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#![cfg_attr(
32    all(target_feature = "atomics", target_arch = "wasm64"),
33    feature(simd_wasm64)
34)]
35
36extern crate alloc;
37
38use alloc::string::String;
39use alloc::vec::Vec;
40use core::cmp::Ordering;
41#[cfg(not(js_sys_unstable_apis))]
42use core::convert::Infallible;
43use core::convert::{self, TryFrom};
44use core::f64;
45use core::fmt;
46use core::iter::{self, Product, Sum};
47use core::marker::PhantomData;
48use core::mem::MaybeUninit;
49use core::ops::{Add, BitAnd, BitOr, BitXor, Div, Mul, Neg, Not, Rem, Shl, Shr, Sub};
50use core::str;
51use core::str::FromStr;
52pub use wasm_bindgen;
53use wasm_bindgen::closure::{ScopedClosure, WasmClosure};
54use wasm_bindgen::convert::{FromWasmAbi, IntoWasmAbi, Upcast, UpcastFrom};
55use wasm_bindgen::prelude::*;
56use wasm_bindgen::JsError;
57
58// Re-export sys types as js-sys types
59pub use wasm_bindgen::sys::{JsNullable, JsOption, Null, Promising, Undefined};
60pub use wasm_bindgen::{IntoJsGeneric, JsGeneric};
61
62// When adding new imports:
63//
64// * Keep imports in alphabetical order.
65//
66// * Rename imports with `js_name = ...` according to the note about `camelCase`
67//   and `snake_case` in the module's documentation above.
68//
69// * Include the one sentence summary of the import from the MDN link in the
70//   module's documentation above, and the MDN link itself.
71//
72// * If a function or method can throw an exception, make it catchable by adding
73//   `#[wasm_bindgen(catch)]`.
74//
75// * Add a new `#[test]` into the appropriate file in the
76//   `crates/js-sys/tests/wasm/` directory. If the imported function or method
77//   can throw an exception, make sure to also add test coverage for that case.
78//
79// * Arguments that are `JsValue`s or imported JavaScript types should be taken
80//   by reference.
81//
82// * Name JavaScript's `toString()` method as `to_js_string()` to avoid conflict
83//   with Rust's `ToString` trait.
84
85macro_rules! forward_deref_unop {
86    (impl $imp:ident, $method:ident for $t:ty) => {
87        impl $imp for $t {
88            type Output = <&'static $t as $imp>::Output;
89
90            #[inline]
91            fn $method(self) -> Self::Output {
92                $imp::$method(&self)
93            }
94        }
95    };
96    (impl<$($gen:ident),+> $imp:ident, $method:ident for $t:ty) => {
97        impl<$($gen),+> $imp for $t {
98            type Output = <&'static $t as $imp>::Output;
99
100            #[inline]
101            fn $method(self) -> Self::Output {
102                $imp::$method(&self)
103            }
104        }
105    };
106}
107
108macro_rules! forward_deref_binop {
109    (impl $imp:ident, $method:ident for $t:ty) => {
110        impl<'a> $imp<$t> for &'a $t {
111            type Output = <&'static $t as $imp<&'static $t>>::Output;
112
113            #[inline]
114            fn $method(self, other: $t) -> Self::Output {
115                $imp::$method(self, &other)
116            }
117        }
118
119        impl $imp<&$t> for $t {
120            type Output = <&'static $t as $imp<&'static $t>>::Output;
121
122            #[inline]
123            fn $method(self, other: &$t) -> Self::Output {
124                $imp::$method(&self, other)
125            }
126        }
127
128        impl $imp<$t> for $t {
129            type Output = <&'static $t as $imp<&'static $t>>::Output;
130
131            #[inline]
132            fn $method(self, other: $t) -> Self::Output {
133                $imp::$method(&self, &other)
134            }
135        }
136    };
137    (impl<$($gen:ident),+> $imp:ident, $method:ident for $t:ty) => {
138        impl<'a, $($gen),+> $imp<$t> for &'a $t {
139            type Output = <&'static $t as $imp<&'static $t>>::Output;
140
141            #[inline]
142            fn $method(self, other: $t) -> Self::Output {
143                $imp::$method(self, &other)
144            }
145        }
146
147        impl<$($gen),+> $imp<&$t> for $t {
148            type Output = <&'static $t as $imp<&'static $t>>::Output;
149
150            #[inline]
151            fn $method(self, other: &$t) -> Self::Output {
152                $imp::$method(&self, other)
153            }
154        }
155
156        impl<$($gen),+> $imp<$t> for $t {
157            type Output = <&'static $t as $imp<&'static $t>>::Output;
158
159            #[inline]
160            fn $method(self, other: $t) -> Self::Output {
161                $imp::$method(&self, &other)
162            }
163        }
164    };
165}
166
167macro_rules! forward_js_unop {
168    (impl $imp:ident, $method:ident for $t:ty) => {
169        impl $imp for &$t {
170            type Output = $t;
171
172            #[inline]
173            fn $method(self) -> Self::Output {
174                $imp::$method(JsValue::as_ref(self)).unchecked_into()
175            }
176        }
177
178        forward_deref_unop!(impl $imp, $method for $t);
179    };
180    (impl<$($gen:ident),+> $imp:ident, $method:ident for $t:ty) => {
181        impl<$($gen),+> $imp for &$t {
182            type Output = $t;
183
184            #[inline]
185            fn $method(self) -> Self::Output {
186                $imp::$method(JsValue::as_ref(self)).unchecked_into()
187            }
188        }
189
190        forward_deref_unop!(impl<$($gen),+> $imp, $method for $t);
191    };
192}
193
194macro_rules! forward_js_binop {
195    (impl $imp:ident, $method:ident for $t:ty) => {
196        impl $imp<&$t> for &$t {
197            type Output = $t;
198
199            #[inline]
200            fn $method(self, other: &$t) -> Self::Output {
201                $imp::$method(JsValue::as_ref(self), JsValue::as_ref(other)).unchecked_into()
202            }
203        }
204
205        forward_deref_binop!(impl $imp, $method for $t);
206    };
207    (impl<$($gen:ident),+> $imp:ident, $method:ident for $t:ty) => {
208        impl<$($gen),+> $imp<&$t> for &$t {
209            type Output = $t;
210
211            #[inline]
212            fn $method(self, other: &$t) -> Self::Output {
213                $imp::$method(JsValue::as_ref(self), JsValue::as_ref(other)).unchecked_into()
214            }
215        }
216
217        forward_deref_binop!(impl<$($gen),+> $imp, $method for $t);
218    };
219}
220
221macro_rules! sum_product {
222    ($($a:ident)*) => ($(
223        impl Sum for $a {
224            #[inline]
225            fn sum<I: iter::Iterator<Item=Self>>(iter: I) -> Self {
226                iter.fold(
227                    $a::from(0),
228                    |a, b| a + b,
229                )
230            }
231        }
232
233        impl Product for $a {
234            #[inline]
235            fn product<I: iter::Iterator<Item=Self>>(iter: I) -> Self {
236                iter.fold(
237                    $a::from(1),
238                    |a, b| a * b,
239                )
240            }
241        }
242
243        impl<'a> Sum<&'a $a> for $a {
244            fn sum<I: iter::Iterator<Item=&'a Self>>(iter: I) -> Self {
245                iter.fold(
246                    $a::from(0),
247                    |a, b| a + b,
248                )
249            }
250        }
251
252        impl<'a> Product<&'a $a> for $a {
253            #[inline]
254            fn product<I: iter::Iterator<Item=&'a Self>>(iter: I) -> Self {
255                iter.fold(
256                    $a::from(1),
257                    |a, b| a * b,
258                )
259            }
260        }
261    )*);
262    // Generic variant: impl<T> for Type<T>
263    (impl<$gen:ident> $a:ident<$g2:ident>) => {
264        impl<$gen> Sum for $a<$g2>
265        where
266            $a<$g2>: From<$gen>,
267            $g2: From<u32>
268        {
269            #[inline]
270            fn sum<I: iter::Iterator<Item=Self>>(iter: I) -> Self {
271                iter.fold(
272                    $a::from($g2::from(0)),
273                    |a, b| a + b,
274                )
275            }
276        }
277
278        impl<$gen> Product for $a<$g2>
279        where
280            $a<$g2>: From<$gen>,
281            $g2: From<u32>
282        {
283            #[inline]
284            fn product<I: iter::Iterator<Item=Self>>(iter: I) -> Self {
285                iter.fold(
286                    $a::from($g2::from(1)),
287                    |a, b| a * b,
288                )
289            }
290        }
291
292        impl<'a, $gen> Sum<&'a $a<$g2>> for $a<$g2>
293        where
294            $a<$g2>: From<$gen>,
295            $g2: From<u32>
296        {
297            fn sum<I: iter::Iterator<Item=&'a Self>>(iter: I) -> Self {
298                iter.fold(
299                    $a::from($g2::from(0)),
300                    |a, b| a + b,
301                )
302            }
303        }
304
305        impl<'a, $gen> Product<&'a $a<$g2>> for $a<$g2>
306        where
307            $a<$g2>: From<$gen>,
308            $g2: From<u32>
309        {
310            #[inline]
311            fn product<I: iter::Iterator<Item=&'a Self>>(iter: I) -> Self {
312                iter.fold(
313                    $a::from($g2::from(1)),
314                    |a, b| a * b,
315                )
316            }
317        }
318    };
319}
320
321macro_rules! partialord_ord {
322    ($t:ident) => {
323        impl PartialOrd for $t {
324            #[inline]
325            fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
326                Some(self.cmp(other))
327            }
328
329            #[inline]
330            fn lt(&self, other: &Self) -> bool {
331                JsValue::as_ref(self).lt(JsValue::as_ref(other))
332            }
333
334            #[inline]
335            fn le(&self, other: &Self) -> bool {
336                JsValue::as_ref(self).le(JsValue::as_ref(other))
337            }
338
339            #[inline]
340            fn ge(&self, other: &Self) -> bool {
341                JsValue::as_ref(self).ge(JsValue::as_ref(other))
342            }
343
344            #[inline]
345            fn gt(&self, other: &Self) -> bool {
346                JsValue::as_ref(self).gt(JsValue::as_ref(other))
347            }
348        }
349
350        impl Ord for $t {
351            #[inline]
352            fn cmp(&self, other: &Self) -> Ordering {
353                if self == other {
354                    Ordering::Equal
355                } else if self.lt(other) {
356                    Ordering::Less
357                } else {
358                    Ordering::Greater
359                }
360            }
361        }
362    };
363}
364
365#[wasm_bindgen]
366extern "C" {
367    /// The `decodeURI()` function decodes a Uniform Resource Identifier (URI)
368    /// previously created by `encodeURI` or by a similar routine.
369    ///
370    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURI)
371    #[wasm_bindgen(catch, js_name = decodeURI)]
372    pub fn decode_uri(encoded: &str) -> Result<JsString, JsValue>;
373
374    /// The `decodeURIComponent()` function decodes a Uniform Resource Identifier (URI) component
375    /// previously created by `encodeURIComponent` or by a similar routine.
376    ///
377    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent)
378    #[wasm_bindgen(catch, js_name = decodeURIComponent)]
379    pub fn decode_uri_component(encoded: &str) -> Result<JsString, JsValue>;
380
381    /// The `encodeURI()` function encodes a Uniform Resource Identifier (URI)
382    /// by replacing each instance of certain characters by one, two, three, or
383    /// four escape sequences representing the UTF-8 encoding of the character
384    /// (will only be four escape sequences for characters composed of two
385    /// "surrogate" characters).
386    ///
387    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI)
388    #[wasm_bindgen(js_name = encodeURI)]
389    pub fn encode_uri(decoded: &str) -> JsString;
390
391    /// The `encodeURIComponent()` function encodes a Uniform Resource Identifier (URI) component
392    /// by replacing each instance of certain characters by one, two, three, or four escape sequences
393    /// representing the UTF-8 encoding of the character
394    /// (will only be four escape sequences for characters composed of two "surrogate" characters).
395    ///
396    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent)
397    #[wasm_bindgen(js_name = encodeURIComponent)]
398    pub fn encode_uri_component(decoded: &str) -> JsString;
399
400    /// The `eval()` function evaluates JavaScript code represented as a string.
401    ///
402    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval)
403    #[cfg(feature = "unsafe-eval")]
404    #[wasm_bindgen(catch)]
405    pub fn eval(js_source_text: &str) -> Result<JsValue, JsValue>;
406
407    /// The global `isFinite()` function determines whether the passed value is a finite number.
408    /// If needed, the parameter is first converted to a number.
409    ///
410    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/isFinite)
411    #[wasm_bindgen(js_name = isFinite)]
412    pub fn is_finite(value: &JsValue) -> bool;
413
414    /// The `parseInt()` function parses a string argument and returns an integer
415    /// of the specified radix (the base in mathematical numeral systems), or NaN on error.
416    ///
417    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt)
418    #[wasm_bindgen(js_name = parseInt)]
419    pub fn parse_int(text: &str, radix: u8) -> f64;
420
421    /// The `parseFloat()` function parses an argument and returns a floating point number,
422    /// or NaN on error.
423    ///
424    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseFloat)
425    #[wasm_bindgen(js_name = parseFloat)]
426    pub fn parse_float(text: &str) -> f64;
427
428    /// The `escape()` function computes a new string in which certain characters have been
429    /// replaced by a hexadecimal escape sequence.
430    ///
431    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/escape)
432    #[wasm_bindgen]
433    pub fn escape(string: &str) -> JsString;
434
435    /// The `unescape()` function computes a new string in which hexadecimal escape
436    /// sequences are replaced with the character that it represents. The escape sequences might
437    /// be introduced by a function like `escape`. Usually, `decodeURI` or `decodeURIComponent`
438    /// are preferred over `unescape`.
439    ///
440    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/unescape)
441    #[wasm_bindgen]
442    pub fn unescape(string: &str) -> JsString;
443}
444
445// AggregateError
446#[wasm_bindgen]
447extern "C" {
448    /// The `AggregateError` object represents an error when several errors need
449    /// to be wrapped in a single error. It is thrown when multiple errors need
450    /// to be reported by an operation, for example by [`Promise::any`], when
451    /// all promises passed to it reject.
452    ///
453    /// `AggregateError` is a subclass of [`Error`].
454    ///
455    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AggregateError)
456    #[wasm_bindgen(extends = Error, extends = Object, typescript_type = "AggregateError")]
457    #[derive(Clone, Debug, PartialEq, Eq)]
458    pub type AggregateError;
459
460    /// Creates a new `AggregateError` from the given iterable of errors.
461    ///
462    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AggregateError/AggregateError)
463    #[wasm_bindgen(constructor)]
464    pub fn new(errors: &[JsValue]) -> AggregateError;
465
466    /// Creates a new `AggregateError` from the given iterable of errors with a
467    /// human-readable description of the aggregate error.
468    ///
469    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AggregateError/AggregateError)
470    #[wasm_bindgen(constructor)]
471    pub fn new_with_message(errors: &[JsValue], message: &str) -> AggregateError;
472
473    /// Creates a new `AggregateError` from the given iterable of errors, a
474    /// human-readable description of the aggregate error, and an
475    /// [`ErrorOptions`] dictionary whose `cause` property indicates the
476    /// original cause of the error.
477    ///
478    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AggregateError/AggregateError)
479    #[wasm_bindgen(constructor)]
480    pub fn new_with_options(
481        errors: &[JsValue],
482        message: &str,
483        options: &ErrorOptions,
484    ) -> AggregateError;
485
486    /// The `errors` property of an `AggregateError` instance is an array
487    /// representing the errors that were aggregated.
488    ///
489    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AggregateError/errors)
490    #[wasm_bindgen(method, getter)]
491    pub fn errors(this: &AggregateError) -> Array;
492}
493
494// ErrorOptions
495#[wasm_bindgen]
496extern "C" {
497    /// The options dictionary accepted as the second argument to the
498    /// [`Error`] constructor (and other built-in error constructors such as
499    /// [`AggregateError`]). Its sole standard property is `cause`, which
500    /// indicates the original cause of the error.
501    ///
502    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/Error)
503    #[wasm_bindgen(extends = Object, typescript_type = "ErrorOptions")]
504    #[derive(Clone, Debug, PartialEq, Eq)]
505    pub type ErrorOptions;
506
507    /// The `cause` property indicates the underlying cause of an error.
508    ///
509    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause)
510    #[wasm_bindgen(method, getter = "cause")]
511    pub fn get_cause(this: &ErrorOptions) -> JsValue;
512
513    /// Sets the `cause` property of this `ErrorOptions` dictionary.
514    ///
515    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause)
516    #[wasm_bindgen(method, setter = "cause")]
517    pub fn set_cause(this: &ErrorOptions, cause: &JsValue);
518}
519
520impl ErrorOptions {
521    /// Construct a new `ErrorOptions` dictionary with the given `cause`.
522    pub fn new(cause: &JsValue) -> Self {
523        let ret: Self = ::wasm_bindgen::JsCast::unchecked_into(Object::new());
524        ret.set_cause(cause);
525        ret
526    }
527}
528
529// Array
530#[wasm_bindgen]
531extern "C" {
532    #[wasm_bindgen(extends = Object, is_type_of = Array::is_array, typescript_type = "Array<any>")]
533    #[derive(Clone, Debug, PartialEq, Eq)]
534    pub type Array<T = JsValue>;
535
536    /// Creates a new empty array.
537    ///
538    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Array)
539    #[cfg(not(js_sys_unstable_apis))]
540    #[wasm_bindgen(constructor)]
541    pub fn new() -> Array;
542
543    /// Creates a new empty array.
544    ///
545    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Array)
546    #[cfg(js_sys_unstable_apis)]
547    #[wasm_bindgen(constructor)]
548    pub fn new<T>() -> Array<T>;
549
550    // Next major: deprecate
551    /// Creates a new empty array.
552    ///
553    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Array)
554    #[wasm_bindgen(constructor)]
555    pub fn new_typed<T>() -> Array<T>;
556
557    /// Creates a new array with the specified length (elements are initialized to `undefined`).
558    ///
559    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Array)
560    #[cfg(not(js_sys_unstable_apis))]
561    #[wasm_bindgen(constructor)]
562    pub fn new_with_length(len: u32) -> Array;
563
564    /// Creates a new array with the specified length (elements are initialized to `undefined`).
565    ///
566    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Array)
567    #[cfg(js_sys_unstable_apis)]
568    #[wasm_bindgen(constructor)]
569    pub fn new_with_length<T>(len: u32) -> Array<T>;
570
571    // Next major: deprecate
572    /// Creates a new array with the specified length (elements are initialized to `undefined`).
573    ///
574    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Array)
575    #[wasm_bindgen(constructor)]
576    pub fn new_with_length_typed<T>(len: u32) -> Array<T>;
577
578    /// Retrieves the element at the index, counting from the end if negative
579    /// (returns `undefined` if the index is out of range).
580    ///
581    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at)
582    #[cfg(not(js_sys_unstable_apis))]
583    #[wasm_bindgen(method)]
584    pub fn at<T>(this: &Array<T>, index: i32) -> T;
585
586    /// Retrieves the element at the index, counting from the end if negative
587    /// (returns `None` if the index is out of range).
588    ///
589    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at)
590    #[cfg(js_sys_unstable_apis)]
591    #[wasm_bindgen(method)]
592    pub fn at<T>(this: &Array<T>, index: i32) -> Option<T>;
593
594    /// Retrieves the element at the index (returns `undefined` if the index is out of range).
595    ///
596    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at)
597    #[cfg(not(js_sys_unstable_apis))]
598    #[wasm_bindgen(method, indexing_getter)]
599    pub fn get<T>(this: &Array<T>, index: u32) -> T;
600
601    /// Retrieves the element at the index (returns `None` if the index is out of range).
602    ///
603    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at)
604    #[cfg(js_sys_unstable_apis)]
605    #[wasm_bindgen(method, indexing_getter)]
606    pub fn get<T>(this: &Array<T>, index: u32) -> Option<T>;
607
608    /// Retrieves the element at the index (returns `undefined` if the index is out of range).
609    ///
610    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at)
611    #[wasm_bindgen(method, indexing_getter)]
612    pub fn get_unchecked<T>(this: &Array<T>, index: u32) -> T;
613
614    // Next major: deprecate
615    /// Retrieves the element at the index (returns `None` if the index is out of range,
616    /// or if the element is explicitly `undefined`).
617    #[wasm_bindgen(method, indexing_getter)]
618    pub fn get_checked<T>(this: &Array<T>, index: u32) -> Option<T>;
619
620    /// Sets the element at the index (auto-enlarges the array if the index is out of range).
621    #[cfg(not(js_sys_unstable_apis))]
622    #[wasm_bindgen(method, indexing_setter)]
623    pub fn set<T>(this: &Array<T>, index: u32, value: T);
624
625    /// Sets the element at the index (auto-enlarges the array if the index is out of range).
626    #[cfg(js_sys_unstable_apis)]
627    #[wasm_bindgen(method, indexing_setter)]
628    pub fn set<T>(this: &Array<T>, index: u32, value: &T);
629
630    // Next major: deprecate
631    /// Sets the element at the index (auto-enlarges the array if the index is out of range).
632    #[wasm_bindgen(method, indexing_setter)]
633    pub fn set_ref<T>(this: &Array<T>, index: u32, value: &T);
634
635    /// Deletes the element at the index (does nothing if the index is out of range).
636    ///
637    /// The element at the index is set to `undefined`.
638    ///
639    /// This does not resize the array, the array will still be the same length.
640    #[wasm_bindgen(method, indexing_deleter)]
641    pub fn delete<T>(this: &Array<T>, index: u32);
642
643    /// The `Array.from()` static method creates a new, shallow-copied `Array` instance
644    /// from an array-like or iterable object.
645    ///
646    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from)
647    #[cfg(not(js_sys_unstable_apis))]
648    #[wasm_bindgen(static_method_of = Array)]
649    pub fn from(val: &JsValue) -> Array;
650
651    /// The `Array.from()` static method creates a new, shallow-copied `Array` instance
652    /// from an array-like or iterable object.
653    ///
654    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from)
655    #[cfg(js_sys_unstable_apis)]
656    #[wasm_bindgen(static_method_of = Array, catch, js_name = from)]
657    pub fn from<I: Iterable>(val: &I) -> Result<Array<I::Item>, JsValue>;
658
659    // Next major: deprecate
660    /// The `Array.from()` static method creates a new, shallow-copied `Array` instance
661    /// from an array-like or iterable object.
662    ///
663    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from)
664    #[wasm_bindgen(static_method_of = Array, catch, js_name = from)]
665    pub fn from_iterable<I: Iterable>(val: &I) -> Result<Array<I::Item>, JsValue>;
666
667    /// The `Array.from()` static method with a map function creates a new, shallow-copied
668    /// `Array` instance from an array-like or iterable object, applying the map function
669    /// to each value.
670    ///
671    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from)
672    #[wasm_bindgen(static_method_of = Array, catch, js_name = from)]
673    pub fn from_iterable_map<I: Iterable, U>(
674        val: &I,
675        map: &mut dyn FnMut(I::Item, u32) -> Result<U, JsError>,
676    ) -> Result<Array<U>, JsValue>;
677
678    /// The `Array.fromAsync()` static method creates a new, shallow-copied `Array` instance
679    /// from an async iterable, iterable or array-like object.
680    ///
681    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fromAsync)
682    #[wasm_bindgen(static_method_of = Array, catch, js_name = fromAsync)]
683    pub fn from_async<I: AsyncIterable>(val: &I) -> Result<Promise<Array<I::Item>>, JsValue>;
684
685    /// The `Array.fromAsync()` static method with a map function creates a new, shallow-copied
686    /// `Array` instance from an async iterable, iterable or array-like object, applying the map
687    /// function to each value.
688    ///
689    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fromAsync)
690    #[wasm_bindgen(static_method_of = Array, catch, js_name = fromAsync)]
691    pub fn from_async_map<'a, I: AsyncIterable, R: Promising>(
692        val: &I,
693        map: &ScopedClosure<'a, dyn FnMut(I::Item, u32) -> Result<R, JsError>>,
694    ) -> Result<Promise<Array<R::Resolution>>, JsValue>;
695
696    /// The `copyWithin()` method shallow copies part of an array to another
697    /// location in the same array and returns it, without modifying its size.
698    ///
699    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin)
700    #[wasm_bindgen(method, js_name = copyWithin)]
701    pub fn copy_within<T>(this: &Array<T>, target: i32, start: i32, end: i32) -> Array<T>;
702
703    /// The `concat()` method is used to merge two or more arrays. This method
704    /// does not change the existing arrays, but instead returns a new array.
705    ///
706    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat)
707    #[wasm_bindgen(method)]
708    pub fn concat<T, U: Upcast<T>>(this: &Array<T>, array: &Array<U>) -> Array<T>;
709
710    /// The `concat()` method is used to merge two or more arrays. This method
711    /// does not change the existing arrays, but instead returns a new array.
712    ///
713    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat)
714    #[wasm_bindgen(method)]
715    pub fn concat_many<T, U: Upcast<T>>(this: &Array<T>, array: &[Array<U>]) -> Array<T>;
716
717    /// The `every()` method tests whether all elements in the array pass the test
718    /// implemented by the provided function.
719    ///
720    /// **Note:** Consider using [`Array::try_every`] if the predicate might throw an error.
721    ///
722    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every)
723    #[wasm_bindgen(method)]
724    pub fn every<T>(this: &Array<T>, predicate: &mut dyn FnMut(T, u32, Array<T>) -> bool) -> bool;
725
726    /// The `every()` method tests whether all elements in the array pass the test
727    /// implemented by the provided function. _(Fallible variation)_
728    ///
729    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every)
730    #[wasm_bindgen(method, js_name = every, catch)]
731    pub fn try_every<T>(
732        this: &Array<T>,
733        predicate: &mut dyn FnMut(T, u32) -> Result<bool, JsError>,
734    ) -> Result<bool, JsValue>;
735
736    /// The `fill()` method fills all the elements of an array from a start index
737    /// to an end index with a static value. The end index is not included.
738    ///
739    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fill)
740    #[wasm_bindgen(method)]
741    pub fn fill<T>(this: &Array<T>, value: &T, start: u32, end: u32) -> Array<T>;
742
743    /// The `filter()` method creates a new array with all elements that pass the
744    /// test implemented by the provided function.
745    ///
746    /// **Note:** Consider using [`Array::try_filter`] if the predicate might throw an error.
747    ///
748    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter)
749    #[wasm_bindgen(method)]
750    pub fn filter<T>(
751        this: &Array<T>,
752        predicate: &mut dyn FnMut(T, u32, Array<T>) -> bool,
753    ) -> Array<T>;
754
755    /// The `filter()` method creates a new array with all elements that pass the
756    /// test implemented by the provided function. _(Fallible variation)_
757    ///
758    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter)
759    #[wasm_bindgen(method, js_name = filter, catch)]
760    pub fn try_filter<T>(
761        this: &Array<T>,
762        predicate: &mut dyn FnMut(T, u32) -> Result<bool, JsError>,
763    ) -> Result<Array<T>, JsValue>;
764
765    /// The `find()` method returns the value of the first element in the array that satisfies
766    /// the provided testing function. Otherwise `undefined` is returned.
767    ///
768    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find)
769    #[cfg(not(js_sys_unstable_apis))]
770    #[wasm_bindgen(method)]
771    pub fn find<T>(this: &Array<T>, predicate: &mut dyn FnMut(T, u32, Array<T>) -> bool) -> T;
772
773    /// The `find()` method returns the value of the first element in the array that satisfies
774    /// the provided testing function. Returns `None` if no element matches.
775    ///
776    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find)
777    #[cfg(js_sys_unstable_apis)]
778    #[wasm_bindgen(method)]
779    pub fn find<T>(
780        this: &Array<T>,
781        predicate: &mut dyn FnMut(T, u32, Array<T>) -> bool,
782    ) -> Option<T>;
783
784    /// The `find()` method returns the value of the first element in the array that satisfies
785    ///  the provided testing function. Otherwise `undefined` is returned. _(Fallible variation)_
786    ///
787    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find)
788    #[wasm_bindgen(method, js_name = find, catch)]
789    pub fn try_find<T>(
790        this: &Array<T>,
791        predicate: &mut dyn FnMut(T, u32) -> Result<bool, JsError>,
792    ) -> Result<Option<T>, JsValue>;
793
794    /// The `findIndex()` method returns the index of the first element in the array that
795    /// satisfies the provided testing function. Otherwise -1 is returned.
796    ///
797    /// **Note:** Consider using [`Array::try_find_index`] if the predicate might throw an error.
798    ///
799    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex)
800    #[wasm_bindgen(method, js_name = findIndex)]
801    pub fn find_index<T>(
802        this: &Array<T>,
803        predicate: &mut dyn FnMut(T, u32, Array<T>) -> bool,
804    ) -> i32;
805
806    /// The `findIndex()` method returns the index of the first element in the array that
807    /// satisfies the provided testing function. Otherwise -1 is returned. _(Fallible variation)_
808    ///
809    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex)
810    #[wasm_bindgen(method, js_name = findIndex, catch)]
811    pub fn try_find_index<T>(
812        this: &Array<T>,
813        predicate: &mut dyn FnMut(T, u32) -> Result<bool, JsError>,
814    ) -> Result<i32, JsValue>;
815
816    /// The `findLast()` method of Array instances iterates the array in reverse order
817    /// and returns the value of the first element that satisfies the provided testing function.
818    /// If no elements satisfy the testing function, undefined is returned.
819    ///
820    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findLast)
821    #[cfg(not(js_sys_unstable_apis))]
822    #[wasm_bindgen(method, js_name = findLast)]
823    pub fn find_last<T>(this: &Array<T>, predicate: &mut dyn FnMut(T, u32, Array<T>) -> bool) -> T;
824
825    /// The `findLast()` method of Array instances iterates the array in reverse order
826    /// and returns the value of the first element that satisfies the provided testing function.
827    /// Returns `None` if no element matches.
828    ///
829    /// **Note:** Consider using [`Array::try_find_last`] if the predicate might throw an error.
830    ///
831    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findLast)
832    #[cfg(js_sys_unstable_apis)]
833    #[wasm_bindgen(method, js_name = findLast)]
834    pub fn find_last<T>(this: &Array<T>, predicate: &mut dyn FnMut(T, u32) -> bool) -> Option<T>;
835
836    /// The `findLast()` method of Array instances iterates the array in reverse order
837    /// and returns the value of the first element that satisfies the provided testing function.
838    /// If no elements satisfy the testing function, undefined is returned. _(Fallible variation)_
839    ///
840    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findLast)
841    #[wasm_bindgen(method, js_name = findLast, catch)]
842    pub fn try_find_last<T>(
843        this: &Array<T>,
844        predicate: &mut dyn FnMut(T, u32) -> Result<bool, JsError>,
845    ) -> Result<Option<T>, JsValue>;
846
847    /// The `findLastIndex()` method of Array instances iterates the array in reverse order
848    /// and returns the index of the first element that satisfies the provided testing function.
849    /// If no elements satisfy the testing function, -1 is returned.
850    ///
851    /// **Note:** Consider using [`Array::try_find_last_index`] if the predicate might throw an error.
852    ///
853    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findLastIndex)
854    #[wasm_bindgen(method, js_name = findLastIndex)]
855    pub fn find_last_index<T>(
856        this: &Array<T>,
857        predicate: &mut dyn FnMut(T, u32, Array<T>) -> bool,
858    ) -> i32;
859
860    /// The `findLastIndex()` method of Array instances iterates the array in reverse order
861    /// and returns the index of the first element that satisfies the provided testing function.
862    /// If no elements satisfy the testing function, -1 is returned. _(Fallible variation)_
863    ///
864    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findLastIndex)
865    #[wasm_bindgen(method, js_name = findLastIndex, catch)]
866    pub fn try_find_last_index<T>(
867        this: &Array<T>,
868        predicate: &mut dyn FnMut(T, u32) -> Result<bool, JsError>,
869    ) -> Result<i32, JsValue>;
870
871    /// The `flat()` method creates a new array with all sub-array elements concatenated into it
872    /// recursively up to the specified depth.
873    ///
874    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat)
875    #[wasm_bindgen(method)]
876    pub fn flat<T>(this: &Array<T>, depth: i32) -> Array<JsValue>;
877
878    /// The `flatMap()` method first maps each element using a mapping function, then flattens
879    /// the result into a new array.
880    ///
881    /// **Note:** Consider using [`Array::try_flat_map`] for safer fallible handling.
882    ///
883    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap)
884    #[wasm_bindgen(method, js_name = flatMap)]
885    pub fn flat_map<T, U>(
886        this: &Array<T>,
887        callback: &mut dyn FnMut(T, u32, Array<T>) -> Vec<U>,
888    ) -> Array<U>;
889
890    /// The `flatMap()` method first maps each element using a mapping function, then flattens
891    /// the result into a new array.
892    ///
893    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap)
894    #[wasm_bindgen(method, js_name = flatMap, catch)]
895    pub fn try_flat_map<T, U>(
896        this: &Array<T>,
897        callback: &mut dyn FnMut(T, u32) -> Vec<U>,
898    ) -> Result<Array<U>, JsValue>;
899
900    /// The `forEach()` method executes a provided function once for each array element.
901    ///
902    /// **Note:** Consider using [`Array::try_for_each`] if the callback might throw an error.
903    ///
904    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach)
905    #[wasm_bindgen(method, js_name = forEach)]
906    pub fn for_each<T: JsGeneric>(this: &Array<T>, callback: &mut dyn FnMut(T, u32, Array<T>));
907
908    /// The `forEach()` method executes a provided function once for each array element. _(Fallible variation)_
909    ///
910    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach)
911    #[wasm_bindgen(method, js_name = forEach, catch)]
912    pub fn try_for_each<T>(
913        this: &Array<T>,
914        callback: &mut dyn FnMut(T, u32) -> Result<(), JsError>,
915    ) -> Result<(), JsValue>;
916
917    /// The `includes()` method determines whether an array includes a certain
918    /// element, returning true or false as appropriate.
919    ///
920    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes)
921    #[wasm_bindgen(method)]
922    pub fn includes<T>(this: &Array<T>, value: &T, from_index: i32) -> bool;
923
924    /// The `indexOf()` method returns the first index at which a given element
925    /// can be found in the array, or -1 if it is not present.
926    ///
927    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf)
928    #[wasm_bindgen(method, js_name = indexOf)]
929    pub fn index_of<T>(this: &Array<T>, value: &T, from_index: i32) -> i32;
930
931    /// The `Array.isArray()` method determines whether the passed value is an Array.
932    ///
933    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray)
934    #[wasm_bindgen(static_method_of = Array, js_name = isArray)]
935    pub fn is_array(value: &JsValue) -> bool;
936
937    /// The `join()` method joins all elements of an array (or an array-like object)
938    /// into a string and returns this string.
939    ///
940    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join)
941    #[wasm_bindgen(method)]
942    pub fn join<T>(this: &Array<T>, delimiter: &str) -> JsString;
943
944    /// The `lastIndexOf()` method returns the last index at which a given element
945    /// can be found in the array, or -1 if it is not present. The array is
946    /// searched backwards, starting at fromIndex.
947    ///
948    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf)
949    #[wasm_bindgen(method, js_name = lastIndexOf)]
950    pub fn last_index_of<T>(this: &Array<T>, value: &T, from_index: i32) -> i32;
951
952    /// The length property of an object which is an instance of type Array
953    /// sets or returns the number of elements in that array. The value is an
954    /// unsigned, 32-bit integer that is always numerically greater than the
955    /// highest index in the array.
956    ///
957    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/length)
958    #[wasm_bindgen(method, getter)]
959    pub fn length<T>(this: &Array<T>) -> u32;
960
961    /// Sets the length of the array.
962    ///
963    /// If it is set to less than the current length of the array, it will
964    /// shrink the array.
965    ///
966    /// If it is set to more than the current length of the array, it will
967    /// increase the length of the array, filling the new space with empty
968    /// slots.
969    ///
970    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/length)
971    #[wasm_bindgen(method, setter)]
972    pub fn set_length<T>(this: &Array<T>, value: u32);
973
974    /// `map()` calls a provided callback function once for each element in an array,
975    /// in order, and constructs a new array from the results. callback is invoked
976    /// only for indexes of the array which have assigned values, including undefined.
977    /// It is not called for missing elements of the array (that is, indexes that have
978    /// never been set, which have been deleted or which have never been assigned a value).
979    ///
980    /// **Note:** Consider using [`Array::try_map`] for safer fallible handling.
981    ///
982    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map)
983    #[wasm_bindgen(method)]
984    pub fn map<T, U>(this: &Array<T>, predicate: &mut dyn FnMut(T, u32, Array<T>) -> U)
985        -> Array<U>;
986
987    /// `map()` calls a provided callback function once for each element in an array,
988    /// in order, and constructs a new array from the results. callback is invoked
989    /// only for indexes of the array which have assigned values, including undefined.
990    /// It is not called for missing elements of the array (that is, indexes that have
991    /// never been set, which have been deleted or which have never been assigned a value).
992    /// _(Fallible variation)_
993    ///
994    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map)
995    #[wasm_bindgen(method, js_name = map, catch)]
996    pub fn try_map<T, U>(
997        this: &Array<T>,
998        predicate: &mut dyn FnMut(T, u32) -> Result<U, JsError>,
999    ) -> Result<Array<U>, JsValue>;
1000
1001    /// The `Array.of()` method creates a new Array instance with a variable
1002    /// number of arguments, regardless of number or type of the arguments.
1003    ///
1004    /// Note: For type inference use `Array::<T>::of(&[T])`.
1005    ///
1006    /// The difference between `Array.of()` and the `Array` constructor is in the
1007    /// handling of integer arguments: `Array.of(7)` creates an array with a single
1008    /// element, `7`, whereas `Array(7)` creates an empty array with a `length`
1009    /// property of `7` (Note: this implies an array of 7 empty slots, not slots
1010    /// with actual undefined values).
1011    ///
1012    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/of)
1013    #[wasm_bindgen(static_method_of = Array, js_name = of, variadic)]
1014    pub fn of<T>(values: &[T]) -> Array<T>;
1015
1016    // Next major: deprecate these
1017    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/of)
1018    #[wasm_bindgen(static_method_of = Array, js_name = of)]
1019    pub fn of1(a: &JsValue) -> Array;
1020
1021    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/of)
1022    #[wasm_bindgen(static_method_of = Array, js_name = of)]
1023    pub fn of2(a: &JsValue, b: &JsValue) -> Array;
1024
1025    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/of)
1026    #[wasm_bindgen(static_method_of = Array, js_name = of)]
1027    pub fn of3(a: &JsValue, b: &JsValue, c: &JsValue) -> Array;
1028
1029    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/of)
1030    #[wasm_bindgen(static_method_of = Array, js_name = of)]
1031    pub fn of4(a: &JsValue, b: &JsValue, c: &JsValue, d: &JsValue) -> Array;
1032
1033    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/of)
1034    #[wasm_bindgen(static_method_of = Array, js_name = of)]
1035    pub fn of5(a: &JsValue, b: &JsValue, c: &JsValue, d: &JsValue, e: &JsValue) -> Array;
1036
1037    /// The `pop()` method removes the last element from an array and returns that
1038    /// element. This method changes the length of the array.
1039    ///
1040    /// **Note:** Consider using [`Array::pop_checked`] for handling empty arrays.
1041    ///
1042    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/pop)
1043    #[cfg(not(js_sys_unstable_apis))]
1044    #[wasm_bindgen(method)]
1045    pub fn pop<T>(this: &Array<T>) -> T;
1046
1047    /// The `pop()` method removes the last element from an array and returns that
1048    /// element. This method changes the length of the array.
1049    /// Returns `None` if the array is empty.
1050    ///
1051    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/pop)
1052    #[cfg(js_sys_unstable_apis)]
1053    #[wasm_bindgen(method)]
1054    pub fn pop<T>(this: &Array<T>) -> Option<T>;
1055
1056    // Next major: deprecate
1057    /// The `pop()` method removes the last element from an array and returns that
1058    /// element. This method changes the length of the array.
1059    ///
1060    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/pop)
1061    #[wasm_bindgen(method, js_name = pop)]
1062    pub fn pop_checked<T>(this: &Array<T>) -> Option<T>;
1063
1064    /// The `push()` method adds one element to the end of an array and
1065    /// returns the new length of the array.
1066    ///
1067    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push)
1068    #[wasm_bindgen(method)]
1069    pub fn push<T>(this: &Array<T>, value: &T) -> u32;
1070
1071    /// The `push()` method adds one or more elements to the end of an array and
1072    /// returns the new length of the array.
1073    ///
1074    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push)
1075    #[wasm_bindgen(method, js_name = push, variadic)]
1076    pub fn push_many<T>(this: &Array<T>, values: &[T]) -> u32;
1077
1078    /// The `reduce()` method applies a function against an accumulator and each element in
1079    /// the array (from left to right) to reduce it to a single value.
1080    ///
1081    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce)
1082    #[cfg(not(js_sys_unstable_apis))]
1083    #[wasm_bindgen(method)]
1084    pub fn reduce<T>(
1085        this: &Array<T>,
1086        predicate: &mut dyn FnMut(JsValue, T, u32, Array<T>) -> JsValue,
1087        initial_value: &JsValue,
1088    ) -> JsValue;
1089
1090    /// The `reduce()` method applies a function against an accumulator and each element in
1091    /// the array (from left to right) to reduce it to a single value.
1092    ///
1093    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce)
1094    #[cfg(js_sys_unstable_apis)]
1095    #[wasm_bindgen(method)]
1096    pub fn reduce<T, A>(
1097        this: &Array<T>,
1098        predicate: &mut dyn FnMut(A, T, u32, Array<T>) -> A,
1099        initial_value: &A,
1100    ) -> A;
1101
1102    /// The `reduce()` method applies a function against an accumulator and each element in
1103    /// the array (from left to right) to reduce it to a single value. _(Fallible variation)_
1104    ///
1105    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce)
1106    #[wasm_bindgen(method, js_name = reduce, catch)]
1107    pub fn try_reduce<T, A>(
1108        this: &Array<T>,
1109        predicate: &mut dyn FnMut(A, T, u32) -> Result<A, JsError>,
1110        initial_value: &A,
1111    ) -> Result<A, JsValue>;
1112
1113    /// The `reduceRight()` method applies a function against an accumulator and each value
1114    /// of the array (from right-to-left) to reduce it to a single value.
1115    ///
1116    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/ReduceRight)
1117    #[cfg(not(js_sys_unstable_apis))]
1118    #[wasm_bindgen(method, js_name = reduceRight)]
1119    pub fn reduce_right<T>(
1120        this: &Array<T>,
1121        predicate: &mut dyn FnMut(JsValue, T, u32, Array<T>) -> JsValue,
1122        initial_value: &JsValue,
1123    ) -> JsValue;
1124
1125    /// The `reduceRight()` method applies a function against an accumulator and each value
1126    /// of the array (from right-to-left) to reduce it to a single value.
1127    ///
1128    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/ReduceRight)
1129    #[cfg(js_sys_unstable_apis)]
1130    #[wasm_bindgen(method, js_name = reduceRight)]
1131    pub fn reduce_right<T, A>(
1132        this: &Array<T>,
1133        predicate: &mut dyn FnMut(A, T, u32, Array<T>) -> A,
1134        initial_value: &A,
1135    ) -> A;
1136
1137    /// The `reduceRight()` method applies a function against an accumulator and each value
1138    /// of the array (from right-to-left) to reduce it to a single value. _(Fallible variation)_
1139    ///
1140    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/ReduceRight)
1141    #[wasm_bindgen(method, js_name = reduceRight, catch)]
1142    pub fn try_reduce_right<T, A>(
1143        this: &Array<T>,
1144        predicate: &mut dyn FnMut(JsValue, T, u32) -> Result<A, JsError>,
1145        initial_value: &A,
1146    ) -> Result<A, JsValue>;
1147
1148    /// The `reverse()` method reverses an array in place. The first array
1149    /// element becomes the last, and the last array element becomes the first.
1150    ///
1151    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse)
1152    #[wasm_bindgen(method)]
1153    pub fn reverse<T>(this: &Array<T>) -> Array<T>;
1154
1155    /// The `shift()` method removes the first element from an array and returns
1156    /// that removed element. This method changes the length of the array.
1157    ///
1158    /// **Note:** Consider using [`Array::shift_checked`] for handling empty arrays.
1159    ///
1160    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/shift)
1161    #[cfg(not(js_sys_unstable_apis))]
1162    #[wasm_bindgen(method)]
1163    pub fn shift<T>(this: &Array<T>) -> T;
1164
1165    /// The `shift()` method removes the first element from an array and returns
1166    /// that removed element. This method changes the length of the array.
1167    /// Returns `None` if the array is empty.
1168    ///
1169    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/shift)
1170    #[cfg(js_sys_unstable_apis)]
1171    #[wasm_bindgen(method)]
1172    pub fn shift<T>(this: &Array<T>) -> Option<T>;
1173
1174    // Next major: deprecate
1175    /// The `shift()` method removes the first element from an array and returns
1176    /// that removed element. This method changes the length of the array.
1177    ///
1178    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/shift)
1179    #[wasm_bindgen(method, js_name = shift)]
1180    pub fn shift_checked<T>(this: &Array<T>) -> Option<T>;
1181
1182    /// The `slice()` method returns a shallow copy of a portion of an array into
1183    /// a new array object selected from begin to end (end not included).
1184    /// The original array will not be modified.
1185    ///
1186    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice)
1187    #[cfg(not(js_sys_unstable_apis))]
1188    #[wasm_bindgen(method)]
1189    pub fn slice<T>(this: &Array<T>, start: u32, end: u32) -> Array<T>;
1190
1191    /// The `slice()` method returns a shallow copy of a portion of an array into
1192    /// a new array object selected from begin to end (end not included).
1193    /// The original array will not be modified. Negative indices count from the end.
1194    ///
1195    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice)
1196    #[cfg(js_sys_unstable_apis)]
1197    #[wasm_bindgen(method)]
1198    pub fn slice<T>(this: &Array<T>, start: i32, end: i32) -> Array<T>;
1199
1200    /// The `slice()` method returns a shallow copy of a portion of an array into
1201    /// a new array object selected from the given index to the end.
1202    /// The original array will not be modified.
1203    ///
1204    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice)
1205    #[cfg(not(js_sys_unstable_apis))]
1206    #[wasm_bindgen(method, js_name = slice)]
1207    pub fn slice_from<T>(this: &Array<T>, start: u32) -> Array<T>;
1208
1209    /// The `slice()` method returns a shallow copy of a portion of an array into
1210    /// a new array object selected from the given index to the end.
1211    /// The original array will not be modified. Negative indices count from the end.
1212    ///
1213    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice)
1214    #[cfg(js_sys_unstable_apis)]
1215    #[wasm_bindgen(method, js_name = slice)]
1216    pub fn slice_from<T>(this: &Array<T>, start: i32) -> Array<T>;
1217
1218    /// The `some()` method tests whether at least one element in the array passes the test implemented
1219    /// by the provided function.
1220    /// Note: This method returns false for any condition put on an empty array.
1221    ///
1222    /// **Note:** Consider using [`Array::try_some`] if the predicate might throw an error.
1223    ///
1224    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some)
1225    #[wasm_bindgen(method)]
1226    pub fn some<T>(this: &Array<T>, predicate: &mut dyn FnMut(T) -> bool) -> bool;
1227
1228    /// The `some()` method tests whether at least one element in the array passes the test implemented
1229    /// by the provided function. _(Fallible variation)_
1230    /// Note: This method returns false for any condition put on an empty array.
1231    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some)
1232    #[wasm_bindgen(method, js_name = some, catch)]
1233    pub fn try_some<T>(
1234        this: &Array<T>,
1235        predicate: &mut dyn FnMut(T) -> Result<bool, JsError>,
1236    ) -> Result<bool, JsValue>;
1237
1238    /// The `sort()` method sorts the elements of an array in place and returns
1239    /// the array. The sort is not necessarily stable. The default sort
1240    /// order is according to string Unicode code points.
1241    ///
1242    /// The time and space complexity of the sort cannot be guaranteed as it
1243    /// is implementation dependent.
1244    ///
1245    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort)
1246    #[wasm_bindgen(method)]
1247    pub fn sort<T>(this: &Array<T>) -> Array<T>;
1248
1249    /// The `sort()` method with a custom compare function.
1250    ///
1251    /// **Note:** Consider using [`Array::try_sort_by`] if the predicate might throw an error.
1252    ///
1253    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort)
1254    #[wasm_bindgen(method, js_name = sort)]
1255    pub fn sort_by<T>(this: &Array<T>, compare_fn: &mut dyn FnMut(T, T) -> i32) -> Array<T>;
1256
1257    /// The `sort()` method with a custom compare function. _(Fallible variation)_
1258    ///
1259    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort)
1260    #[wasm_bindgen(method, js_name = sort, catch)]
1261    pub fn try_sort_by<T>(
1262        this: &Array<T>,
1263        compare_fn: &mut dyn FnMut(T, T) -> Result<i32, JsError>,
1264    ) -> Result<Array<T>, JsValue>;
1265
1266    /// The `splice()` method changes the contents of an array by removing existing elements and/or
1267    /// adding new elements.
1268    ///
1269    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice)
1270    #[wasm_bindgen(method)]
1271    pub fn splice<T>(this: &Array<T>, start: u32, delete_count: u32, item: &T) -> Array<T>;
1272
1273    /// The `splice()` method changes the contents of an array by removing existing elements and/or
1274    /// adding new elements.
1275    ///
1276    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice)
1277    #[wasm_bindgen(method, js_name = splice, variadic)]
1278    pub fn splice_many<T>(this: &Array<T>, start: u32, delete_count: u32, items: &[T]) -> Array<T>;
1279
1280    /// The `toLocaleString()` method returns a string representing the elements of the array.
1281    /// The elements are converted to Strings using their toLocaleString methods and these
1282    /// Strings are separated by a locale-specific String (such as a comma ",").
1283    ///
1284    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toLocaleString)
1285    #[cfg(not(js_sys_unstable_apis))]
1286    #[wasm_bindgen(method, js_name = toLocaleString)]
1287    pub fn to_locale_string<T>(this: &Array<T>, locales: &JsValue, options: &JsValue) -> JsString;
1288
1289    /// The `toLocaleString()` method returns a string representing the elements of the array.
1290    /// The elements are converted to Strings using their toLocaleString methods and these
1291    /// Strings are separated by a locale-specific String (such as a comma ",").
1292    ///
1293    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toLocaleString)
1294    #[cfg(js_sys_unstable_apis)]
1295    #[wasm_bindgen(method, js_name = toLocaleString)]
1296    pub fn to_locale_string<T>(
1297        this: &Array<T>,
1298        locales: &[JsString],
1299        options: &Intl::NumberFormatOptions,
1300    ) -> JsString;
1301
1302    /// The `toReversed()` method returns a new array with the elements in reversed order,
1303    /// without modifying the original array.
1304    ///
1305    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toReversed)
1306    #[wasm_bindgen(method, js_name = toReversed)]
1307    pub fn to_reversed<T>(this: &Array<T>) -> Array<T>;
1308
1309    /// The `toSorted()` method returns a new array with the elements sorted in ascending order,
1310    /// without modifying the original array.
1311    ///
1312    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toSorted)
1313    #[wasm_bindgen(method, js_name = toSorted)]
1314    pub fn to_sorted<T>(this: &Array<T>) -> Array<T>;
1315
1316    /// The `toSorted()` method with a custom compare function.
1317    ///
1318    /// **Note:** Consider using [`Array::try_to_sorted_by`] if the predicate might throw an error.
1319    ///
1320    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toSorted)
1321    #[wasm_bindgen(method, js_name = toSorted)]
1322    pub fn to_sorted_by<T>(this: &Array<T>, compare_fn: &mut dyn FnMut(T, T) -> i32) -> Array<T>;
1323
1324    /// The `toSorted()` method with a custom compare function. _(Fallible variation)_
1325    ///
1326    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toSorted)
1327    #[wasm_bindgen(method, js_name = toSorted, catch)]
1328    pub fn try_to_sorted_by<T>(
1329        this: &Array<T>,
1330        compare_fn: &mut dyn FnMut(T, T) -> Result<i32, JsError>,
1331    ) -> Result<Array<T>, JsValue>;
1332
1333    /// The `toSpliced()` method returns a new array with some elements removed and/or
1334    /// replaced at a given index, without modifying the original array.
1335    ///
1336    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toSpliced)
1337    #[wasm_bindgen(method, js_name = toSpliced, variadic)]
1338    pub fn to_spliced<T>(this: &Array<T>, start: u32, delete_count: u32, items: &[T]) -> Array<T>;
1339
1340    /// The `toString()` method returns a string representing the specified array
1341    /// and its elements.
1342    ///
1343    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toString)
1344    #[cfg(not(js_sys_unstable_apis))]
1345    #[wasm_bindgen(method, js_name = toString)]
1346    pub fn to_string<T>(this: &Array<T>) -> JsString;
1347
1348    /// Converts the Array into a Vector.
1349    #[wasm_bindgen(method, js_name = slice)]
1350    pub fn to_vec<T>(this: &Array<T>) -> Vec<T>;
1351
1352    /// The `unshift()` method adds one element to the beginning of an
1353    /// array and returns the new length of the array.
1354    ///
1355    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/unshift)
1356    #[wasm_bindgen(method)]
1357    pub fn unshift<T>(this: &Array<T>, value: &T) -> u32;
1358
1359    /// The `unshift()` method adds one or more elements to the beginning of an
1360    /// array and returns the new length of the array.
1361    ///
1362    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/unshift)
1363    #[wasm_bindgen(method, js_name = unshift, variadic)]
1364    pub fn unshift_many<T>(this: &Array<T>, values: &[T]) -> u32;
1365
1366    /// The `with()` method returns a new array with the element at the given index
1367    /// replaced with the given value, without modifying the original array.
1368    ///
1369    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/with)
1370    #[wasm_bindgen(method, js_name = with)]
1371    pub fn with<T>(this: &Array<T>, index: u32, value: &T) -> Array<T>;
1372}
1373
1374// Tuples as a typed array variant
1375#[wasm_bindgen]
1376extern "C" {
1377    #[wasm_bindgen(extends = Object, js_name = Array, is_type_of = Array::is_array, no_upcast, typescript_type = "Array<any>")]
1378    #[derive(Clone, Debug)]
1379    pub type ArrayTuple<T: JsTuple = (JsValue,)>;
1380
1381    /// Creates a new JS array typed as a 1-tuple.
1382    #[wasm_bindgen(js_class = Array, static_method_of = ArrayTuple, js_name = of)]
1383    pub fn new1<T1>(t1: &T1) -> ArrayTuple<(T1,)>;
1384
1385    /// Creates a new JS array typed as a 2-tuple.
1386    #[wasm_bindgen(js_class = Array, static_method_of = ArrayTuple, js_name = of)]
1387    pub fn new2<T1, T2>(t1: &T1, t2: &T2) -> ArrayTuple<(T1, T2)>;
1388
1389    /// Creates a new JS array typed as a 3-tuple.
1390    #[wasm_bindgen(js_class = Array, static_method_of = ArrayTuple, js_name = of)]
1391    pub fn new3<T1, T2, T3>(t1: &T1, t2: &T2, t3: &T3) -> ArrayTuple<(T1, T2, T3)>;
1392
1393    /// Creates a new JS array typed as a 4-tuple.
1394    #[wasm_bindgen(js_class = Array, static_method_of = ArrayTuple, js_name = of)]
1395    pub fn new4<T1, T2, T3, T4>(t1: &T1, t2: &T2, t3: &T3, t4: &T4)
1396        -> ArrayTuple<(T1, T2, T3, T4)>;
1397
1398    /// Creates a new JS array typed as a 5-tuple.
1399    #[wasm_bindgen(js_class = Array, static_method_of = ArrayTuple, js_name = of)]
1400    pub fn new5<T1, T2, T3, T4, T5>(
1401        t1: &T1,
1402        t2: &T2,
1403        t3: &T3,
1404        t4: &T4,
1405        t5: &T5,
1406    ) -> ArrayTuple<(T1, T2, T3, T4, T5)>;
1407
1408    /// Creates a new JS array typed as a 6-tuple.
1409    #[wasm_bindgen(js_class = Array, static_method_of = ArrayTuple, js_name = of)]
1410    pub fn new6<T1, T2, T3, T4, T5, T6>(
1411        t1: &T1,
1412        t2: &T2,
1413        t3: &T3,
1414        t4: &T4,
1415        t5: &T5,
1416        t6: &T6,
1417    ) -> ArrayTuple<(T1, T2, T3, T4, T5, T6)>;
1418
1419    /// Creates a new JS array typed as a 7-tuple.
1420    #[wasm_bindgen(js_class = Array, static_method_of = ArrayTuple, js_name = of)]
1421    pub fn new7<T1, T2, T3, T4, T5, T6, T7>(
1422        t1: &T1,
1423        t2: &T2,
1424        t3: &T3,
1425        t4: &T4,
1426        t5: &T5,
1427        t6: &T6,
1428        t7: &T7,
1429    ) -> ArrayTuple<(T1, T2, T3, T4, T5, T6, T7)>;
1430
1431    /// Creates a new JS array typed as a 8-tuple.
1432    #[wasm_bindgen(js_class = Array, static_method_of = ArrayTuple, js_name = of)]
1433    pub fn new8<T1, T2, T3, T4, T5, T6, T7, T8>(
1434        t1: &T1,
1435        t2: &T2,
1436        t3: &T3,
1437        t4: &T4,
1438        t5: &T5,
1439        t6: &T6,
1440        t7: &T7,
1441        t8: &T8,
1442    ) -> ArrayTuple<(T1, T2, T3, T4, T5, T6, T7, T8)>;
1443
1444    /// Gets the 1st item
1445    #[wasm_bindgen(
1446        method,
1447        js_class = Array,
1448        getter,
1449        js_name = "0"
1450    )]
1451    pub fn get0<T: JsTuple1 = (JsValue,)>(this: &ArrayTuple<T>) -> <T as JsTuple1>::T1;
1452
1453    /// Gets the 2nd item
1454    #[wasm_bindgen(
1455        method,
1456        js_class = Array,
1457        getter,
1458        js_name = "1"
1459    )]
1460    pub fn get1<T: JsTuple2 = (JsValue, JsValue)>(this: &ArrayTuple<T>) -> <T as JsTuple2>::T2;
1461
1462    /// Gets the 3rd item
1463    #[wasm_bindgen(
1464        method,
1465        js_class = Array,
1466        getter,
1467        js_name = "2"
1468    )]
1469    pub fn get2<T: JsTuple3 = (JsValue, JsValue, JsValue)>(
1470        this: &ArrayTuple<T>,
1471    ) -> <T as JsTuple3>::T3;
1472
1473    /// Gets the 4th item
1474    #[wasm_bindgen(
1475        method,
1476        js_class = Array,
1477        getter,
1478        js_name = "3"
1479    )]
1480    pub fn get3<T: JsTuple4 = (JsValue, JsValue, JsValue, JsValue)>(
1481        this: &ArrayTuple<T>,
1482    ) -> <T as JsTuple4>::T4;
1483
1484    /// Gets the 5th item
1485    #[wasm_bindgen(
1486        method,
1487        js_class = Array,
1488        getter,
1489        js_name = "4"
1490    )]
1491    pub fn get4<T: JsTuple5 = (JsValue, JsValue, JsValue, JsValue, JsValue)>(
1492        this: &ArrayTuple<T>,
1493    ) -> <T as JsTuple5>::T5;
1494
1495    /// Gets the 6th item
1496    #[wasm_bindgen(
1497        method,
1498        js_class = Array,
1499        getter,
1500        js_name = "5"
1501    )]
1502    pub fn get5<T: JsTuple6 = (JsValue, JsValue, JsValue, JsValue, JsValue, JsValue)>(
1503        this: &ArrayTuple<T>,
1504    ) -> <T as JsTuple6>::T6;
1505
1506    /// Gets the 7th item
1507    #[wasm_bindgen(
1508        method,
1509        js_class = Array,
1510        getter,
1511        js_name = "6"
1512    )]
1513    pub fn get6<
1514        T: JsTuple7 = (
1515            JsValue,
1516            JsValue,
1517            JsValue,
1518            JsValue,
1519            JsValue,
1520            JsValue,
1521            JsValue,
1522        ),
1523    >(
1524        this: &ArrayTuple<T>,
1525    ) -> <T as JsTuple7>::T7;
1526
1527    /// Gets the 8th item
1528    #[wasm_bindgen(
1529        method,
1530        js_class = Array,
1531        getter,
1532        js_name = "7"
1533    )]
1534    pub fn get7<
1535        T: JsTuple8 = (
1536            JsValue,
1537            JsValue,
1538            JsValue,
1539            JsValue,
1540            JsValue,
1541            JsValue,
1542            JsValue,
1543            JsValue,
1544        ),
1545    >(
1546        this: &ArrayTuple<T>,
1547    ) -> <T as JsTuple8>::T8;
1548
1549    /// Sets the 1st item
1550    #[wasm_bindgen(
1551        method,
1552        js_class = Array,
1553        setter,
1554        js_name = "0"
1555    )]
1556    pub fn set0<T: JsTuple1 = (JsValue,)>(this: &ArrayTuple<T>, value: &<T as JsTuple1>::T1);
1557
1558    /// Sets the 2nd item
1559    #[wasm_bindgen(
1560        method,
1561        js_class = Array,
1562        setter,
1563        js_name = "1"
1564    )]
1565    pub fn set1<T: JsTuple2 = (JsValue, JsValue)>(
1566        this: &ArrayTuple<T>,
1567        value: &<T as JsTuple2>::T2,
1568    );
1569
1570    /// Sets the 3rd item
1571    #[wasm_bindgen(
1572        method,
1573        js_class = Array,
1574        setter,
1575        js_name = "2"
1576    )]
1577    pub fn set2<T: JsTuple3 = (JsValue, JsValue, JsValue)>(
1578        this: &ArrayTuple<T>,
1579        value: &<T as JsTuple3>::T3,
1580    );
1581
1582    /// Sets the 4th item
1583    #[wasm_bindgen(
1584        method,
1585        js_class = Array,
1586        setter,
1587        js_name = "3"
1588    )]
1589    pub fn set3<T: JsTuple4 = (JsValue, JsValue, JsValue, JsValue)>(
1590        this: &ArrayTuple<T>,
1591        value: &<T as JsTuple4>::T4,
1592    );
1593
1594    /// Sets the 5th item
1595    #[wasm_bindgen(
1596        method,
1597        js_class = Array,
1598        setter,
1599        js_name = "4"
1600    )]
1601    pub fn set4<T: JsTuple5 = (JsValue, JsValue, JsValue, JsValue, JsValue)>(
1602        this: &ArrayTuple<T>,
1603        value: &<T as JsTuple5>::T5,
1604    );
1605
1606    /// Sets the 6th item
1607    #[wasm_bindgen(
1608        method,
1609        js_class = Array,
1610        setter,
1611        js_name = "5"
1612    )]
1613    pub fn set5<T: JsTuple6 = (JsValue, JsValue, JsValue, JsValue, JsValue, JsValue)>(
1614        this: &ArrayTuple<T>,
1615        value: &<T as JsTuple6>::T6,
1616    );
1617
1618    /// Sets the 7th item
1619    #[wasm_bindgen(
1620        method,
1621        js_class = Array,
1622        setter,
1623        js_name = "6"
1624    )]
1625    pub fn set6<
1626        T: JsTuple7 = (
1627            JsValue,
1628            JsValue,
1629            JsValue,
1630            JsValue,
1631            JsValue,
1632            JsValue,
1633            JsValue,
1634        ),
1635    >(
1636        this: &ArrayTuple<T>,
1637        value: &<T as JsTuple7>::T7,
1638    );
1639
1640    /// Sets the 8th item
1641    #[wasm_bindgen(
1642        method,
1643        js_class = Array,
1644        setter,
1645        js_name = "7"
1646    )]
1647    pub fn set7<
1648        T: JsTuple8 = (
1649            JsValue,
1650            JsValue,
1651            JsValue,
1652            JsValue,
1653            JsValue,
1654            JsValue,
1655            JsValue,
1656            JsValue,
1657        ),
1658    >(
1659        this: &ArrayTuple<T>,
1660        value: &<T as JsTuple8>::T8,
1661    );
1662}
1663
1664/// Base trait for tuple types.
1665pub trait JsTuple {
1666    const ARITY: usize;
1667}
1668
1669macro_rules! impl_tuple_traits {
1670    // Base case: first trait has no parent (besides JsTuple)
1671    ($name:ident $ty:tt) => {
1672        pub trait $name: JsTuple {
1673            type $ty;
1674        }
1675    };
1676
1677    // Recursive case: define trait with parent, then recurse
1678    ($name:ident $ty:tt $($rest_name:ident $rest_ty:tt)+) => {
1679        pub trait $name: JsTuple {
1680            type $ty;
1681        }
1682
1683        impl_tuple_traits!(@with_parent $name $($rest_name $rest_ty)+);
1684    };
1685
1686    // Internal: traits that have a parent
1687    (@with_parent $trait:ident $name:ident $ty:tt) => {
1688        pub trait $name: $trait {
1689            type $ty;
1690        }
1691    };
1692
1693    (@with_parent $trait:ident $name:ident $ty:tt $($rest_name:ident $rest_ty:tt)+) => {
1694        pub trait $name: $trait {
1695            type $ty;
1696        }
1697
1698        impl_tuple_traits!(@with_parent $name $($rest_name $rest_ty)+);
1699    };
1700}
1701
1702macro_rules! impl_parent_traits {
1703    ([$($types:tt),+] [] []) => {};
1704
1705    ([$($types:tt),+] [$trait:ident $($rest_traits:ident)*] [$ty:tt $($rest_tys:tt)*]) => {
1706        impl<$($types),+> $trait for ($($types),+,) {
1707            type $ty = $ty;
1708        }
1709
1710        impl_parent_traits!([$($types),+] [$($rest_traits)*] [$($rest_tys)*]);
1711    };
1712}
1713
1714// Define the trait hierarchy once
1715impl_tuple_traits!(
1716    JsTuple1 T1
1717    JsTuple2 T2
1718    JsTuple3 T3
1719    JsTuple4 T4
1720    JsTuple5 T5
1721    JsTuple6 T6
1722    JsTuple7 T7
1723    JsTuple8 T8
1724);
1725
1726impl<T: JsTuple> ArrayTuple<T> {
1727    /// Get the static arity of the ArrayTuple type.
1728    #[allow(clippy::len_without_is_empty)]
1729    pub fn len(&self) -> usize {
1730        <T as JsTuple>::ARITY
1731    }
1732}
1733
1734macro_rules! impl_tuple {
1735    ($arity:literal [$($traits:ident)*] [$($T:tt)+] [$($vars:tt)+] $new:ident $last:ident $last_ty:tt) => {
1736        impl<$($T),+> JsTuple for ($($T),+,) {
1737            const ARITY: usize = $arity;
1738        }
1739
1740        impl_parent_traits!([$($T),+] [$($traits)*] [$($T)*]);
1741
1742        impl<$($T: JsGeneric),+> From<($($T,)+)> for ArrayTuple<($($T),+,)> {
1743            fn from(($($vars,)+): ($($T,)+)) -> Self {
1744                $(let $vars: JsValue = $vars.upcast_into();)+
1745                Array::of(&[$($vars),+]).unchecked_into()
1746            }
1747        }
1748
1749        impl<$($T: JsGeneric + Default),+> Default for ArrayTuple<($($T),+,)> {
1750            fn default() -> Self {
1751                (
1752                    $($T::default(),)+
1753                ).into()
1754            }
1755        }
1756
1757        impl<$($T: JsGeneric),+> ArrayTuple<($($T),+,)> {
1758            /// Get the first element of the ArrayTuple
1759            pub fn first(&self) -> T1 {
1760                self.get0()
1761            }
1762
1763            /// Get the last element of the ArrayTuple
1764            pub fn last(&self) -> $last_ty {
1765                self.$last()
1766            }
1767
1768            /// Convert the ArrayTuple into its corresponding Rust tuple.
1769            pub fn into_tuple(self) -> ($($T,)+) {
1770                ($(self.$vars(),)+)
1771            }
1772
1773            /// Deprecated alias for [`ArrayTuple::into_tuple`].
1774            #[deprecated(note = "renamed to `into_tuple`")]
1775            pub fn into_parts(self) -> ($($T,)+) {
1776                self.into_tuple()
1777            }
1778
1779            /// Create a new ArrayTuple from the corresponding parts.
1780            ///
1781            /// # Example
1782            ///
1783            /// ```
1784            /// use js_sys::{ArrayTuple, JsString};
1785            ///
1786            /// let tuple = ArrayTuple::<JsString, JsString>::new(&"a".into(), &"b".into());
1787            /// ```
1788            ///
1789            /// Note: You must specify the T using `::<...>` syntax on `ArrayTuple`.
1790            /// Alternatively, use `new1`, `new2`, etc. for type inference from the left-hand side.
1791            pub fn new($($vars: &$T),+) -> ArrayTuple<($($T),+,)> {
1792                ArrayTuple::$new($($vars),+)
1793            }
1794        }
1795    };
1796}
1797
1798// Implement for each tuple size
1799impl_tuple!(1 [JsTuple1] [T1] [get0] new1 get0 T1);
1800impl_tuple!(2 [JsTuple1 JsTuple2] [T1 T2] [get0 get1] new2 get1 T2);
1801impl_tuple!(3 [JsTuple1 JsTuple2 JsTuple3] [T1 T2 T3] [get0 get1 get2] new3 get2 T3);
1802impl_tuple!(4 [JsTuple1 JsTuple2 JsTuple3 JsTuple4] [T1 T2 T3 T4] [get0 get1 get2 get3] new4 get3 T4);
1803impl_tuple!(5 [JsTuple1 JsTuple2 JsTuple3 JsTuple4 JsTuple5] [T1 T2 T3 T4 T5] [get0 get1 get2 get3 get4] new5 get4 T5);
1804impl_tuple!(6 [JsTuple1 JsTuple2 JsTuple3 JsTuple4 JsTuple5 JsTuple6] [T1 T2 T3 T4 T5 T6] [get0 get1 get2 get3 get4 get5] new6 get5 T6);
1805impl_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);
1806impl_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);
1807
1808// Macro to generate structural covariance impls for each arity
1809macro_rules! impl_tuple_covariance {
1810    ([$($T:ident)+] [$($Target:ident)+]) => {
1811        // ArrayTuple -> Array
1812        // Allows (T1, T2, ...) to be used where (Target) is expected
1813        // when all T1, T2, ... are covariant to Target
1814        impl<$($T,)+ Target> UpcastFrom<ArrayTuple<($($T,)+)>> for Array<Target>
1815        where
1816            $(Target: UpcastFrom<$T>,)+
1817        {
1818        }
1819        impl<$($T,)+ Target> UpcastFrom<ArrayTuple<($($T,)+)>> for JsOption<Array<Target>>
1820        where
1821            $(Target: UpcastFrom<$T>,)+
1822        {}
1823        impl<$($T,)+ Target> UpcastFrom<ArrayTuple<($($T,)+)>> for JsNullable<Array<Target>>
1824        where
1825            $(Target: UpcastFrom<$T>,)+
1826        {}
1827    };
1828}
1829
1830impl_tuple_covariance!([T1][Target1]);
1831impl_tuple_covariance!([T1 T2] [Target1 Target2]);
1832impl_tuple_covariance!([T1 T2 T3] [Target1 Target2 Target3]);
1833impl_tuple_covariance!([T1 T2 T3 T4] [Target1 Target2 Target3 Target4]);
1834impl_tuple_covariance!([T1 T2 T3 T4 T5] [Target1 Target2 Target3 Target4 Target5]);
1835impl_tuple_covariance!([T1 T2 T3 T4 T5 T6] [Target1 Target2 Target3 Target4 Target5 Target6]);
1836impl_tuple_covariance!([T1 T2 T3 T4 T5 T6 T7] [Target1 Target2 Target3 Target4 Target5 Target6 Target7]);
1837impl_tuple_covariance!([T1 T2 T3 T4 T5 T6 T7 T8] [Target1 Target2 Target3 Target4 Target5 Target6 Target7 Target8]);
1838
1839// Tuple casting is implemented in core
1840impl<T: JsTuple, U: JsTuple> UpcastFrom<ArrayTuple<T>> for ArrayTuple<U> where U: UpcastFrom<T> {}
1841impl<T: JsTuple> UpcastFrom<ArrayTuple<T>> for JsValue {}
1842impl<T: JsTuple> UpcastFrom<ArrayTuple<T>> for JsOption<JsValue> {}
1843impl<T: JsTuple> UpcastFrom<ArrayTuple<T>> for JsNullable<JsValue> {}
1844
1845/// Iterator returned by `Array::into_iter`
1846#[derive(Debug, Clone)]
1847pub struct ArrayIntoIter<T: JsGeneric = JsValue> {
1848    range: core::ops::Range<u32>,
1849    array: Array<T>,
1850}
1851
1852#[cfg(not(js_sys_unstable_apis))]
1853impl<T: JsGeneric> core::iter::Iterator for ArrayIntoIter<T> {
1854    type Item = T;
1855
1856    fn next(&mut self) -> Option<Self::Item> {
1857        let index = self.range.next()?;
1858        Some(self.array.get(index))
1859    }
1860
1861    #[inline]
1862    fn size_hint(&self) -> (usize, Option<usize>) {
1863        self.range.size_hint()
1864    }
1865
1866    #[inline]
1867    fn count(self) -> usize
1868    where
1869        Self: Sized,
1870    {
1871        self.range.count()
1872    }
1873
1874    #[inline]
1875    fn last(self) -> Option<Self::Item>
1876    where
1877        Self: Sized,
1878    {
1879        let Self { range, array } = self;
1880        range.last().map(|index| array.get(index))
1881    }
1882
1883    #[inline]
1884    fn nth(&mut self, n: usize) -> Option<Self::Item> {
1885        self.range.nth(n).map(|index| self.array.get(index))
1886    }
1887}
1888
1889#[cfg(js_sys_unstable_apis)]
1890impl<T: JsGeneric> core::iter::Iterator for ArrayIntoIter<T> {
1891    type Item = T;
1892
1893    fn next(&mut self) -> Option<Self::Item> {
1894        let index = self.range.next()?;
1895        self.array.get(index)
1896    }
1897
1898    #[inline]
1899    fn size_hint(&self) -> (usize, Option<usize>) {
1900        self.range.size_hint()
1901    }
1902
1903    #[inline]
1904    fn count(self) -> usize
1905    where
1906        Self: Sized,
1907    {
1908        self.range.count()
1909    }
1910
1911    #[inline]
1912    fn last(self) -> Option<Self::Item>
1913    where
1914        Self: Sized,
1915    {
1916        let Self { range, array } = self;
1917        range.last().and_then(|index| array.get(index))
1918    }
1919
1920    #[inline]
1921    fn nth(&mut self, n: usize) -> Option<Self::Item> {
1922        self.range.nth(n).and_then(|index| self.array.get(index))
1923    }
1924}
1925
1926#[cfg(not(js_sys_unstable_apis))]
1927impl<T: JsGeneric> core::iter::DoubleEndedIterator for ArrayIntoIter<T> {
1928    fn next_back(&mut self) -> Option<Self::Item> {
1929        let index = self.range.next_back()?;
1930        Some(self.array.get(index))
1931    }
1932
1933    fn nth_back(&mut self, n: usize) -> Option<Self::Item> {
1934        self.range.nth_back(n).map(|index| self.array.get(index))
1935    }
1936}
1937
1938#[cfg(js_sys_unstable_apis)]
1939impl<T: JsGeneric> core::iter::DoubleEndedIterator for ArrayIntoIter<T> {
1940    fn next_back(&mut self) -> Option<Self::Item> {
1941        let index = self.range.next_back()?;
1942        self.array.get(index)
1943    }
1944
1945    fn nth_back(&mut self, n: usize) -> Option<Self::Item> {
1946        self.range
1947            .nth_back(n)
1948            .and_then(|index| self.array.get(index))
1949    }
1950}
1951
1952impl<T: JsGeneric> core::iter::FusedIterator for ArrayIntoIter<T> {}
1953
1954impl<T: JsGeneric> core::iter::ExactSizeIterator for ArrayIntoIter<T> {}
1955
1956/// Iterator returned by `Array::iter`
1957#[derive(Debug, Clone)]
1958pub struct ArrayIter<'a, T: JsGeneric = JsValue> {
1959    range: core::ops::Range<u32>,
1960    array: &'a Array<T>,
1961}
1962
1963impl<T: JsGeneric> core::iter::Iterator for ArrayIter<'_, T> {
1964    type Item = T;
1965
1966    fn next(&mut self) -> Option<Self::Item> {
1967        let index = self.range.next()?;
1968        Some(self.array.get_unchecked(index))
1969    }
1970
1971    #[inline]
1972    fn size_hint(&self) -> (usize, Option<usize>) {
1973        self.range.size_hint()
1974    }
1975
1976    #[inline]
1977    fn count(self) -> usize
1978    where
1979        Self: Sized,
1980    {
1981        self.range.count()
1982    }
1983
1984    #[inline]
1985    fn last(self) -> Option<Self::Item>
1986    where
1987        Self: Sized,
1988    {
1989        let Self { range, array } = self;
1990        range.last().map(|index| array.get_unchecked(index))
1991    }
1992
1993    #[inline]
1994    fn nth(&mut self, n: usize) -> Option<Self::Item> {
1995        self.range
1996            .nth(n)
1997            .map(|index| self.array.get_unchecked(index))
1998    }
1999}
2000
2001impl<T: JsGeneric> core::iter::DoubleEndedIterator for ArrayIter<'_, T> {
2002    fn next_back(&mut self) -> Option<Self::Item> {
2003        let index = self.range.next_back()?;
2004        Some(self.array.get_unchecked(index))
2005    }
2006
2007    fn nth_back(&mut self, n: usize) -> Option<Self::Item> {
2008        self.range
2009            .nth_back(n)
2010            .map(|index| self.array.get_unchecked(index))
2011    }
2012}
2013
2014impl<T: JsGeneric> core::iter::FusedIterator for ArrayIter<'_, T> {}
2015
2016impl<T: JsGeneric> core::iter::ExactSizeIterator for ArrayIter<'_, T> {}
2017
2018impl<T: JsGeneric> Array<T> {
2019    /// Returns an iterator over the values of the JS array.
2020    pub fn iter(&self) -> ArrayIter<'_, T> {
2021        ArrayIter {
2022            range: 0..self.length(),
2023            array: self,
2024        }
2025    }
2026}
2027
2028impl<T: JsGeneric> core::iter::IntoIterator for Array<T> {
2029    type Item = T;
2030    type IntoIter = ArrayIntoIter<T>;
2031
2032    fn into_iter(self) -> Self::IntoIter {
2033        ArrayIntoIter {
2034            range: 0..self.length(),
2035            array: self,
2036        }
2037    }
2038}
2039
2040// `FromIterator` / `Extend` for `Array` (= `Array<JsValue>` via the default
2041// type parameter) preserve the long-standing stable behaviour: any iterator
2042// of items convertible to `&JsValue` collects into an erased `Array<JsValue>`.
2043//
2044// Typed collection (where the element type is inferred from the iterator
2045// item via [`IntoJsGeneric`]) is exposed as the inherent constructor
2046// [`Array::from_iter_typed`] rather than a second `FromIterator` impl. A
2047// blanket `impl<A: IntoJsGeneric> FromIterator<A> for Array<A::JsCanon>`
2048// would overlap with the stable `AsRef<JsValue>` impl on `Array<JsValue>`
2049// (since `JsValue: IntoJsGeneric` with `JsCanon = JsValue`), so the two
2050// cannot coexist as `FromIterator` impls without coherence violations.
2051//
2052// TODO(next major): deprecate this `FromIterator`/`Extend` pair in favour
2053// of a single `IntoJsGeneric`-based impl, and rename `from_iter_typed` to
2054// take its place. That migration is source-breaking for callers relying on
2055// `.collect::<Array>()` implicit erasure of typed items, so it is deferred.
2056
2057impl<A> core::iter::FromIterator<A> for Array
2058where
2059    A: AsRef<JsValue>,
2060{
2061    fn from_iter<I>(iter: I) -> Array
2062    where
2063        I: IntoIterator<Item = A>,
2064    {
2065        let mut out = Array::new();
2066        out.extend(iter);
2067        out
2068    }
2069}
2070
2071impl<A> core::iter::Extend<A> for Array
2072where
2073    A: AsRef<JsValue>,
2074{
2075    fn extend<I>(&mut self, iter: I)
2076    where
2077        I: IntoIterator<Item = A>,
2078    {
2079        for value in iter {
2080            self.push(value.as_ref());
2081        }
2082    }
2083}
2084
2085impl<T: JsGeneric> Array<T> {
2086    /// Collect an iterator into a typed `Array<T>`, projecting each item
2087    /// through its canonical [`JsGeneric`] via [`IntoJsGeneric`].
2088    ///
2089    /// This is the typed counterpart to the stable
2090    /// `impl FromIterator<A> for Array where A: AsRef<JsValue>`, which always
2091    /// produces an erased `Array<JsValue>`. Use `from_iter_typed` when you
2092    /// want the element type inferred from the iterator item:
2093    ///
2094    /// ```ignore
2095    /// use js_sys::{Array, Number};
2096    ///
2097    /// let arr = Array::from_iter_typed((0..10).map(Number::from));
2098    /// // arr: Array<Number>
2099    /// ```
2100    ///
2101    /// Reference iteration (`Item = &U`) is supported transparently via the
2102    /// `&U: IntoJsGeneric` blanket in `wasm-bindgen` core.
2103    //
2104    // TODO(next major): replace the stable `FromIterator` impl above with
2105    // this behaviour and remove `from_iter_typed`.
2106    pub fn from_iter_typed<A, I>(iter: I) -> Array<T>
2107    where
2108        A: IntoJsGeneric<JsCanon = T>,
2109        I: IntoIterator<Item = A>,
2110    {
2111        let mut out = Array::<T>::new_typed();
2112        out.extend_typed(iter);
2113        out
2114    }
2115
2116    /// Extend a typed `Array<T>` with an iterator of items convertible to
2117    /// `T` via [`IntoJsGeneric`]. Companion to [`Array::from_iter_typed`].
2118    //
2119    // TODO(next major): replace the stable `Extend` impl above with this
2120    // behaviour and remove `extend_typed`.
2121    pub fn extend_typed<A, I>(&mut self, iter: I)
2122    where
2123        A: IntoJsGeneric<JsCanon = T>,
2124        I: IntoIterator<Item = A>,
2125    {
2126        for value in iter {
2127            self.push(&value.to_js());
2128        }
2129    }
2130}
2131
2132impl Default for Array<JsValue> {
2133    fn default() -> Self {
2134        Self::new()
2135    }
2136}
2137
2138impl<T> Iterable for Array<T> {
2139    type Item = T;
2140}
2141
2142impl<T: JsTuple> Iterable for ArrayTuple<T> {
2143    type Item = JsValue;
2144}
2145
2146// ArrayBufferOptions
2147#[wasm_bindgen]
2148extern "C" {
2149    #[wasm_bindgen(extends = Object, typescript_type = "ArrayBufferOptions")]
2150    #[derive(Clone, Debug, PartialEq, Eq)]
2151    pub type ArrayBufferOptions;
2152
2153    /// The maximum size, in bytes, that the array buffer can be resized to.
2154    #[wasm_bindgen(method, setter, js_name = maxByteLength)]
2155    pub fn set_max_byte_length(this: &ArrayBufferOptions, max_byte_length: usize);
2156
2157    /// The maximum size, in bytes, that the array buffer can be resized to.
2158    #[wasm_bindgen(method, getter, js_name = maxByteLength)]
2159    pub fn get_max_byte_length(this: &ArrayBufferOptions) -> usize;
2160}
2161
2162impl ArrayBufferOptions {
2163    #[cfg(not(js_sys_unstable_apis))]
2164    pub fn new(max_byte_length: usize) -> ArrayBufferOptions {
2165        let options = JsCast::unchecked_into::<ArrayBufferOptions>(Object::new());
2166        options.set_max_byte_length(max_byte_length);
2167        options
2168    }
2169
2170    #[cfg(js_sys_unstable_apis)]
2171    pub fn new(max_byte_length: usize) -> ArrayBufferOptions {
2172        let options = JsCast::unchecked_into::<ArrayBufferOptions>(Object::<JsValue>::new());
2173        options.set_max_byte_length(max_byte_length);
2174        options
2175    }
2176}
2177
2178// ArrayBuffer
2179#[wasm_bindgen]
2180extern "C" {
2181    #[wasm_bindgen(extends = Object, typescript_type = "ArrayBuffer")]
2182    #[derive(Clone, Debug, PartialEq, Eq)]
2183    pub type ArrayBuffer;
2184
2185    /// The `ArrayBuffer` object is used to represent a generic,
2186    /// fixed-length raw binary data buffer. You cannot directly
2187    /// manipulate the contents of an `ArrayBuffer`; instead, you
2188    /// create one of the typed array objects or a `DataView` object
2189    /// which represents the buffer in a specific format, and use that
2190    /// to read and write the contents of the buffer.
2191    ///
2192    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer)
2193    #[cfg(not(js_sys_unstable_apis))]
2194    #[wasm_bindgen(constructor)]
2195    pub fn new(length: u32) -> ArrayBuffer;
2196
2197    /// The `ArrayBuffer` object is used to represent a generic,
2198    /// fixed-length raw binary data buffer. You cannot directly
2199    /// manipulate the contents of an `ArrayBuffer`; instead, you
2200    /// create one of the typed array objects or a `DataView` object
2201    /// which represents the buffer in a specific format, and use that
2202    /// to read and write the contents of the buffer.
2203    ///
2204    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer)
2205    #[cfg(js_sys_unstable_apis)]
2206    #[wasm_bindgen(constructor)]
2207    pub fn new(length: usize) -> ArrayBuffer;
2208
2209    /// The `ArrayBuffer` object is used to represent a generic,
2210    /// fixed-length raw binary data buffer. You cannot directly
2211    /// manipulate the contents of an `ArrayBuffer`; instead, you
2212    /// create one of the typed array objects or a `DataView` object
2213    /// which represents the buffer in a specific format, and use that
2214    /// to read and write the contents of the buffer.
2215    ///
2216    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer)
2217    #[wasm_bindgen(constructor)]
2218    pub fn new_with_options(length: usize, options: &ArrayBufferOptions) -> ArrayBuffer;
2219
2220    /// The `byteLength` property of an object which is an instance of type ArrayBuffer
2221    /// it's an accessor property whose set accessor function is undefined,
2222    /// meaning that you can only read this property.
2223    /// The value is established when the array is constructed and cannot be changed.
2224    /// This property returns 0 if this ArrayBuffer has been detached.
2225    ///
2226    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/byteLength)
2227    #[cfg(not(js_sys_unstable_apis))]
2228    #[wasm_bindgen(method, getter, js_name = byteLength)]
2229    pub fn byte_length(this: &ArrayBuffer) -> u32;
2230
2231    /// The `byteLength` property of an object which is an instance of type ArrayBuffer
2232    /// it's an accessor property whose set accessor function is undefined,
2233    /// meaning that you can only read this property.
2234    /// The value is established when the array is constructed and cannot be changed.
2235    /// This property returns 0 if this ArrayBuffer has been detached.
2236    ///
2237    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/byteLength)
2238    #[cfg(js_sys_unstable_apis)]
2239    #[wasm_bindgen(method, getter, js_name = byteLength)]
2240    pub fn byte_length(this: &ArrayBuffer) -> usize;
2241
2242    /// The `detached` accessor property of `ArrayBuffer` instances returns a boolean indicating
2243    /// whether or not this buffer has been detached (transferred).
2244    ///
2245    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/detached)
2246    #[wasm_bindgen(method, getter)]
2247    pub fn detached(this: &ArrayBuffer) -> bool;
2248
2249    /// The `isView()` method returns true if arg is one of the `ArrayBuffer`
2250    /// views, such as typed array objects or a DataView; false otherwise.
2251    ///
2252    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/isView)
2253    #[wasm_bindgen(static_method_of = ArrayBuffer, js_name = isView)]
2254    pub fn is_view(value: &JsValue) -> bool;
2255
2256    /// The `maxByteLength` accessor property of ArrayBuffer instances returns the maximum
2257    /// length (in bytes) that this array buffer can be resized to.
2258    ///
2259    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/maxByteLength)
2260    #[wasm_bindgen(method, getter, js_name = maxByteLength)]
2261    pub fn max_byte_length(this: &ArrayBuffer) -> usize;
2262
2263    /// The `resizable` accessor property of `ArrayBuffer` instances returns whether this array buffer
2264    /// can be resized or not.
2265    ///
2266    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/resizable)
2267    #[wasm_bindgen(method, getter)]
2268    pub fn resizable(this: &ArrayBuffer) -> bool;
2269
2270    /// The `resize()` method of ArrayBuffer instances resizes the ArrayBuffer to the
2271    /// specified size, in bytes.
2272    ///
2273    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/resize)
2274    #[wasm_bindgen(method, catch)]
2275    pub fn resize(this: &ArrayBuffer, new_len: usize) -> Result<(), JsValue>;
2276
2277    /// The `slice()` method returns a new `ArrayBuffer` whose contents
2278    /// are a copy of this `ArrayBuffer`'s bytes from begin, inclusive,
2279    /// up to end, exclusive.
2280    ///
2281    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/slice)
2282    #[cfg(not(js_sys_unstable_apis))]
2283    #[wasm_bindgen(method)]
2284    pub fn slice(this: &ArrayBuffer, begin: u32) -> ArrayBuffer;
2285
2286    /// The `slice()` method returns a new `ArrayBuffer` whose contents
2287    /// are a copy of this `ArrayBuffer`'s bytes from begin, inclusive,
2288    /// up to end, exclusive. Negative indices count from the end.
2289    ///
2290    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/slice)
2291    #[cfg(js_sys_unstable_apis)]
2292    #[wasm_bindgen(method)]
2293    pub fn slice(this: &ArrayBuffer, begin: isize, end: isize) -> ArrayBuffer;
2294
2295    /// The `slice()` method returns a new `ArrayBuffer` whose contents
2296    /// are a copy of this `ArrayBuffer`'s bytes from begin, inclusive,
2297    /// up to end, exclusive.
2298    ///
2299    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/slice)
2300    #[cfg(not(js_sys_unstable_apis))]
2301    #[wasm_bindgen(method, js_name = slice)]
2302    pub fn slice_from(this: &ArrayBuffer, begin: isize) -> ArrayBuffer;
2303
2304    /// The `slice()` method returns a new `ArrayBuffer` whose contents
2305    /// are a copy of this `ArrayBuffer`'s bytes from begin to the end.
2306    /// Negative indices count from the end.
2307    ///
2308    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/slice)
2309    #[cfg(js_sys_unstable_apis)]
2310    #[wasm_bindgen(method, js_name = slice)]
2311    pub fn slice_from(this: &ArrayBuffer, begin: isize) -> ArrayBuffer;
2312
2313    // Next major: deprecate
2314    /// Like `slice()` but with the `end` argument.
2315    ///
2316    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/slice)
2317    #[wasm_bindgen(method, js_name = slice)]
2318    pub fn slice_with_end(this: &ArrayBuffer, begin: u32, end: u32) -> ArrayBuffer;
2319
2320    /// The `transfer()` method of ArrayBuffer instances creates a new `ArrayBuffer`
2321    /// with the same byte content as this buffer, then detaches this buffer.
2322    ///
2323    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/transfer)
2324    #[wasm_bindgen(method, catch)]
2325    pub fn transfer(this: &ArrayBuffer) -> Result<ArrayBuffer, JsValue>;
2326
2327    /// The `transfer()` method of `ArrayBuffer` instances creates a new `ArrayBuffer`
2328    /// with the same byte content as this buffer, then detaches this buffer.
2329    ///
2330    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/transfer)
2331    #[wasm_bindgen(method, catch, js_name = transfer)]
2332    pub fn transfer_with_length(
2333        this: &ArrayBuffer,
2334        new_byte_length: usize,
2335    ) -> Result<ArrayBuffer, JsValue>;
2336
2337    /// The `transferToFixedLength()` method of `ArrayBuffer` instances creates a new non-resizable
2338    /// ArrayBuffer with the same byte content as this buffer, then detaches this buffer.
2339    ///
2340    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/transferToFixedLength)
2341    #[wasm_bindgen(method, catch, js_name = transferToFixedLength)]
2342    pub fn transfer_to_fixed_length(this: &ArrayBuffer) -> Result<ArrayBuffer, JsValue>;
2343
2344    /// The `transferToFixedLength()` method of `ArrayBuffer` instances creates a new non-resizable
2345    /// `ArrayBuffer` with the same byte content as this buffer, then detaches this buffer.
2346    ///
2347    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/transferToFixedLength)
2348    #[wasm_bindgen(method, catch, js_name = transferToFixedLength)]
2349    pub fn transfer_to_fixed_length_with_length(
2350        this: &ArrayBuffer,
2351        new_byte_length: usize,
2352    ) -> Result<ArrayBuffer, JsValue>;
2353}
2354
2355impl UpcastFrom<&[u8]> for ArrayBuffer {}
2356
2357// SharedArrayBuffer
2358#[wasm_bindgen]
2359extern "C" {
2360    #[wasm_bindgen(extends = Object, typescript_type = "SharedArrayBuffer")]
2361    #[derive(Clone, Debug)]
2362    pub type SharedArrayBuffer;
2363
2364    /// The `SharedArrayBuffer` object is used to represent a generic,
2365    /// fixed-length raw binary data buffer, similar to the `ArrayBuffer`
2366    /// object, but in a way that they can be used to create views
2367    /// on shared memory. Unlike an `ArrayBuffer`, a `SharedArrayBuffer`
2368    /// cannot become detached.
2369    ///
2370    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer)
2371    #[cfg(not(js_sys_unstable_apis))]
2372    #[wasm_bindgen(constructor)]
2373    pub fn new(length: u32) -> SharedArrayBuffer;
2374
2375    /// The `SharedArrayBuffer` object is used to represent a generic,
2376    /// fixed-length raw binary data buffer, similar to the `ArrayBuffer`
2377    /// object, but in a way that they can be used to create views
2378    /// on shared memory. Unlike an `ArrayBuffer`, a `SharedArrayBuffer`
2379    /// cannot become detached.
2380    ///
2381    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer)
2382    #[cfg(js_sys_unstable_apis)]
2383    #[wasm_bindgen(constructor)]
2384    pub fn new(length: usize) -> SharedArrayBuffer;
2385
2386    /// The `SharedArrayBuffer` object is used to represent a generic,
2387    /// fixed-length raw binary data buffer, similar to the `ArrayBuffer`
2388    /// object, but in a way that they can be used to create views
2389    /// on shared memory. Unlike an `ArrayBuffer`, a `SharedArrayBuffer`
2390    /// cannot become detached.
2391    ///
2392    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer)
2393    #[wasm_bindgen(constructor)]
2394    pub fn new_with_options(length: usize, options: &ArrayBufferOptions) -> SharedArrayBuffer;
2395
2396    /// The `byteLength` accessor property represents the length of
2397    /// an `SharedArrayBuffer` in bytes. This is established when
2398    /// the `SharedArrayBuffer` is constructed and cannot be changed.
2399    ///
2400    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/byteLength)
2401    #[cfg(not(js_sys_unstable_apis))]
2402    #[wasm_bindgen(method, getter, js_name = byteLength)]
2403    pub fn byte_length(this: &SharedArrayBuffer) -> u32;
2404
2405    /// The `byteLength` accessor property represents the length of
2406    /// an `SharedArrayBuffer` in bytes. This is established when
2407    /// the `SharedArrayBuffer` is constructed and cannot be changed.
2408    ///
2409    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/byteLength)
2410    #[cfg(js_sys_unstable_apis)]
2411    #[wasm_bindgen(method, getter, js_name = byteLength)]
2412    pub fn byte_length(this: &SharedArrayBuffer) -> usize;
2413
2414    /// The `growable` accessor property of `SharedArrayBuffer` instances returns whether
2415    /// this `SharedArrayBuffer` can be grown or not.
2416    ///
2417    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/growable)
2418    #[wasm_bindgen(method, getter)]
2419    pub fn growable(this: &SharedArrayBuffer) -> bool;
2420
2421    /// The `grow()` method of `SharedArrayBuffer` instances grows the
2422    /// `SharedArrayBuffer` to the specified size, in bytes.
2423    ///
2424    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/grow)
2425    #[wasm_bindgen(method, catch)]
2426    pub fn grow(this: &SharedArrayBuffer, new_byte_length: usize) -> Result<(), JsValue>;
2427
2428    /// The `maxByteLength` accessor property of `SharedArrayBuffer` instances returns the maximum
2429    /// length (in bytes) that this `SharedArrayBuffer` can be resized to.
2430    ///
2431    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/maxByteLength)
2432    #[wasm_bindgen(method, getter, js_name = maxByteLength)]
2433    pub fn max_byte_length(this: &SharedArrayBuffer) -> usize;
2434
2435    /// The `slice()` method returns a new `SharedArrayBuffer` whose contents
2436    /// are a copy of this `SharedArrayBuffer`'s bytes from begin, inclusive,
2437    /// up to end, exclusive.
2438    ///
2439    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/slice)
2440    #[cfg(not(js_sys_unstable_apis))]
2441    #[wasm_bindgen(method)]
2442    pub fn slice(this: &SharedArrayBuffer, begin: u32) -> SharedArrayBuffer;
2443
2444    /// The `slice()` method returns a new `SharedArrayBuffer` whose contents
2445    /// are a copy of this `SharedArrayBuffer`'s bytes from begin, inclusive,
2446    /// up to end, exclusive. Negative indices count from the end.
2447    ///
2448    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/slice)
2449    #[cfg(js_sys_unstable_apis)]
2450    #[wasm_bindgen(method)]
2451    pub fn slice(this: &SharedArrayBuffer, begin: isize, end: isize) -> SharedArrayBuffer;
2452
2453    /// The `slice()` method returns a new `SharedArrayBuffer` whose contents
2454    /// are a copy of this `SharedArrayBuffer`'s bytes from begin, inclusive,
2455    /// up to end, exclusive.
2456    ///
2457    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/slice)
2458    #[cfg(not(js_sys_unstable_apis))]
2459    #[wasm_bindgen(method)]
2460    pub fn slice_from(this: &SharedArrayBuffer, begin: isize) -> SharedArrayBuffer;
2461
2462    /// The `slice()` method returns a new `SharedArrayBuffer` whose contents
2463    /// are a copy of this `SharedArrayBuffer`'s bytes from begin to end.
2464    /// Negative indices count from the end.
2465    ///
2466    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/slice)
2467    #[cfg(js_sys_unstable_apis)]
2468    #[wasm_bindgen(method)]
2469    pub fn slice_from(this: &SharedArrayBuffer, begin: isize) -> SharedArrayBuffer;
2470
2471    // Next major: deprecate
2472    /// Like `slice()` but with the `end` argument.
2473    ///
2474    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/slice)
2475    #[wasm_bindgen(method, js_name = slice)]
2476    pub fn slice_with_end(this: &SharedArrayBuffer, begin: u32, end: u32) -> SharedArrayBuffer;
2477}
2478
2479// Array Iterator
2480#[wasm_bindgen]
2481extern "C" {
2482    /// The `keys()` method returns a new Array Iterator object that contains the
2483    /// keys for each index in the array.
2484    ///
2485    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/keys)
2486    #[wasm_bindgen(method)]
2487    pub fn keys<T>(this: &Array<T>) -> Iterator<T>;
2488
2489    /// The `entries()` method returns a new Array Iterator object that contains
2490    /// the key/value pairs for each index in the array.
2491    ///
2492    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/entries)
2493    #[cfg(not(js_sys_unstable_apis))]
2494    #[wasm_bindgen(method)]
2495    #[deprecated(note = "recommended to use `Array::entries_typed` instead for typing")]
2496    #[allow(deprecated)]
2497    pub fn entries<T>(this: &Array<T>) -> Iterator<T>;
2498
2499    /// The `entries()` method returns a new Array Iterator object that contains
2500    /// the key/value pairs for each index in the array.
2501    ///
2502    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/entries)
2503    #[cfg(js_sys_unstable_apis)]
2504    #[wasm_bindgen(method)]
2505    pub fn entries<T: JsGeneric>(this: &Array<T>) -> Iterator<ArrayTuple<(Number, T)>>;
2506
2507    // Next major: deprecate
2508    /// The `entries()` method returns a new Array Iterator object that contains
2509    /// the key/value pairs for each index in the array.
2510    ///
2511    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/entries)
2512    #[wasm_bindgen(method, js_name = entries)]
2513    pub fn entries_typed<T: JsGeneric>(this: &Array<T>) -> Iterator<ArrayTuple<(Number, T)>>;
2514
2515    /// The `values()` method returns a new Array Iterator object that
2516    /// contains the values for each index in the array.
2517    ///
2518    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/values)
2519    #[wasm_bindgen(method)]
2520    pub fn values<T>(this: &Array<T>) -> Iterator<T>;
2521}
2522
2523// FIXME(next-major): rename this trait to `ArrayBufferView`. The DOM/WebIDL
2524// spec name `ArrayBufferView` covers both `DataView` and the typed-array
2525// types, which more accurately reflects the set of types that implement this
2526// trait. The `TypedArray` name is kept for now to avoid a breaking change.
2527pub trait TypedArray: JsGeneric {}
2528
2529impl TypedArray for DataView {}
2530
2531// Next major: use usize/isize for indices
2532/// The `Atomics` object provides atomic operations as static methods.
2533/// They are used with `SharedArrayBuffer` objects.
2534///
2535/// The Atomic operations are installed on an `Atomics` module. Unlike
2536/// the other global objects, `Atomics` is not a constructor. You cannot
2537/// use it with a new operator or invoke the `Atomics` object as a
2538/// function. All properties and methods of `Atomics` are static
2539/// (as is the case with the Math object, for example).
2540/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics)
2541#[allow(non_snake_case)]
2542pub mod Atomics {
2543    use super::*;
2544
2545    #[wasm_bindgen]
2546    extern "C" {
2547        /// The static `Atomics.add()` method adds a given value at a given
2548        /// position in the array and returns the old value at that position.
2549        /// This atomic operation guarantees that no other write happens
2550        /// until the modified value is written back.
2551        ///
2552        /// You should use `add_bigint` to operate on a `BigInt64Array` or a `BigUint64Array`.
2553        ///
2554        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/add)
2555        #[wasm_bindgen(js_namespace = Atomics, catch)]
2556        pub fn add<T: TypedArray = Int32Array>(
2557            typed_array: &T,
2558            index: u32,
2559            value: i32,
2560        ) -> Result<i32, JsValue>;
2561
2562        /// The static `Atomics.add()` method adds a given value at a given
2563        /// position in the array and returns the old value at that position.
2564        /// This atomic operation guarantees that no other write happens
2565        /// until the modified value is written back.
2566        ///
2567        /// This method is used to operate on a `BigInt64Array` or a `BigUint64Array`.
2568        ///
2569        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/add)
2570        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = add)]
2571        pub fn add_bigint<T: TypedArray = Int32Array>(
2572            typed_array: &T,
2573            index: u32,
2574            value: i64,
2575        ) -> Result<i64, JsValue>;
2576
2577        /// The static `Atomics.and()` method computes a bitwise AND with a given
2578        /// value at a given position in the array, and returns the old value
2579        /// at that position.
2580        /// This atomic operation guarantees that no other write happens
2581        /// until the modified value is written back.
2582        ///
2583        /// You should use `and_bigint` to operate on a `BigInt64Array` or a `BigUint64Array`.
2584        ///
2585        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/and)
2586        #[wasm_bindgen(js_namespace = Atomics, catch)]
2587        pub fn and<T: TypedArray = Int32Array>(
2588            typed_array: &T,
2589            index: u32,
2590            value: i32,
2591        ) -> Result<i32, JsValue>;
2592
2593        /// The static `Atomics.and()` method computes a bitwise AND with a given
2594        /// value at a given position in the array, and returns the old value
2595        /// at that position.
2596        /// This atomic operation guarantees that no other write happens
2597        /// until the modified value is written back.
2598        ///
2599        /// This method is used to operate on a `BigInt64Array` or a `BigUint64Array`.
2600        ///
2601        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/and)
2602        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = and)]
2603        pub fn and_bigint<T: TypedArray = Int32Array>(
2604            typed_array: &T,
2605            index: u32,
2606            value: i64,
2607        ) -> Result<i64, JsValue>;
2608
2609        /// The static `Atomics.compareExchange()` method exchanges a given
2610        /// replacement value at a given position in the array, if a given expected
2611        /// value equals the old value. It returns the old value at that position
2612        /// whether it was equal to the expected value or not.
2613        /// This atomic operation guarantees that no other write happens
2614        /// until the modified value is written back.
2615        ///
2616        /// You should use `compare_exchange_bigint` to operate on a `BigInt64Array` or a `BigUint64Array`.
2617        ///
2618        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/compareExchange)
2619        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = compareExchange)]
2620        pub fn compare_exchange<T: TypedArray = Int32Array>(
2621            typed_array: &T,
2622            index: u32,
2623            expected_value: i32,
2624            replacement_value: i32,
2625        ) -> Result<i32, JsValue>;
2626
2627        /// The static `Atomics.compareExchange()` method exchanges a given
2628        /// replacement value at a given position in the array, if a given expected
2629        /// value equals the old value. It returns the old value at that position
2630        /// whether it was equal to the expected value or not.
2631        /// This atomic operation guarantees that no other write happens
2632        /// until the modified value is written back.
2633        ///
2634        /// This method is used to operate on a `BigInt64Array` or a `BigUint64Array`.
2635        ///
2636        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/compareExchange)
2637        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = compareExchange)]
2638        pub fn compare_exchange_bigint<T: TypedArray = Int32Array>(
2639            typed_array: &T,
2640            index: u32,
2641            expected_value: i64,
2642            replacement_value: i64,
2643        ) -> Result<i64, JsValue>;
2644
2645        /// The static `Atomics.exchange()` method stores a given value at a given
2646        /// position in the array and returns the old value at that position.
2647        /// This atomic operation guarantees that no other write happens
2648        /// until the modified value is written back.
2649        ///
2650        /// You should use `exchange_bigint` to operate on a `BigInt64Array` or a `BigUint64Array`.
2651        ///
2652        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/exchange)
2653        #[wasm_bindgen(js_namespace = Atomics, catch)]
2654        pub fn exchange<T: TypedArray = Int32Array>(
2655            typed_array: &T,
2656            index: u32,
2657            value: i32,
2658        ) -> Result<i32, JsValue>;
2659
2660        /// The static `Atomics.exchange()` method stores a given value at a given
2661        /// position in the array and returns the old value at that position.
2662        /// This atomic operation guarantees that no other write happens
2663        /// until the modified value is written back.
2664        ///
2665        /// This method is used to operate on a `BigInt64Array` or a `BigUint64Array`.
2666        ///
2667        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/exchange)
2668        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = exchange)]
2669        pub fn exchange_bigint<T: TypedArray = Int32Array>(
2670            typed_array: &T,
2671            index: u32,
2672            value: i64,
2673        ) -> Result<i64, JsValue>;
2674
2675        /// The static `Atomics.isLockFree()` method is used to determine
2676        /// whether to use locks or atomic operations. It returns true,
2677        /// if the given size is one of the `BYTES_PER_ELEMENT` property
2678        /// of integer `TypedArray` types.
2679        ///
2680        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/isLockFree)
2681        #[wasm_bindgen(js_namespace = Atomics, js_name = isLockFree)]
2682        pub fn is_lock_free(size: u32) -> bool;
2683
2684        /// The static `Atomics.load()` method returns a value at a given
2685        /// position in the array.
2686        ///
2687        /// You should use `load_bigint` to operate on a `BigInt64Array` or a `BigUint64Array`.
2688        ///
2689        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/load)
2690        #[wasm_bindgen(js_namespace = Atomics, catch)]
2691        pub fn load<T: TypedArray = Int32Array>(
2692            typed_array: &T,
2693            index: u32,
2694        ) -> Result<i32, JsValue>;
2695
2696        /// The static `Atomics.load()` method returns a value at a given
2697        /// position in the array.
2698        ///
2699        /// This method is used to operate on a `BigInt64Array` or a `BigUint64Array`.
2700        ///
2701        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/load)
2702        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = load)]
2703        pub fn load_bigint<T: TypedArray = Int32Array>(
2704            typed_array: &T,
2705            index: i64,
2706        ) -> Result<i64, JsValue>;
2707
2708        /// The static `Atomics.notify()` method notifies up some agents that
2709        /// are sleeping in the wait queue.
2710        /// Note: This operation works with a shared `Int32Array` only.
2711        /// If `count` is not provided, notifies all the agents in the queue.
2712        ///
2713        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/notify)
2714        #[wasm_bindgen(js_namespace = Atomics, catch)]
2715        pub fn notify(typed_array: &Int32Array, index: u32) -> Result<u32, JsValue>;
2716
2717        /// The static `Atomics.notify()` method notifies up some agents that
2718        /// are sleeping in the wait queue.
2719        /// Note: This operation works with a shared `Int32Array` only.
2720        /// If `count` is not provided, notifies all the agents in the queue.
2721        ///
2722        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/notify)
2723        #[wasm_bindgen(js_namespace = Atomics, catch)]
2724        pub fn notify_bigint(typed_array: &BigInt64Array, index: u32) -> Result<u32, JsValue>;
2725
2726        /// Notifies up to `count` agents in the wait queue.
2727        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = notify)]
2728        pub fn notify_with_count(
2729            typed_array: &Int32Array,
2730            index: u32,
2731            count: u32,
2732        ) -> Result<u32, JsValue>;
2733
2734        /// Notifies up to `count` agents in the wait queue.
2735        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = notify)]
2736        pub fn notify_bigint_with_count(
2737            typed_array: &BigInt64Array,
2738            index: u32,
2739            count: u32,
2740        ) -> Result<u32, JsValue>;
2741
2742        /// The static `Atomics.or()` method computes a bitwise OR with a given value
2743        /// at a given position in the array, and returns the old value at that position.
2744        /// This atomic operation guarantees that no other write happens
2745        /// until the modified value is written back.
2746        ///
2747        /// You should use `or_bigint` to operate on a `BigInt64Array` or a `BigUint64Array`.
2748        ///
2749        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/or)
2750        #[wasm_bindgen(js_namespace = Atomics, catch)]
2751        pub fn or<T: TypedArray = Int32Array>(
2752            typed_array: &T,
2753            index: u32,
2754            value: i32,
2755        ) -> Result<i32, JsValue>;
2756
2757        /// The static `Atomics.or()` method computes a bitwise OR with a given value
2758        /// at a given position in the array, and returns the old value at that position.
2759        /// This atomic operation guarantees that no other write happens
2760        /// until the modified value is written back.
2761        ///
2762        /// This method is used to operate on a `BigInt64Array` or a `BigUint64Array`.
2763        ///
2764        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/or)
2765        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = or)]
2766        pub fn or_bigint<T: TypedArray = Int32Array>(
2767            typed_array: &T,
2768            index: u32,
2769            value: i64,
2770        ) -> Result<i64, JsValue>;
2771
2772        /// The static `Atomics.pause()` static method provides a micro-wait primitive that hints to the CPU
2773        /// that the caller is spinning while waiting on access to a shared resource. This allows the system
2774        /// to reduce the resources allocated to the core (such as power) or thread, without yielding the
2775        /// current thread.
2776        ///
2777        /// `pause()` has no observable behavior other than timing. The exact behavior is dependent on the CPU
2778        /// architecture and the operating system. For example, in Intel x86, it may be a pause instruction as
2779        /// per Intel's optimization manual. It could be a no-op in certain platforms.
2780        ///
2781        /// This method is used to operate on a `BigInt64Array` or a `BigUint64Array`.
2782        ///
2783        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/xor)
2784        #[wasm_bindgen(js_namespace = Atomics)]
2785        pub fn pause();
2786
2787        /// The static `Atomics.pause()` static method provides a micro-wait primitive that hints to the CPU
2788        /// that the caller is spinning while waiting on access to a shared resource. This allows the system
2789        /// to reduce the resources allocated to the core (such as power) or thread, without yielding the
2790        /// current thread.
2791        ///
2792        /// `pause()` has no observable behavior other than timing. The exact behavior is dependent on the CPU
2793        /// architecture and the operating system. For example, in Intel x86, it may be a pause instruction as
2794        /// per Intel's optimization manual. It could be a no-op in certain platforms.
2795        ///
2796        /// This method is used to operate on a `BigInt64Array` or a `BigUint64Array`.
2797        ///
2798        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/xor)
2799        #[wasm_bindgen(js_namespace = Atomics)]
2800        pub fn pause_with_hint(duration_hint: u32);
2801
2802        /// The static `Atomics.store()` method stores a given value at the given
2803        /// position in the array and returns that value.
2804        ///
2805        /// You should use `store_bigint` to operate on a `BigInt64Array` or a `BigUint64Array`.
2806        ///
2807        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/store)
2808        #[wasm_bindgen(js_namespace = Atomics, catch)]
2809        pub fn store<T: TypedArray = Int32Array>(
2810            typed_array: &T,
2811            index: u32,
2812            value: i32,
2813        ) -> Result<i32, JsValue>;
2814
2815        /// The static `Atomics.store()` method stores a given value at the given
2816        /// position in the array and returns that value.
2817        ///
2818        /// This method is used to operate on a `BigInt64Array` or a `BigUint64Array`.
2819        ///
2820        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/store)
2821        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = store)]
2822        pub fn store_bigint<T: TypedArray = Int32Array>(
2823            typed_array: &T,
2824            index: u32,
2825            value: i64,
2826        ) -> Result<i64, JsValue>;
2827
2828        /// The static `Atomics.sub()` method subtracts a given value at a
2829        /// given position in the array and returns the old value at that position.
2830        /// This atomic operation guarantees that no other write happens
2831        /// until the modified value is written back.
2832        ///
2833        /// You should use `sub_bigint` to operate on a `BigInt64Array` or a `BigUint64Array`.
2834        ///
2835        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/sub)
2836        #[wasm_bindgen(js_namespace = Atomics, catch)]
2837        pub fn sub<T: TypedArray = Int32Array>(
2838            typed_array: &T,
2839            index: u32,
2840            value: i32,
2841        ) -> Result<i32, JsValue>;
2842
2843        /// The static `Atomics.sub()` method subtracts a given value at a
2844        /// given position in the array and returns the old value at that position.
2845        /// This atomic operation guarantees that no other write happens
2846        /// until the modified value is written back.
2847        ///
2848        /// This method is used to operate on a `BigInt64Array` or a `BigUint64Array`.
2849        ///
2850        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/sub)
2851        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = sub)]
2852        pub fn sub_bigint<T: TypedArray = Int32Array>(
2853            typed_array: &T,
2854            index: u32,
2855            value: i64,
2856        ) -> Result<i64, JsValue>;
2857
2858        /// The static `Atomics.wait()` method verifies that a given
2859        /// position in an `Int32Array` still contains a given value
2860        /// and if so sleeps, awaiting a wakeup or a timeout.
2861        /// It returns a string which is either "ok", "not-equal", or "timed-out".
2862        /// Note: This operation only works with a shared `Int32Array`
2863        /// and may not be allowed on the main thread.
2864        ///
2865        /// You should use `wait_bigint` to operate on a `BigInt64Array`.
2866        ///
2867        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/wait)
2868        #[wasm_bindgen(js_namespace = Atomics, catch)]
2869        pub fn wait(typed_array: &Int32Array, index: u32, value: i32) -> Result<JsString, JsValue>;
2870
2871        /// The static `Atomics.wait()` method verifies that a given
2872        /// position in an `BigInt64Array` still contains a given value
2873        /// and if so sleeps, awaiting a wakeup or a timeout.
2874        /// It returns a string which is either "ok", "not-equal", or "timed-out".
2875        /// Note: This operation only works with a shared `BigInt64Array`
2876        /// and may not be allowed on the main thread.
2877        ///
2878        /// You should use `wait` to operate on a `Int32Array`.
2879        ///
2880        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/wait)
2881        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = wait)]
2882        pub fn wait_bigint(
2883            typed_array: &BigInt64Array,
2884            index: u32,
2885            value: i64,
2886        ) -> Result<JsString, JsValue>;
2887
2888        /// Like `wait()`, but with timeout
2889        ///
2890        /// You should use `wait_with_timeout_bigint` to operate on a `BigInt64Array`.
2891        ///
2892        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/wait)
2893        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = wait)]
2894        pub fn wait_with_timeout(
2895            typed_array: &Int32Array,
2896            index: u32,
2897            value: i32,
2898            timeout: f64,
2899        ) -> Result<JsString, JsValue>;
2900
2901        /// Like `wait()`, but with timeout
2902        ///
2903        /// You should use `wait_with_timeout` to operate on a `Int32Array`.
2904        ///
2905        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/wait)
2906        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = wait)]
2907        pub fn wait_with_timeout_bigint(
2908            typed_array: &BigInt64Array,
2909            index: u32,
2910            value: i64,
2911            timeout: f64,
2912        ) -> Result<JsString, JsValue>;
2913
2914        /// The static `Atomics.waitAsync()` method verifies that a given position in an
2915        /// `Int32Array` still contains a given value and if so sleeps, awaiting a
2916        /// wakeup or a timeout. It returns an object with two properties. The first
2917        /// property `async` is a boolean which if true indicates that the second
2918        /// property `value` is a promise. If `async` is false then value is a string
2919        /// whether equal to either "not-equal" or "timed-out".
2920        /// Note: This operation only works with a shared `Int32Array` and may be used
2921        /// on the main thread.
2922        ///
2923        /// You should use `wait_async_bigint` to operate on a `BigInt64Array`.
2924        ///
2925        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/waitAsync)
2926        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = waitAsync)]
2927        pub fn wait_async(
2928            typed_array: &Int32Array,
2929            index: u32,
2930            value: i32,
2931        ) -> Result<Object, JsValue>;
2932
2933        /// The static `Atomics.waitAsync()` method verifies that a given position in an
2934        /// `Int32Array` still contains a given value and if so sleeps, awaiting a
2935        /// wakeup or a timeout. It returns an object with two properties. The first
2936        /// property `async` is a boolean which if true indicates that the second
2937        /// property `value` is a promise. If `async` is false then value is a string
2938        /// whether equal to either "not-equal" or "timed-out".
2939        /// Note: This operation only works with a shared `BigInt64Array` and may be used
2940        /// on the main thread.
2941        ///
2942        /// You should use `wait_async` to operate on a `Int32Array`.
2943        ///
2944        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/waitAsync)
2945        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = waitAsync)]
2946        pub fn wait_async_bigint(
2947            typed_array: &BigInt64Array,
2948            index: u32,
2949            value: i64,
2950        ) -> Result<Object, JsValue>;
2951
2952        /// Like `waitAsync()`, but with timeout
2953        ///
2954        /// You should use `wait_async_with_timeout_bigint` to operate on a `BigInt64Array`.
2955        ///
2956        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/waitAsync)
2957        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = waitAsync)]
2958        pub fn wait_async_with_timeout(
2959            typed_array: &Int32Array,
2960            index: u32,
2961            value: i32,
2962            timeout: f64,
2963        ) -> Result<Object, JsValue>;
2964
2965        /// Like `waitAsync()`, but with timeout
2966        ///
2967        /// You should use `wait_async_with_timeout` to operate on a `Int32Array`.
2968        ///
2969        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/waitAsync)
2970        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = waitAsync)]
2971        pub fn wait_async_with_timeout_bigint(
2972            typed_array: &BigInt64Array,
2973            index: u32,
2974            value: i64,
2975            timeout: f64,
2976        ) -> Result<Object, JsValue>;
2977
2978        /// The static `Atomics.xor()` method computes a bitwise XOR
2979        /// with a given value at a given position in the array,
2980        /// and returns the old value at that position.
2981        /// This atomic operation guarantees that no other write happens
2982        /// until the modified value is written back.
2983        ///
2984        /// You should use `xor_bigint` to operate on a `BigInt64Array` or a `BigUint64Array`.
2985        ///
2986        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/xor)
2987        #[wasm_bindgen(js_namespace = Atomics, catch)]
2988        pub fn xor<T: TypedArray = Int32Array>(
2989            typed_array: &T,
2990            index: u32,
2991            value: i32,
2992        ) -> Result<i32, JsValue>;
2993
2994        /// The static `Atomics.xor()` method computes a bitwise XOR
2995        /// with a given value at a given position in the array,
2996        /// and returns the old value at that position.
2997        /// This atomic operation guarantees that no other write happens
2998        /// until the modified value is written back.
2999        ///
3000        /// This method is used to operate on a `BigInt64Array` or a `BigUint64Array`.
3001        ///
3002        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/xor)
3003        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = xor)]
3004        pub fn xor_bigint<T: TypedArray = Int32Array>(
3005            typed_array: &T,
3006            index: u32,
3007            value: i64,
3008        ) -> Result<i64, JsValue>;
3009    }
3010}
3011
3012// BigInt
3013#[wasm_bindgen]
3014extern "C" {
3015    #[wasm_bindgen(extends = Object, is_type_of = |v| v.is_bigint(), typescript_type = "bigint")]
3016    #[derive(Clone, PartialEq, Eq)]
3017    pub type BigInt;
3018
3019    #[wasm_bindgen(catch, js_name = BigInt)]
3020    fn new_bigint(value: &JsValue) -> Result<BigInt, Error>;
3021
3022    #[wasm_bindgen(js_name = BigInt)]
3023    fn new_bigint_unchecked(value: &JsValue) -> BigInt;
3024
3025    /// Clamps a BigInt value to a signed integer value, and returns that value.
3026    ///
3027    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/asIntN)
3028    #[wasm_bindgen(static_method_of = BigInt, js_name = asIntN)]
3029    pub fn as_int_n(bits: f64, bigint: &BigInt) -> BigInt;
3030
3031    /// Clamps a BigInt value to an unsigned integer value, and returns that value.
3032    ///
3033    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/asUintN)
3034    #[wasm_bindgen(static_method_of = BigInt, js_name = asUintN)]
3035    pub fn as_uint_n(bits: f64, bigint: &BigInt) -> BigInt;
3036
3037    /// 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.
3038    ///
3039    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/toLocaleString)
3040    #[cfg(not(js_sys_unstable_apis))]
3041    #[wasm_bindgen(method, js_name = toLocaleString)]
3042    pub fn to_locale_string(this: &BigInt, locales: &JsValue, options: &JsValue) -> JsString;
3043
3044    /// 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.
3045    ///
3046    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/toLocaleString)
3047    #[cfg(js_sys_unstable_apis)]
3048    #[wasm_bindgen(method, js_name = toLocaleString)]
3049    pub fn to_locale_string(
3050        this: &BigInt,
3051        locales: &[JsString],
3052        options: &Intl::NumberFormatOptions,
3053    ) -> JsString;
3054
3055    // Next major: deprecate
3056    /// 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.
3057    ///
3058    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/toString)
3059    #[wasm_bindgen(catch, method, js_name = toString)]
3060    pub fn to_string(this: &BigInt, radix: u8) -> Result<JsString, RangeError>;
3061
3062    /// Returns a string representing this BigInt value in the specified radix (base).
3063    ///
3064    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/toString)
3065    #[cfg(js_sys_unstable_apis)]
3066    #[wasm_bindgen(catch, method, js_name = toString)]
3067    pub fn to_string_with_radix(this: &BigInt, radix: u8) -> Result<JsString, RangeError>;
3068
3069    #[wasm_bindgen(method, js_name = toString)]
3070    fn to_string_unchecked(this: &BigInt, radix: u8) -> String;
3071
3072    /// Returns this BigInt value. Overrides the [`Object.prototype.valueOf()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/valueOf) method.
3073    ///
3074    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/valueOf)
3075    #[wasm_bindgen(method, js_name = valueOf)]
3076    pub fn value_of(this: &BigInt, radix: u8) -> BigInt;
3077}
3078
3079impl BigInt {
3080    /// Creates a new BigInt value.
3081    ///
3082    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/BigInt)
3083    #[inline]
3084    pub fn new(value: &JsValue) -> Result<BigInt, Error> {
3085        new_bigint(value)
3086    }
3087
3088    /// Applies the binary `/` JS operator on two `BigInt`s, catching and returning any `RangeError` thrown.
3089    ///
3090    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Division)
3091    pub fn checked_div(&self, rhs: &Self) -> Result<Self, RangeError> {
3092        let result = JsValue::as_ref(self).checked_div(JsValue::as_ref(rhs));
3093
3094        if result.is_instance_of::<RangeError>() {
3095            Err(result.unchecked_into())
3096        } else {
3097            Ok(result.unchecked_into())
3098        }
3099    }
3100
3101    /// Applies the binary `**` JS operator on the two `BigInt`s.
3102    ///
3103    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Exponentiation)
3104    #[inline]
3105    pub fn pow(&self, rhs: &Self) -> Self {
3106        JsValue::as_ref(self)
3107            .pow(JsValue::as_ref(rhs))
3108            .unchecked_into()
3109    }
3110
3111    /// Returns a tuple of this [`BigInt`]'s absolute value along with a
3112    /// [`bool`] indicating whether the [`BigInt`] was negative.
3113    fn abs(&self) -> (Self, bool) {
3114        if self < &BigInt::from(0) {
3115            (-self, true)
3116        } else {
3117            (self.clone(), false)
3118        }
3119    }
3120}
3121
3122macro_rules! bigint_from {
3123    ($($x:ident)*) => ($(
3124        impl From<$x> for BigInt {
3125            #[inline]
3126            fn from(x: $x) -> BigInt {
3127                new_bigint_unchecked(&JsValue::from(x))
3128            }
3129        }
3130
3131        impl PartialEq<$x> for BigInt {
3132            #[inline]
3133            fn eq(&self, other: &$x) -> bool {
3134                JsValue::from(self) == JsValue::from(BigInt::from(*other))
3135            }
3136        }
3137    )*)
3138}
3139bigint_from!(i8 u8 i16 u16 i32 u32 isize usize);
3140
3141macro_rules! bigint_from_big {
3142    ($($x:ident)*) => ($(
3143        impl From<$x> for BigInt {
3144            #[inline]
3145            fn from(x: $x) -> BigInt {
3146                JsValue::from(x).unchecked_into()
3147            }
3148        }
3149
3150        impl PartialEq<$x> for BigInt {
3151            #[inline]
3152            fn eq(&self, other: &$x) -> bool {
3153                self == &BigInt::from(*other)
3154            }
3155        }
3156
3157        impl TryFrom<BigInt> for $x {
3158            type Error = BigInt;
3159
3160            #[inline]
3161            fn try_from(x: BigInt) -> Result<Self, BigInt> {
3162                Self::try_from(JsValue::from(x)).map_err(JsCast::unchecked_into)
3163            }
3164        }
3165    )*)
3166}
3167bigint_from_big!(i64 u64 i128 u128);
3168
3169impl PartialEq<Number> for BigInt {
3170    #[inline]
3171    fn eq(&self, other: &Number) -> bool {
3172        JsValue::as_ref(self).loose_eq(JsValue::as_ref(other))
3173    }
3174}
3175
3176impl Not for &BigInt {
3177    type Output = BigInt;
3178
3179    #[inline]
3180    fn not(self) -> Self::Output {
3181        JsValue::as_ref(self).bit_not().unchecked_into()
3182    }
3183}
3184
3185forward_deref_unop!(impl Not, not for BigInt);
3186forward_js_unop!(impl Neg, neg for BigInt);
3187forward_js_binop!(impl BitAnd, bitand for BigInt);
3188forward_js_binop!(impl BitOr, bitor for BigInt);
3189forward_js_binop!(impl BitXor, bitxor for BigInt);
3190forward_js_binop!(impl Shl, shl for BigInt);
3191forward_js_binop!(impl Shr, shr for BigInt);
3192forward_js_binop!(impl Add, add for BigInt);
3193forward_js_binop!(impl Sub, sub for BigInt);
3194forward_js_binop!(impl Div, div for BigInt);
3195forward_js_binop!(impl Mul, mul for BigInt);
3196forward_js_binop!(impl Rem, rem for BigInt);
3197sum_product!(BigInt);
3198
3199partialord_ord!(BigInt);
3200
3201impl Default for BigInt {
3202    fn default() -> Self {
3203        BigInt::from(i32::default())
3204    }
3205}
3206
3207impl FromStr for BigInt {
3208    type Err = Error;
3209
3210    #[inline]
3211    fn from_str(s: &str) -> Result<Self, Self::Err> {
3212        BigInt::new(&s.into())
3213    }
3214}
3215
3216impl fmt::Debug for BigInt {
3217    #[inline]
3218    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3219        fmt::Display::fmt(self, f)
3220    }
3221}
3222
3223impl fmt::Display for BigInt {
3224    #[inline]
3225    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3226        let (abs, is_neg) = self.abs();
3227        f.pad_integral(!is_neg, "", &abs.to_string_unchecked(10))
3228    }
3229}
3230
3231impl fmt::Binary for BigInt {
3232    #[inline]
3233    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3234        let (abs, is_neg) = self.abs();
3235        f.pad_integral(!is_neg, "0b", &abs.to_string_unchecked(2))
3236    }
3237}
3238
3239impl fmt::Octal for BigInt {
3240    #[inline]
3241    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3242        let (abs, is_neg) = self.abs();
3243        f.pad_integral(!is_neg, "0o", &abs.to_string_unchecked(8))
3244    }
3245}
3246
3247impl fmt::LowerHex for BigInt {
3248    #[inline]
3249    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3250        let (abs, is_neg) = self.abs();
3251        f.pad_integral(!is_neg, "0x", &abs.to_string_unchecked(16))
3252    }
3253}
3254
3255impl fmt::UpperHex for BigInt {
3256    #[inline]
3257    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3258        let (abs, is_neg) = self.abs();
3259        let mut s: String = abs.to_string_unchecked(16);
3260        s.make_ascii_uppercase();
3261        f.pad_integral(!is_neg, "0x", &s)
3262    }
3263}
3264
3265// Boolean
3266#[wasm_bindgen]
3267extern "C" {
3268    #[wasm_bindgen(extends = Object, is_type_of = |v| v.as_bool().is_some(), typescript_type = "boolean")]
3269    #[derive(Clone, PartialEq, Eq)]
3270    pub type Boolean;
3271
3272    /// The `Boolean()` constructor creates an object wrapper for a boolean value.
3273    ///
3274    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)
3275    #[cfg(not(js_sys_unstable_apis))]
3276    #[wasm_bindgen(constructor)]
3277    #[deprecated(note = "recommended to use `Boolean::from` instead")]
3278    #[allow(deprecated)]
3279    pub fn new(value: &JsValue) -> Boolean;
3280
3281    /// The `valueOf()` method returns the primitive value of a `Boolean` object.
3282    ///
3283    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean/valueOf)
3284    #[wasm_bindgen(method, js_name = valueOf)]
3285    pub fn value_of(this: &Boolean) -> bool;
3286}
3287
3288impl UpcastFrom<bool> for Boolean {}
3289impl UpcastFrom<Boolean> for bool {}
3290
3291impl Boolean {
3292    /// Typed Boolean true constant.
3293    pub const TRUE: Boolean = Self {
3294        obj: Object {
3295            obj: JsValue::TRUE,
3296            generics: PhantomData,
3297        },
3298    };
3299
3300    /// Typed Boolean false constant.
3301    pub const FALSE: Boolean = Self {
3302        obj: Object {
3303            obj: JsValue::FALSE,
3304            generics: PhantomData,
3305        },
3306    };
3307}
3308
3309impl From<bool> for Boolean {
3310    #[inline]
3311    fn from(b: bool) -> Boolean {
3312        Boolean::unchecked_from_js(JsValue::from(b))
3313    }
3314}
3315
3316impl From<Boolean> for bool {
3317    #[inline]
3318    fn from(b: Boolean) -> bool {
3319        b.value_of()
3320    }
3321}
3322
3323impl PartialEq<bool> for Boolean {
3324    #[inline]
3325    fn eq(&self, other: &bool) -> bool {
3326        self.value_of() == *other
3327    }
3328}
3329
3330impl fmt::Debug for Boolean {
3331    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
3332        fmt::Debug::fmt(&self.value_of(), f)
3333    }
3334}
3335
3336impl fmt::Display for Boolean {
3337    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
3338        fmt::Display::fmt(&self.value_of(), f)
3339    }
3340}
3341
3342impl Default for Boolean {
3343    fn default() -> Self {
3344        Self::from(bool::default())
3345    }
3346}
3347
3348impl Not for &Boolean {
3349    type Output = Boolean;
3350
3351    #[inline]
3352    fn not(self) -> Self::Output {
3353        (!JsValue::as_ref(self)).into()
3354    }
3355}
3356
3357forward_deref_unop!(impl Not, not for Boolean);
3358
3359partialord_ord!(Boolean);
3360
3361// DataView
3362#[wasm_bindgen]
3363extern "C" {
3364    #[wasm_bindgen(extends = Object, typescript_type = "DataView")]
3365    #[derive(Clone, Debug, PartialEq, Eq)]
3366    pub type DataView;
3367
3368    /// The `DataView` view provides a low-level interface for reading and
3369    /// writing multiple number types in an `ArrayBuffer` irrespective of the
3370    /// platform's endianness.
3371    ///
3372    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView)
3373    #[wasm_bindgen(constructor)]
3374    pub fn new(buffer: &ArrayBuffer, byteOffset: usize, byteLength: usize) -> DataView;
3375
3376    /// The `DataView` view provides a low-level interface for reading and
3377    /// writing multiple number types in an `ArrayBuffer` irrespective of the
3378    /// platform's endianness.
3379    ///
3380    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView)
3381    #[wasm_bindgen(constructor)]
3382    pub fn new_with_shared_array_buffer(
3383        buffer: &SharedArrayBuffer,
3384        byteOffset: usize,
3385        byteLength: usize,
3386    ) -> DataView;
3387
3388    /// The ArrayBuffer referenced by this view. Fixed at construction time and thus read only.
3389    ///
3390    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/buffer)
3391    #[wasm_bindgen(method, getter)]
3392    pub fn buffer(this: &DataView) -> ArrayBuffer;
3393
3394    /// The length (in bytes) of this view from the start of its ArrayBuffer.
3395    /// Fixed at construction time and thus read only.
3396    ///
3397    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/byteLength)
3398    #[wasm_bindgen(method, getter, js_name = byteLength)]
3399    pub fn byte_length(this: &DataView) -> usize;
3400
3401    /// The offset (in bytes) of this view from the start of its ArrayBuffer.
3402    /// Fixed at construction time and thus read only.
3403    ///
3404    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/byteOffset)
3405    #[wasm_bindgen(method, getter, js_name = byteOffset)]
3406    pub fn byte_offset(this: &DataView) -> usize;
3407
3408    /// The `getInt8()` method gets a signed 8-bit integer (byte) at the
3409    /// specified byte offset from the start of the DataView.
3410    ///
3411    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getInt8)
3412    #[wasm_bindgen(method, js_name = getInt8)]
3413    pub fn get_int8(this: &DataView, byte_offset: usize) -> i8;
3414
3415    /// The `getUint8()` method gets a unsigned 8-bit integer (byte) at the specified
3416    /// byte offset from the start of the DataView.
3417    ///
3418    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getUint8)
3419    #[wasm_bindgen(method, js_name = getUint8)]
3420    pub fn get_uint8(this: &DataView, byte_offset: usize) -> u8;
3421
3422    /// The `getInt16()` method gets a signed 16-bit integer (short) at the specified
3423    /// byte offset from the start of the DataView.
3424    ///
3425    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getInt16)
3426    #[wasm_bindgen(method, js_name = getInt16)]
3427    pub fn get_int16(this: &DataView, byte_offset: usize) -> i16;
3428
3429    /// The `getInt16()` method gets a signed 16-bit integer (short) at the specified
3430    /// byte offset from the start of the DataView.
3431    ///
3432    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getInt16)
3433    #[wasm_bindgen(method, js_name = getInt16)]
3434    pub fn get_int16_endian(this: &DataView, byte_offset: usize, little_endian: bool) -> i16;
3435
3436    /// The `getUint16()` method gets an unsigned 16-bit integer (unsigned short) at the specified
3437    /// byte offset from the start of the view.
3438    ///
3439    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getUint16)
3440    #[wasm_bindgen(method, js_name = getUint16)]
3441    pub fn get_uint16(this: &DataView, byte_offset: usize) -> u16;
3442
3443    /// The `getUint16()` method gets an unsigned 16-bit integer (unsigned short) at the specified
3444    /// byte offset from the start of the view.
3445    ///
3446    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getUint16)
3447    #[wasm_bindgen(method, js_name = getUint16)]
3448    pub fn get_uint16_endian(this: &DataView, byte_offset: usize, little_endian: bool) -> u16;
3449
3450    /// The `getInt32()` method gets a signed 32-bit integer (long) at the specified
3451    /// byte offset from the start of the DataView.
3452    ///
3453    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getInt32)
3454    #[wasm_bindgen(method, js_name = getInt32)]
3455    pub fn get_int32(this: &DataView, byte_offset: usize) -> i32;
3456
3457    /// The `getInt32()` method gets a signed 32-bit integer (long) at the specified
3458    /// byte offset from the start of the DataView.
3459    ///
3460    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getInt32)
3461    #[wasm_bindgen(method, js_name = getInt32)]
3462    pub fn get_int32_endian(this: &DataView, byte_offset: usize, little_endian: bool) -> i32;
3463
3464    /// The `getUint32()` method gets an unsigned 32-bit integer (unsigned long) at the specified
3465    /// byte offset from the start of the view.
3466    ///
3467    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getUint32)
3468    #[wasm_bindgen(method, js_name = getUint32)]
3469    pub fn get_uint32(this: &DataView, byte_offset: usize) -> u32;
3470
3471    /// The `getUint32()` method gets an unsigned 32-bit integer (unsigned long) at the specified
3472    /// byte offset from the start of the view.
3473    ///
3474    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getUint32)
3475    #[wasm_bindgen(method, js_name = getUint32)]
3476    pub fn get_uint32_endian(this: &DataView, byte_offset: usize, little_endian: bool) -> u32;
3477
3478    /// The `getFloat32()` method gets a signed 32-bit float (float) at the specified
3479    /// byte offset from the start of the DataView.
3480    ///
3481    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getFloat32)
3482    #[wasm_bindgen(method, js_name = getFloat32)]
3483    pub fn get_float32(this: &DataView, byte_offset: usize) -> f32;
3484
3485    /// The `getFloat32()` method gets a signed 32-bit float (float) at the specified
3486    /// byte offset from the start of the DataView.
3487    ///
3488    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getFloat32)
3489    #[wasm_bindgen(method, js_name = getFloat32)]
3490    pub fn get_float32_endian(this: &DataView, byte_offset: usize, little_endian: bool) -> f32;
3491
3492    /// The `getFloat16()` method gets a signed 16-bit float at the specified
3493    /// byte offset from the start of the DataView as an `f32`.
3494    ///
3495    /// The unsuffixed `get_float16` name is reserved for a future native
3496    /// `f16` binding once Rust stabilizes the type.
3497    ///
3498    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getFloat16)
3499    #[wasm_bindgen(method, js_name = getFloat16)]
3500    pub fn get_float16_as_f32(this: &DataView, byte_offset: usize) -> f32;
3501
3502    /// The `getFloat16()` method gets a signed 16-bit float at the specified
3503    /// byte offset from the start of the DataView as an `f32`.
3504    ///
3505    /// The unsuffixed `get_float16_endian` name is reserved for a future
3506    /// native `f16` binding once Rust stabilizes the type.
3507    ///
3508    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getFloat16)
3509    #[wasm_bindgen(method, js_name = getFloat16)]
3510    pub fn get_float16_endian_as_f32(
3511        this: &DataView,
3512        byte_offset: usize,
3513        little_endian: bool,
3514    ) -> f32;
3515
3516    /// The `getFloat64()` method gets a signed 64-bit float (double) at the specified
3517    /// byte offset from the start of the DataView.
3518    ///
3519    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getFloat64)
3520    #[wasm_bindgen(method, js_name = getFloat64)]
3521    pub fn get_float64(this: &DataView, byte_offset: usize) -> f64;
3522
3523    /// The `getFloat64()` method gets a signed 64-bit float (double) at the specified
3524    /// byte offset from the start of the DataView.
3525    ///
3526    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getFloat64)
3527    #[wasm_bindgen(method, js_name = getFloat64)]
3528    pub fn get_float64_endian(this: &DataView, byte_offset: usize, little_endian: bool) -> f64;
3529
3530    /// The `setInt8()` method stores a signed 8-bit integer (byte) value at the
3531    /// specified byte offset from the start of the DataView.
3532    ///
3533    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setInt8)
3534    #[wasm_bindgen(method, js_name = setInt8)]
3535    pub fn set_int8(this: &DataView, byte_offset: usize, value: i8);
3536
3537    /// The `setUint8()` method stores an unsigned 8-bit integer (byte) value at the
3538    /// specified byte offset from the start of the DataView.
3539    ///
3540    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setUint8)
3541    #[wasm_bindgen(method, js_name = setUint8)]
3542    pub fn set_uint8(this: &DataView, byte_offset: usize, value: u8);
3543
3544    /// The `setInt16()` method stores a signed 16-bit integer (short) value at the
3545    /// specified byte offset from the start of the DataView.
3546    ///
3547    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setInt16)
3548    #[wasm_bindgen(method, js_name = setInt16)]
3549    pub fn set_int16(this: &DataView, byte_offset: usize, value: i16);
3550
3551    /// The `setInt16()` method stores a signed 16-bit integer (short) value at the
3552    /// specified byte offset from the start of the DataView.
3553    ///
3554    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setInt16)
3555    #[wasm_bindgen(method, js_name = setInt16)]
3556    pub fn set_int16_endian(this: &DataView, byte_offset: usize, value: i16, little_endian: bool);
3557
3558    /// The `setUint16()` method stores an unsigned 16-bit integer (unsigned short) value at the
3559    /// specified byte offset from the start of the DataView.
3560    ///
3561    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setUint16)
3562    #[wasm_bindgen(method, js_name = setUint16)]
3563    pub fn set_uint16(this: &DataView, byte_offset: usize, value: u16);
3564
3565    /// The `setUint16()` method stores an unsigned 16-bit integer (unsigned short) value at the
3566    /// specified byte offset from the start of the DataView.
3567    ///
3568    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setUint16)
3569    #[wasm_bindgen(method, js_name = setUint16)]
3570    pub fn set_uint16_endian(this: &DataView, byte_offset: usize, value: u16, little_endian: bool);
3571
3572    /// The `setInt32()` method stores a signed 32-bit integer (long) value at the
3573    /// specified byte offset from the start of the DataView.
3574    ///
3575    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setInt32)
3576    #[wasm_bindgen(method, js_name = setInt32)]
3577    pub fn set_int32(this: &DataView, byte_offset: usize, value: i32);
3578
3579    /// The `setInt32()` method stores a signed 32-bit integer (long) value at the
3580    /// specified byte offset from the start of the DataView.
3581    ///
3582    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setInt32)
3583    #[wasm_bindgen(method, js_name = setInt32)]
3584    pub fn set_int32_endian(this: &DataView, byte_offset: usize, value: i32, little_endian: bool);
3585
3586    /// The `setUint32()` method stores an unsigned 32-bit integer (unsigned long) value at the
3587    /// specified byte offset from the start of the DataView.
3588    ///
3589    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setUint32)
3590    #[wasm_bindgen(method, js_name = setUint32)]
3591    pub fn set_uint32(this: &DataView, byte_offset: usize, value: u32);
3592
3593    /// The `setUint32()` method stores an unsigned 32-bit integer (unsigned long) value at the
3594    /// specified byte offset from the start of the DataView.
3595    ///
3596    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setUint32)
3597    #[wasm_bindgen(method, js_name = setUint32)]
3598    pub fn set_uint32_endian(this: &DataView, byte_offset: usize, value: u32, little_endian: bool);
3599
3600    /// The `setFloat32()` method stores a signed 32-bit float (float) value at the
3601    /// specified byte offset from the start of the DataView.
3602    ///
3603    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setFloat32)
3604    #[wasm_bindgen(method, js_name = setFloat32)]
3605    pub fn set_float32(this: &DataView, byte_offset: usize, value: f32);
3606
3607    /// The `setFloat32()` method stores a signed 32-bit float (float) value at the
3608    /// specified byte offset from the start of the DataView.
3609    ///
3610    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setFloat32)
3611    #[wasm_bindgen(method, js_name = setFloat32)]
3612    pub fn set_float32_endian(this: &DataView, byte_offset: usize, value: f32, little_endian: bool);
3613
3614    /// The `setFloat16()` method stores a signed 16-bit float value from an
3615    /// `f32` at the specified byte offset from the start of the DataView.
3616    ///
3617    /// The unsuffixed `set_float16` name is reserved for a future native
3618    /// `f16` binding once Rust stabilizes the type.
3619    ///
3620    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setFloat16)
3621    #[wasm_bindgen(method, js_name = setFloat16)]
3622    pub fn set_float16_from_f32(this: &DataView, byte_offset: usize, value: f32);
3623
3624    /// The `setFloat16()` method stores a signed 16-bit float value from an
3625    /// `f32` at the specified byte offset from the start of the DataView.
3626    ///
3627    /// The unsuffixed `set_float16_endian` name is reserved for a future
3628    /// native `f16` binding once Rust stabilizes the type.
3629    ///
3630    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setFloat16)
3631    #[wasm_bindgen(method, js_name = setFloat16)]
3632    pub fn set_float16_endian_from_f32(
3633        this: &DataView,
3634        byte_offset: usize,
3635        value: f32,
3636        little_endian: bool,
3637    );
3638
3639    /// The `setFloat64()` method stores a signed 64-bit float (double) value at the
3640    /// specified byte offset from the start of the DataView.
3641    ///
3642    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setFloat64)
3643    #[wasm_bindgen(method, js_name = setFloat64)]
3644    pub fn set_float64(this: &DataView, byte_offset: usize, value: f64);
3645
3646    /// The `setFloat64()` method stores a signed 64-bit float (double) value at the
3647    /// specified byte offset from the start of the DataView.
3648    ///
3649    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setFloat64)
3650    #[wasm_bindgen(method, js_name = setFloat64)]
3651    pub fn set_float64_endian(this: &DataView, byte_offset: usize, value: f64, little_endian: bool);
3652}
3653
3654// Error
3655#[wasm_bindgen]
3656extern "C" {
3657    #[wasm_bindgen(extends = Object, typescript_type = "Error")]
3658    #[derive(Clone, Debug, PartialEq, Eq)]
3659    pub type Error;
3660
3661    /// The Error constructor creates an error object.
3662    /// Instances of Error objects are thrown when runtime errors occur.
3663    /// The Error object can also be used as a base object for user-defined exceptions.
3664    /// See below for standard built-in error types.
3665    ///
3666    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error)
3667    #[wasm_bindgen(constructor)]
3668    pub fn new(message: &str) -> Error;
3669
3670    /// Creates a new `Error` with the given message and an untyped options
3671    /// object whose `cause` property indicates the original cause of the
3672    /// error.
3673    ///
3674    /// New code should prefer [`Error::new_with_error_options`], which takes
3675    /// a typed [`ErrorOptions`] dictionary.
3676    ///
3677    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/Error)
3678    #[wasm_bindgen(constructor)]
3679    pub fn new_with_options(message: &str, options: &Object) -> Error;
3680
3681    /// Creates a new `Error` with the given message and a typed
3682    /// [`ErrorOptions`] dictionary whose `cause` property indicates the
3683    /// original cause of the error.
3684    ///
3685    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/Error)
3686    #[wasm_bindgen(constructor)]
3687    pub fn new_with_error_options(message: &str, options: &ErrorOptions) -> Error;
3688
3689    /// The cause property is the underlying cause of the error.
3690    /// Usually this is used to add context to re-thrown errors.
3691    ///
3692    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error#differentiate_between_similar_errors)
3693    #[wasm_bindgen(method, getter)]
3694    pub fn cause(this: &Error) -> JsValue;
3695    #[wasm_bindgen(method, setter)]
3696    pub fn set_cause(this: &Error, cause: &JsValue);
3697
3698    /// The message property is a human-readable description of the error.
3699    ///
3700    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/message)
3701    #[wasm_bindgen(method, getter)]
3702    pub fn message(this: &Error) -> JsString;
3703    #[wasm_bindgen(method, setter)]
3704    pub fn set_message(this: &Error, message: &str);
3705
3706    /// The name property represents a name for the type of error. The initial value is "Error".
3707    ///
3708    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/name)
3709    #[wasm_bindgen(method, getter)]
3710    pub fn name(this: &Error) -> JsString;
3711    #[wasm_bindgen(method, setter)]
3712    pub fn set_name(this: &Error, name: &str);
3713
3714    /// The `toString()` method returns a string representing the specified Error object
3715    ///
3716    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/toString)
3717    #[cfg(not(js_sys_unstable_apis))]
3718    #[wasm_bindgen(method, js_name = toString)]
3719    pub fn to_string(this: &Error) -> JsString;
3720
3721    /// The `Error.stackTraceLimit` property controls the number of stack
3722    /// frames collected by a stack trace.
3723    ///
3724    /// This is a non-standard V8/Node.js API.
3725    ///
3726    /// [V8 documentation](https://v8.dev/docs/stack-trace-api#stack-trace-collection-for-custom-exceptions)
3727    #[wasm_bindgen(static_method_of = Error, getter, js_name = stackTraceLimit)]
3728    pub fn stack_trace_limit() -> JsValue;
3729
3730    /// Set `Error.stackTraceLimit` to control the number of stack frames
3731    /// collected by a stack trace.
3732    ///
3733    /// This is a non-standard V8/Node.js API.
3734    ///
3735    /// [V8 documentation](https://v8.dev/docs/stack-trace-api#stack-trace-collection-for-custom-exceptions)
3736    #[wasm_bindgen(static_method_of = Error, setter, js_name = stackTraceLimit)]
3737    pub fn set_stack_trace_limit(value: &JsValue);
3738}
3739
3740partialord_ord!(JsString);
3741
3742// EvalError
3743#[wasm_bindgen]
3744extern "C" {
3745    #[wasm_bindgen(extends = Object, extends = Error, typescript_type = "EvalError")]
3746    #[derive(Clone, Debug, PartialEq, Eq)]
3747    pub type EvalError;
3748
3749    /// The `EvalError` object indicates an error regarding the global eval() function. This
3750    /// exception is not thrown by JavaScript anymore, however the EvalError object remains for
3751    /// compatibility.
3752    ///
3753    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError)
3754    #[wasm_bindgen(constructor)]
3755    pub fn new(message: &str) -> EvalError;
3756
3757    /// Creates a new `EvalError` with the given message and a typed
3758    /// [`ErrorOptions`] dictionary whose `cause` property indicates the
3759    /// original cause of the error.
3760    ///
3761    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError/EvalError)
3762    #[wasm_bindgen(constructor)]
3763    pub fn new_with_options(message: &str, options: &ErrorOptions) -> EvalError;
3764}
3765
3766#[wasm_bindgen]
3767extern "C" {
3768    #[wasm_bindgen(extends = Object, is_type_of = JsValue::is_function, no_upcast, typescript_type = "Function")]
3769    #[derive(Clone, Debug, PartialEq, Eq)]
3770    /// `Function` represents any generic Function in JS, by treating all arguments as `JsValue`.
3771    ///
3772    /// It takes a generic parameter of phantom type `fn (Arg1, ..., Argn) -> Ret` which
3773    /// is used to type the JS function. For example, `Function<fn () -> Number>` represents
3774    /// a function taking no arguments that returns a number.
3775    ///
3776    /// The 8 generic argument parameters (`Arg1` through `Arg8`) are the argument
3777    /// types. Arguments not provided enable strict arity checking at compile time.
3778    ///
3779    /// A void function is represented by `fn (Arg) -> Undefined`, and **not** the `()` unit
3780    /// type. This is because generics must be based on JS values in the JS generic type system.
3781    ///
3782    /// _The default without any parameters is as a void function - no arguments, `Undefined` return._
3783    ///
3784    /// _The default generic for `Function` is `fn (JsValue, JsValue, ...) -> JsValue`,
3785    /// representing any function, since all functions safely upcast into this function._
3786    ///
3787    /// ### Arity Enforcement
3788    ///
3789    /// It is not possible to use `call4` or `bind4` on a function that does not have
3790    /// at least 4 arguments — the compiler will reject this because only arguments that
3791    /// are not `None` support the trait bound for `ErasableGeneric`.
3792    ///
3793    /// ### Examples
3794    ///
3795    /// ```ignore
3796    /// // A function taking no args, returning Number
3797    /// let f: Function<Number> = get_some_fn();
3798    ///
3799    /// // A function taking (String, Number) and returning Boolean
3800    /// let f: Function<Boolean, String, Number> = get_some_fn();
3801    ///
3802    /// ### Upcasting
3803    ///
3804    /// To pass a typed `Function` where a different generic Function is expected, `upcast()` may be used
3805    /// to convert into any generic `Function` at zero cost with type-safety.
3806    ///
3807    /// MDN documentation (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function)
3808    pub type Function<
3809        T: JsFunction = fn(
3810            JsValue,
3811            JsValue,
3812            JsValue,
3813            JsValue,
3814            JsValue,
3815            JsValue,
3816            JsValue,
3817            JsValue,
3818        ) -> JsValue,
3819    >;
3820}
3821
3822#[wasm_bindgen]
3823extern "C" {
3824    /// The `Function` constructor creates a new `Function` object. Calling the
3825    /// constructor directly can create functions dynamically, but suffers from
3826    /// security and similar (but far less significant) performance issues
3827    /// similar to `eval`. However, unlike `eval`, the `Function` constructor
3828    /// allows executing code in the global scope, prompting better programming
3829    /// habits and allowing for more efficient code minification.
3830    ///
3831    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function)
3832    #[cfg(all(feature = "unsafe-eval", not(js_sys_unstable_apis)))]
3833    #[wasm_bindgen(constructor)]
3834    pub fn new_with_args(args: &str, body: &str) -> Function;
3835
3836    /// The `Function` constructor creates a new `Function` object. Calling the
3837    /// constructor directly can create functions dynamically, but suffers from
3838    /// security and similar (but far less significant) performance issues
3839    /// similar to `eval`. However, unlike `eval`, the `Function` constructor
3840    /// allows executing code in the global scope, prompting better programming
3841    /// habits and allowing for more efficient code minification.
3842    ///
3843    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function)
3844    #[cfg(all(feature = "unsafe-eval", js_sys_unstable_apis))]
3845    #[wasm_bindgen(constructor)]
3846    pub fn new_with_args<T: JsFunction = fn() -> JsValue>(args: &str, body: &str) -> Function<T>;
3847
3848    // Next major: deprecate
3849    /// The `Function` constructor creates a new `Function` object. Calling the
3850    /// constructor directly can create functions dynamically, but suffers from
3851    /// security and similar (but far less significant) performance issues
3852    /// similar to `eval`. However, unlike `eval`, the `Function` constructor
3853    /// allows executing code in the global scope, prompting better programming
3854    /// habits and allowing for more efficient code minification.
3855    ///
3856    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function)
3857    #[cfg(feature = "unsafe-eval")]
3858    #[wasm_bindgen(constructor)]
3859    pub fn new_with_args_typed<T: JsFunction = fn() -> JsValue>(
3860        args: &str,
3861        body: &str,
3862    ) -> Function<T>;
3863
3864    /// The `Function` constructor creates a new `Function` object. Calling the
3865    /// constructor directly can create functions dynamically, but suffers from
3866    /// security and similar (but far less significant) performance issues
3867    /// similar to `eval`. However, unlike `eval`, the `Function` constructor
3868    /// allows executing code in the global scope, prompting better programming
3869    /// habits and allowing for more efficient code minification.
3870    ///
3871    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function)
3872    #[cfg(all(feature = "unsafe-eval", not(js_sys_unstable_apis)))]
3873    #[wasm_bindgen(constructor)]
3874    pub fn new_no_args(body: &str) -> Function;
3875
3876    /// The `Function` constructor creates a new `Function` object. Calling the
3877    /// constructor directly can create functions dynamically, but suffers from
3878    /// security and similar (but far less significant) performance issues
3879    /// similar to `eval`. However, unlike `eval`, the `Function` constructor
3880    /// allows executing code in the global scope, prompting better programming
3881    /// habits and allowing for more efficient code minification.
3882    ///
3883    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function)
3884    #[cfg(all(feature = "unsafe-eval", js_sys_unstable_apis))]
3885    #[wasm_bindgen(constructor)]
3886    pub fn new_no_args<T: JsFunction = fn() -> JsValue>(body: &str) -> Function<T>;
3887
3888    // Next major: deprecate
3889    /// The `Function` constructor creates a new `Function` object.
3890    ///
3891    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function)
3892    #[cfg(feature = "unsafe-eval")]
3893    #[wasm_bindgen(constructor)]
3894    pub fn new_no_args_typed<T: JsFunction = fn() -> JsValue>(body: &str) -> Function<T>;
3895
3896    /// The `apply()` method calls a function with a given this value, and arguments provided as an array
3897    /// (or an array-like object).
3898    ///
3899    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/apply)
3900    #[wasm_bindgen(method, catch)]
3901    pub fn apply<T: JsFunction = fn() -> JsValue>(
3902        this: &Function<T>,
3903        context: &JsValue,
3904        args: &Array,
3905    ) -> Result<<T as JsFunction>::Ret, JsValue>;
3906
3907    // Next major: Deprecate, and separately provide provide impl
3908    /// The `call()` method calls a function with a given this value and
3909    /// arguments provided individually.
3910    ///
3911    /// **Note: Use [`call()`](Function::call) to get exact arity and also checked generic type casting.**
3912    ///
3913    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
3914    #[wasm_bindgen(method, catch, js_name = call)]
3915    pub fn call0<Ret: JsGeneric, F: JsFunction<Ret = Ret> = fn() -> JsValue>(
3916        this: &Function<F>,
3917        context: &JsValue,
3918    ) -> Result<Ret, JsValue>;
3919
3920    // Next major: Deprecate, and separately provide provide impl
3921    /// The `call()` method calls a function with a given this value and
3922    /// arguments provided individually.
3923    ///
3924    /// **Note: Use [`call()`](Function::call) to get exact arity and also checked generic type casting.**
3925    ///
3926    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
3927    #[wasm_bindgen(method, catch, js_name = call)]
3928    pub fn call1<
3929        Ret: JsGeneric,
3930        Arg1: JsGeneric,
3931        F: JsFunction<Ret = Ret> + JsFunction1<Arg1 = Arg1> = fn(JsValue) -> JsValue,
3932    >(
3933        this: &Function<F>,
3934        context: &JsValue,
3935        arg1: &Arg1,
3936    ) -> Result<Ret, JsValue>;
3937
3938    // Next major: Deprecate, and separately provide provide impl
3939    /// The `call()` method calls a function with a given this value and
3940    /// arguments provided individually.
3941    ///
3942    /// **Note: Use [`call()`](Function::call) to get exact arity and also checked generic type casting.**
3943    ///
3944    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
3945    #[wasm_bindgen(method, catch, js_name = call)]
3946    pub fn call2<
3947        Ret: JsGeneric,
3948        Arg1: JsGeneric,
3949        Arg2: JsGeneric,
3950        F: JsFunction<Ret = Ret> + JsFunction1<Arg1 = Arg1> + JsFunction2<Arg2 = Arg2> = fn(
3951            JsValue,
3952            JsValue,
3953        ) -> JsValue,
3954    >(
3955        this: &Function<F>,
3956        context: &JsValue,
3957        arg1: &Arg1,
3958        arg2: &Arg2,
3959    ) -> Result<Ret, JsValue>;
3960
3961    // Next major: Deprecate, and separately provide provide impl
3962    /// The `call()` method calls a function with a given this value and
3963    /// arguments provided individually.
3964    ///
3965    /// **Note: Use [`call()`](Function::call) to get exact arity and also checked generic type casting.**
3966    ///
3967    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
3968    #[wasm_bindgen(method, catch, js_name = call)]
3969    pub fn call3<
3970        Ret: JsGeneric,
3971        Arg1: JsGeneric,
3972        Arg2: JsGeneric,
3973        Arg3: JsGeneric,
3974        F: JsFunction<Ret = Ret> + JsFunction3<Arg1 = Arg1, Arg2 = Arg2, Arg3 = Arg3> = fn(
3975            JsValue,
3976            JsValue,
3977            JsValue,
3978        ) -> JsValue,
3979    >(
3980        this: &Function<F>,
3981        context: &JsValue,
3982        arg1: &Arg1,
3983        arg2: &Arg2,
3984        arg3: &Arg3,
3985    ) -> Result<Ret, JsValue>;
3986
3987    // Next major: Deprecate, and separately provide provide impl
3988    /// The `call()` method calls a function with a given this value and
3989    /// arguments provided individually.
3990    ///
3991    /// **Note: Use [`call()`](Function::call) to get exact arity and also checked generic type casting.**
3992    ///
3993    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
3994    #[wasm_bindgen(method, catch, js_name = call)]
3995    pub fn call4<
3996        Ret: JsGeneric,
3997        Arg1: JsGeneric,
3998        Arg2: JsGeneric,
3999        Arg3: JsGeneric,
4000        Arg4: JsGeneric,
4001        F: JsFunction<Ret = Ret> + JsFunction4<Arg1 = Arg1, Arg2 = Arg2, Arg3 = Arg3, Arg4 = Arg4> = fn(
4002            JsValue,
4003            JsValue,
4004            JsValue,
4005            JsValue,
4006        ) -> JsValue,
4007    >(
4008        this: &Function<F>,
4009        context: &JsValue,
4010        arg1: &Arg1,
4011        arg2: &Arg2,
4012        arg3: &Arg3,
4013        arg4: &Arg4,
4014    ) -> Result<Ret, JsValue>;
4015
4016    // Next major: Deprecate, and separately provide provide impl
4017    /// The `call()` method calls a function with a given this value and
4018    /// arguments provided individually.
4019    ///
4020    /// **Note: Use [`call()`](Function::call) to get exact arity and also checked generic type casting.**
4021    ///
4022    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
4023    #[wasm_bindgen(method, catch, js_name = call)]
4024    pub fn call5<
4025        Ret: JsGeneric,
4026        Arg1: JsGeneric,
4027        Arg2: JsGeneric,
4028        Arg3: JsGeneric,
4029        Arg4: JsGeneric,
4030        Arg5: JsGeneric,
4031        F: JsFunction<Ret = Ret>
4032            + JsFunction5<Arg1 = Arg1, Arg2 = Arg2, Arg3 = Arg3, Arg4 = Arg4, Arg5 = Arg5> = fn(
4033            JsValue,
4034            JsValue,
4035            JsValue,
4036            JsValue,
4037            JsValue,
4038        ) -> JsValue,
4039    >(
4040        this: &Function<F>,
4041        context: &JsValue,
4042        arg1: &Arg1,
4043        arg2: &Arg2,
4044        arg3: &Arg3,
4045        arg4: &Arg4,
4046        arg5: &Arg5,
4047    ) -> Result<Ret, JsValue>;
4048
4049    // Next major: Deprecate, and separately provide provide impl
4050    /// The `call()` method calls a function with a given this value and
4051    /// arguments provided individually.
4052    ///
4053    /// **Note: Use [`call()`](Function::call) to get exact arity and also checked generic type casting.**
4054    ///
4055    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
4056    #[wasm_bindgen(method, catch, js_name = call)]
4057    pub fn call6<
4058        Ret: JsGeneric,
4059        Arg1: JsGeneric,
4060        Arg2: JsGeneric,
4061        Arg3: JsGeneric,
4062        Arg4: JsGeneric,
4063        Arg5: JsGeneric,
4064        Arg6: JsGeneric,
4065        F: JsFunction<Ret = Ret>
4066            + JsFunction6<
4067                Arg1 = Arg1,
4068                Arg2 = Arg2,
4069                Arg3 = Arg3,
4070                Arg4 = Arg4,
4071                Arg5 = Arg5,
4072                Arg6 = Arg6,
4073            > = fn(JsValue, JsValue, JsValue, JsValue, JsValue, JsValue) -> JsValue,
4074    >(
4075        this: &Function<F>,
4076        context: &JsValue,
4077        arg1: &Arg1,
4078        arg2: &Arg2,
4079        arg3: &Arg3,
4080        arg4: &Arg4,
4081        arg5: &Arg5,
4082        arg6: &Arg6,
4083    ) -> Result<Ret, JsValue>;
4084
4085    // Next major: Deprecate, and separately provide provide impl
4086    /// The `call()` method calls a function with a given this value and
4087    /// arguments provided individually.
4088    ///
4089    /// **Note: Use [`call()`](Function::call) to get exact arity and also checked generic type casting.**
4090    ///
4091    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
4092    #[wasm_bindgen(method, catch, js_name = call)]
4093    pub fn call7<
4094        Ret: JsGeneric,
4095        Arg1: JsGeneric,
4096        Arg2: JsGeneric,
4097        Arg3: JsGeneric,
4098        Arg4: JsGeneric,
4099        Arg5: JsGeneric,
4100        Arg6: JsGeneric,
4101        Arg7: JsGeneric,
4102        F: JsFunction<Ret = Ret>
4103            + JsFunction7<
4104                Arg1 = Arg1,
4105                Arg2 = Arg2,
4106                Arg3 = Arg3,
4107                Arg4 = Arg4,
4108                Arg5 = Arg5,
4109                Arg6 = Arg6,
4110                Arg7 = Arg7,
4111            > = fn(
4112            JsValue,
4113            JsValue,
4114            JsValue,
4115            JsValue,
4116            JsValue,
4117            JsValue,
4118            JsValue,
4119        ) -> JsValue,
4120    >(
4121        this: &Function<F>,
4122        context: &JsValue,
4123        arg1: &Arg1,
4124        arg2: &Arg2,
4125        arg3: &Arg3,
4126        arg4: &Arg4,
4127        arg5: &Arg5,
4128        arg6: &Arg6,
4129        arg7: &Arg7,
4130    ) -> Result<Ret, JsValue>;
4131
4132    // Next major: Deprecate, and separately provide provide impl
4133    /// The `call()` method calls a function with a given this value and
4134    /// arguments provided individually.
4135    ///
4136    /// **Note: Use [`call()`](Function::call) to get exact arity and also checked generic type casting.**
4137    ///
4138    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
4139    #[wasm_bindgen(method, catch, js_name = call)]
4140    pub fn call8<
4141        Ret: JsGeneric,
4142        Arg1: JsGeneric,
4143        Arg2: JsGeneric,
4144        Arg3: JsGeneric,
4145        Arg4: JsGeneric,
4146        Arg5: JsGeneric,
4147        Arg6: JsGeneric,
4148        Arg7: JsGeneric,
4149        Arg8: JsGeneric,
4150        F: JsFunction8<
4151            Ret = Ret,
4152            Arg1 = Arg1,
4153            Arg2 = Arg2,
4154            Arg3 = Arg3,
4155            Arg4 = Arg4,
4156            Arg5 = Arg5,
4157            Arg6 = Arg6,
4158            Arg7 = Arg7,
4159            Arg8 = Arg8,
4160        > = fn(
4161            JsValue,
4162            JsValue,
4163            JsValue,
4164            JsValue,
4165            JsValue,
4166            JsValue,
4167            JsValue,
4168            JsValue,
4169        ) -> JsValue,
4170    >(
4171        this: &Function<F>,
4172        context: &JsValue,
4173        arg1: &Arg1,
4174        arg2: &Arg2,
4175        arg3: &Arg3,
4176        arg4: &Arg4,
4177        arg5: &Arg5,
4178        arg6: &Arg6,
4179        arg7: &Arg7,
4180        arg8: &Arg8,
4181    ) -> Result<Ret, JsValue>;
4182
4183    /// The `call()` method calls a function with a given this value and
4184    /// arguments provided individually.
4185    ///
4186    /// **Note: Use [`call()`](Function::call) to get exact arity and also checked generic type casting.**
4187    ///
4188    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
4189    #[deprecated]
4190    #[allow(deprecated)]
4191    #[wasm_bindgen(method, catch, js_name = call)]
4192    pub fn call9<
4193        Ret: JsGeneric,
4194        Arg1: JsGeneric,
4195        Arg2: JsGeneric,
4196        Arg3: JsGeneric,
4197        Arg4: JsGeneric,
4198        Arg5: JsGeneric,
4199        Arg6: JsGeneric,
4200        Arg7: JsGeneric,
4201        Arg8: JsGeneric,
4202        F: JsFunction8<
4203            Ret = Ret,
4204            Arg1 = Arg1,
4205            Arg2 = Arg2,
4206            Arg3 = Arg3,
4207            Arg4 = Arg4,
4208            Arg5 = Arg5,
4209            Arg6 = Arg6,
4210            Arg7 = Arg7,
4211            Arg8 = Arg8,
4212        > = fn(
4213            JsValue,
4214            JsValue,
4215            JsValue,
4216            JsValue,
4217            JsValue,
4218            JsValue,
4219            JsValue,
4220            JsValue,
4221        ) -> JsValue,
4222    >(
4223        this: &Function<F>,
4224        context: &JsValue,
4225        arg1: &Arg1,
4226        arg2: &Arg2,
4227        arg3: &Arg3,
4228        arg4: &Arg4,
4229        arg5: &Arg5,
4230        arg6: &Arg6,
4231        arg7: &Arg7,
4232        arg8: &Arg8,
4233        arg9: &JsValue,
4234    ) -> Result<Ret, JsValue>;
4235
4236    /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
4237    /// with a given sequence of arguments preceding any provided when the new function is called.
4238    ///
4239    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
4240    #[cfg(not(js_sys_unstable_apis))]
4241    #[deprecated(note = "Use `Function::bind0` instead.")]
4242    #[allow(deprecated)]
4243    #[wasm_bindgen(method, js_name = bind)]
4244    pub fn bind<T: JsFunction = fn() -> JsValue>(
4245        this: &Function<T>,
4246        context: &JsValue,
4247    ) -> Function<T>;
4248
4249    /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
4250    /// with a given sequence of arguments preceding any provided when the new function is called.
4251    ///
4252    /// *Note:* See [`Function::bindn`] for arbitrary binding with function arity checking.
4253    ///
4254    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
4255    #[wasm_bindgen(method, js_name = bind)]
4256    pub fn bind0<T: JsFunction = fn() -> JsValue>(
4257        this: &Function<T>,
4258        context: &JsValue,
4259    ) -> Function<T>;
4260
4261    /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
4262    /// with a given sequence of arguments preceding any provided when the new function is called.
4263    ///
4264    /// *Note:* See [`Function::bindn`] for arbitrary binding with function arity checking.
4265    ///
4266    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
4267    #[wasm_bindgen(method, js_name = bind)]
4268    pub fn bind1<
4269        Ret: JsGeneric,
4270        Arg1: JsGeneric,
4271        F: JsFunction1<Ret = Ret, Arg1 = Arg1> = fn(JsValue) -> JsValue,
4272    >(
4273        this: &Function<F>,
4274        context: &JsValue,
4275        arg1: &Arg1,
4276    ) -> Function<<F as JsFunction1>::Bind1>;
4277
4278    /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
4279    /// with a given sequence of arguments preceding any provided when the new function is called.
4280    ///
4281    /// *Note:* See [`Function::bindn`] for arbitrary binding with function arity checking.
4282    ///
4283    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
4284    #[wasm_bindgen(method, js_name = bind)]
4285    pub fn bind2<
4286        Ret: JsGeneric,
4287        Arg1: JsGeneric,
4288        Arg2: JsGeneric,
4289        F: JsFunction2<Ret = Ret, Arg1 = Arg1, Arg2 = Arg2> = fn(JsValue, JsValue) -> JsValue,
4290    >(
4291        this: &Function<F>,
4292        context: &JsValue,
4293        arg1: &Arg1,
4294        arg2: &Arg2,
4295    ) -> Function<<F as JsFunction2>::Bind2>;
4296
4297    /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
4298    /// with a given sequence of arguments preceding any provided when the new function is called.
4299    ///
4300    /// *Note:* See [`Function::bindn`] for arbitrary binding with function arity checking.
4301    ///
4302    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
4303    #[wasm_bindgen(method, js_name = bind)]
4304    pub fn bind3<
4305        Ret: JsGeneric,
4306        Arg1: JsGeneric,
4307        Arg2: JsGeneric,
4308        Arg3: JsGeneric,
4309        F: JsFunction3<Ret = Ret, Arg1 = Arg1, Arg2 = Arg2, Arg3 = Arg3> = fn(
4310            JsValue,
4311            JsValue,
4312            JsValue,
4313        ) -> JsValue,
4314    >(
4315        this: &Function<F>,
4316        context: &JsValue,
4317        arg1: &Arg1,
4318        arg2: &Arg2,
4319        arg3: &Arg3,
4320    ) -> Function<<F as JsFunction3>::Bind3>;
4321
4322    /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
4323    /// with a given sequence of arguments preceding any provided when the new function is called.
4324    ///
4325    /// *Note:* See [`Function::bindn`] for arbitrary binding with function arity checking.
4326    ///
4327    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
4328    #[wasm_bindgen(method, js_name = bind)]
4329    pub fn bind4<
4330        Ret: JsGeneric,
4331        Arg1: JsGeneric,
4332        Arg2: JsGeneric,
4333        Arg3: JsGeneric,
4334        Arg4: JsGeneric,
4335        F: JsFunction4<Ret = Ret, Arg1 = Arg1, Arg2 = Arg2, Arg3 = Arg3, Arg4 = Arg4> = fn(
4336            JsValue,
4337            JsValue,
4338            JsValue,
4339            JsValue,
4340        ) -> JsValue,
4341    >(
4342        this: &Function<F>,
4343        context: &JsValue,
4344        arg1: &Arg1,
4345        arg2: &Arg2,
4346        arg3: &Arg3,
4347        arg4: &Arg4,
4348    ) -> Function<<F as JsFunction4>::Bind4>;
4349
4350    /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
4351    /// with a given sequence of arguments preceding any provided when the new function is called.
4352    ///
4353    /// *Note:* See [`Function::bindn`] for arbitrary binding with function arity checking.
4354    ///
4355    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
4356    #[wasm_bindgen(method, js_name = bind)]
4357    pub fn bind5<
4358        Ret: JsGeneric,
4359        Arg1: JsGeneric,
4360        Arg2: JsGeneric,
4361        Arg3: JsGeneric,
4362        Arg4: JsGeneric,
4363        Arg5: JsGeneric,
4364        F: JsFunction5<Ret = Ret, Arg1 = Arg1, Arg2 = Arg2, Arg3 = Arg3, Arg4 = Arg4, Arg5 = Arg5> = fn(
4365            JsValue,
4366            JsValue,
4367            JsValue,
4368            JsValue,
4369            JsValue,
4370        ) -> JsValue,
4371    >(
4372        this: &Function<F>,
4373        context: &JsValue,
4374        arg1: &Arg1,
4375        arg2: &Arg2,
4376        arg3: &Arg3,
4377        arg4: &Arg4,
4378        arg5: &Arg5,
4379    ) -> Function<<F as JsFunction5>::Bind5>;
4380
4381    /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
4382    /// with a given sequence of arguments preceding any provided when the new function is called.
4383    ///
4384    /// *Note:* See [`Function::bindn`] for arbitrary binding with function arity checking.
4385    ///
4386    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
4387    #[wasm_bindgen(method, js_name = bind)]
4388    pub fn bind6<
4389        Ret: JsGeneric,
4390        Arg1: JsGeneric,
4391        Arg2: JsGeneric,
4392        Arg3: JsGeneric,
4393        Arg4: JsGeneric,
4394        Arg5: JsGeneric,
4395        Arg6: JsGeneric,
4396        F: JsFunction6<
4397            Ret = Ret,
4398            Arg1 = Arg1,
4399            Arg2 = Arg2,
4400            Arg3 = Arg3,
4401            Arg4 = Arg4,
4402            Arg5 = Arg5,
4403            Arg6 = Arg6,
4404        > = fn(JsValue, JsValue, JsValue, JsValue, JsValue, JsValue) -> JsValue,
4405    >(
4406        this: &Function<F>,
4407        context: &JsValue,
4408        arg1: &Arg1,
4409        arg2: &Arg2,
4410        arg3: &Arg3,
4411        arg4: &Arg4,
4412        arg5: &Arg5,
4413        arg6: &Arg6,
4414    ) -> Function<<F as JsFunction6>::Bind6>;
4415
4416    /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
4417    /// with a given sequence of arguments preceding any provided when the new function is called.
4418    ///
4419    /// *Note:* See [`Function::bindn`] for arbitrary binding with function arity checking.
4420    ///
4421    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
4422    #[wasm_bindgen(method, js_name = bind)]
4423    pub fn bind7<
4424        Ret: JsGeneric,
4425        Arg1: JsGeneric,
4426        Arg2: JsGeneric,
4427        Arg3: JsGeneric,
4428        Arg4: JsGeneric,
4429        Arg5: JsGeneric,
4430        Arg6: JsGeneric,
4431        Arg7: JsGeneric,
4432        F: JsFunction7<
4433            Ret = Ret,
4434            Arg1 = Arg1,
4435            Arg2 = Arg2,
4436            Arg3 = Arg3,
4437            Arg4 = Arg4,
4438            Arg5 = Arg5,
4439            Arg6 = Arg6,
4440            Arg7 = Arg7,
4441        > = fn(
4442            JsValue,
4443            JsValue,
4444            JsValue,
4445            JsValue,
4446            JsValue,
4447            JsValue,
4448            JsValue,
4449        ) -> JsValue,
4450    >(
4451        this: &Function<F>,
4452        context: &JsValue,
4453        arg1: &Arg1,
4454        arg2: &Arg2,
4455        arg3: &Arg3,
4456        arg4: &Arg4,
4457        arg5: &Arg5,
4458        arg6: &Arg6,
4459        arg7: &Arg7,
4460    ) -> Function<<F as JsFunction7>::Bind7>;
4461
4462    /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
4463    /// with a given sequence of arguments preceding any provided when the new function is called.
4464    ///
4465    /// *Note:* See [`Function::bindn`] for arbitrary binding with function arity checking.
4466    ///
4467    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
4468    #[wasm_bindgen(method, js_name = bind)]
4469    pub fn bind8<
4470        Ret: JsGeneric,
4471        Arg1: JsGeneric,
4472        Arg2: JsGeneric,
4473        Arg3: JsGeneric,
4474        Arg4: JsGeneric,
4475        Arg5: JsGeneric,
4476        Arg6: JsGeneric,
4477        Arg7: JsGeneric,
4478        Arg8: JsGeneric,
4479        F: JsFunction8<
4480            Ret = Ret,
4481            Arg1 = Arg1,
4482            Arg2 = Arg2,
4483            Arg3 = Arg3,
4484            Arg4 = Arg4,
4485            Arg5 = Arg5,
4486            Arg6 = Arg6,
4487            Arg7 = Arg7,
4488            Arg8 = Arg8,
4489        > = fn(
4490            JsValue,
4491            JsValue,
4492            JsValue,
4493            JsValue,
4494            JsValue,
4495            JsValue,
4496            JsValue,
4497            JsValue,
4498        ) -> JsValue,
4499    >(
4500        this: &Function<F>,
4501        context: &JsValue,
4502        arg1: &Arg1,
4503        arg2: &Arg2,
4504        arg3: &Arg3,
4505        arg4: &Arg4,
4506        arg5: &Arg5,
4507        arg6: &Arg6,
4508        arg7: &Arg7,
4509        arg8: &Arg8,
4510    ) -> Function<<F as JsFunction8>::Bind8>;
4511
4512    /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
4513    /// with a given sequence of arguments preceding any provided when the new function is called.
4514    ///
4515    /// *Note:* See [`Function::bindn`] for arbitrary binding with function arity checking.
4516    ///
4517    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
4518    #[deprecated]
4519    #[allow(deprecated)]
4520    #[wasm_bindgen(method, js_name = bind)]
4521    pub fn bind9<
4522        Ret: JsGeneric,
4523        Arg1: JsGeneric,
4524        Arg2: JsGeneric,
4525        Arg3: JsGeneric,
4526        Arg4: JsGeneric,
4527        Arg5: JsGeneric,
4528        Arg6: JsGeneric,
4529        Arg7: JsGeneric,
4530        Arg8: JsGeneric,
4531        F: JsFunction8<
4532            Ret = Ret,
4533            Arg1 = Arg1,
4534            Arg2 = Arg2,
4535            Arg3 = Arg3,
4536            Arg4 = Arg4,
4537            Arg5 = Arg5,
4538            Arg6 = Arg6,
4539            Arg7 = Arg7,
4540            Arg8 = Arg8,
4541        > = fn(
4542            JsValue,
4543            JsValue,
4544            JsValue,
4545            JsValue,
4546            JsValue,
4547            JsValue,
4548            JsValue,
4549            JsValue,
4550        ) -> JsValue,
4551    >(
4552        this: &Function<F>,
4553        context: &JsValue,
4554        arg1: &Arg1,
4555        arg2: &Arg2,
4556        arg3: &Arg3,
4557        arg4: &Arg4,
4558        arg5: &Arg5,
4559        arg6: &Arg6,
4560        arg7: &Arg7,
4561        arg8: &Arg8,
4562        arg9: &JsValue,
4563    ) -> Function<fn() -> Ret>;
4564
4565    /// The length property indicates the number of arguments expected by the function.
4566    ///
4567    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/length)
4568    #[wasm_bindgen(method, getter)]
4569    pub fn length<T: JsFunction = fn() -> JsValue>(this: &Function<T>) -> u32;
4570
4571    /// A Function object's read-only name property indicates the function's
4572    /// name as specified when it was created or "anonymous" for functions
4573    /// created anonymously.
4574    ///
4575    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name)
4576    #[wasm_bindgen(method, getter)]
4577    pub fn name<T: JsFunction = fn() -> JsValue>(this: &Function<T>) -> JsString;
4578
4579    /// The `toString()` method returns a string representing the source code of the function.
4580    ///
4581    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/toString)
4582    #[cfg(not(js_sys_unstable_apis))]
4583    #[wasm_bindgen(method, js_name = toString)]
4584    pub fn to_string<T: JsFunction = fn() -> JsValue>(this: &Function<T>) -> JsString;
4585}
4586
4587// Basic UpcastFrom impls for Function<T>
4588impl<T: JsFunction> UpcastFrom<Function<T>> for JsValue {}
4589impl<T: JsFunction> UpcastFrom<Function<T>> for JsOption<JsValue> {}
4590impl<T: JsFunction> UpcastFrom<Function<T>> for JsNullable<JsValue> {}
4591impl<T: JsFunction> UpcastFrom<Function<T>> for Object {}
4592impl<T: JsFunction> UpcastFrom<Function<T>> for JsOption<Object> {}
4593impl<T: JsFunction> UpcastFrom<Function<T>> for JsNullable<Object> {}
4594
4595// Blanket trait for Function upcast
4596// Function<T> upcasts to Function<U> when the underlying fn type T upcasts to U.
4597// The fn signature UpcastFrom impls already encode correct variance (covariant return, contravariant args).
4598impl<T: JsFunction, U: JsFunction> UpcastFrom<Function<T>> for Function<U> where U: UpcastFrom<T> {}
4599
4600// len() method for Function<T> using JsFunction::ARITY
4601impl<T: JsFunction> Function<T> {
4602    /// Get the static arity of this function type.
4603    #[allow(clippy::len_without_is_empty)]
4604    pub fn len(&self) -> usize {
4605        T::ARITY
4606    }
4607
4608    /// Returns true if this is a zero-argument function.
4609    pub fn is_empty(&self) -> bool {
4610        T::ARITY == 0
4611    }
4612}
4613
4614// Base traits for function signature types.
4615pub trait JsFunction {
4616    type Ret: JsGeneric;
4617    const ARITY: usize;
4618}
4619
4620pub trait JsFunction1: JsFunction {
4621    type Arg1: JsGeneric;
4622    type Bind1: JsFunction;
4623}
4624pub trait JsFunction2: JsFunction1 {
4625    type Arg2: JsGeneric;
4626    type Bind2: JsFunction;
4627}
4628pub trait JsFunction3: JsFunction2 {
4629    type Arg3: JsGeneric;
4630    type Bind3: JsFunction;
4631}
4632pub trait JsFunction4: JsFunction3 {
4633    type Arg4: JsGeneric;
4634    type Bind4: JsFunction;
4635}
4636pub trait JsFunction5: JsFunction4 {
4637    type Arg5: JsGeneric;
4638    type Bind5: JsFunction;
4639}
4640pub trait JsFunction6: JsFunction5 {
4641    type Arg6: JsGeneric;
4642    type Bind6: JsFunction;
4643}
4644pub trait JsFunction7: JsFunction6 {
4645    type Arg7: JsGeneric;
4646    type Bind7: JsFunction;
4647}
4648pub trait JsFunction8: JsFunction7 {
4649    type Arg8: JsGeneric;
4650    type Bind8: JsFunction;
4651}
4652
4653// Manual impl for fn() -> R
4654impl<Ret: JsGeneric> JsFunction for fn() -> Ret {
4655    type Ret = Ret;
4656    const ARITY: usize = 0;
4657}
4658
4659macro_rules! impl_fn {
4660    () => {
4661        impl_fn!(@impl 1 [Arg1] [
4662            JsFunction1 Arg1 Bind1 {fn() -> Ret}
4663        ]);
4664        impl_fn!(@impl 2 [Arg1 Arg2] [
4665            JsFunction1 Arg1 Bind1 {fn(Arg2) -> Ret}
4666            JsFunction2 Arg2 Bind2 {fn() -> Ret}
4667        ]);
4668        impl_fn!(@impl 3 [Arg1 Arg2 Arg3] [
4669            JsFunction1 Arg1 Bind1 {fn(Arg2, Arg3) -> Ret}
4670            JsFunction2 Arg2 Bind2 {fn(Arg3) -> Ret}
4671            JsFunction3 Arg3 Bind3 {fn() -> Ret}
4672        ]);
4673        impl_fn!(@impl 4 [Arg1 Arg2 Arg3 Arg4] [
4674            JsFunction1 Arg1 Bind1 {fn(Arg2, Arg3, Arg4) -> Ret}
4675            JsFunction2 Arg2 Bind2 {fn(Arg3, Arg4) -> Ret}
4676            JsFunction3 Arg3 Bind3 {fn(Arg4) -> Ret}
4677            JsFunction4 Arg4 Bind4 {fn() -> Ret}
4678        ]);
4679        impl_fn!(@impl 5 [Arg1 Arg2 Arg3 Arg4 Arg5] [
4680            JsFunction1 Arg1 Bind1 {fn(Arg2, Arg3, Arg4, Arg5) -> Ret}
4681            JsFunction2 Arg2 Bind2 {fn(Arg3, Arg4, Arg5) -> Ret}
4682            JsFunction3 Arg3 Bind3 {fn(Arg4, Arg5) -> Ret}
4683            JsFunction4 Arg4 Bind4 {fn(Arg5) -> Ret}
4684            JsFunction5 Arg5 Bind5 {fn() -> Ret}
4685        ]);
4686        impl_fn!(@impl 6 [Arg1 Arg2 Arg3 Arg4 Arg5 Arg6] [
4687            JsFunction1 Arg1 Bind1 {fn(Arg2, Arg3, Arg4, Arg5, Arg6) -> Ret}
4688            JsFunction2 Arg2 Bind2 {fn(Arg3, Arg4, Arg5, Arg6) -> Ret}
4689            JsFunction3 Arg3 Bind3 {fn(Arg4, Arg5, Arg6) -> Ret}
4690            JsFunction4 Arg4 Bind4 {fn(Arg5, Arg6) -> Ret}
4691            JsFunction5 Arg5 Bind5 {fn(Arg6) -> Ret}
4692            JsFunction6 Arg6 Bind6 {fn() -> Ret}
4693        ]);
4694        impl_fn!(@impl 7 [Arg1 Arg2 Arg3 Arg4 Arg5 Arg6 Arg7] [
4695            JsFunction1 Arg1 Bind1 {fn(Arg2, Arg3, Arg4, Arg5, Arg6, Arg7) -> Ret}
4696            JsFunction2 Arg2 Bind2 {fn(Arg3, Arg4, Arg5, Arg6, Arg7) -> Ret}
4697            JsFunction3 Arg3 Bind3 {fn(Arg4, Arg5, Arg6, Arg7) -> Ret}
4698            JsFunction4 Arg4 Bind4 {fn(Arg5, Arg6, Arg7) -> Ret}
4699            JsFunction5 Arg5 Bind5 {fn(Arg6, Arg7) -> Ret}
4700            JsFunction6 Arg6 Bind6 {fn(Arg7) -> Ret}
4701            JsFunction7 Arg7 Bind7 {fn() -> Ret}
4702        ]);
4703        impl_fn!(@impl 8 [Arg1 Arg2 Arg3 Arg4 Arg5 Arg6 Arg7 Arg8] [
4704            JsFunction1 Arg1 Bind1 {fn(Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8) -> Ret}
4705            JsFunction2 Arg2 Bind2 {fn(Arg3, Arg4, Arg5, Arg6, Arg7, Arg8) -> Ret}
4706            JsFunction3 Arg3 Bind3 {fn(Arg4, Arg5, Arg6, Arg7, Arg8) -> Ret}
4707            JsFunction4 Arg4 Bind4 {fn(Arg5, Arg6, Arg7, Arg8) -> Ret}
4708            JsFunction5 Arg5 Bind5 {fn(Arg6, Arg7, Arg8) -> Ret}
4709            JsFunction6 Arg6 Bind6 {fn(Arg7, Arg8) -> Ret}
4710            JsFunction7 Arg7 Bind7 {fn(Arg8) -> Ret}
4711            JsFunction8 Arg8 Bind8 {fn() -> Ret}
4712        ]);
4713    };
4714
4715    (@impl $arity:literal [$($A:ident)+] [$($trait:ident $arg:ident $bind:ident {$bind_ty:ty})+]) => {
4716        impl<Ret: JsGeneric $(, $A: JsGeneric)+> JsFunction for fn($($A),+) -> Ret {
4717            type Ret = Ret;
4718            const ARITY: usize = $arity;
4719        }
4720
4721        impl_fn!(@traits [$($A)+] [$($trait $arg $bind {$bind_ty})+]);
4722    };
4723
4724    (@traits [$($A:ident)+] []) => {};
4725
4726    (@traits [$($A:ident)+] [$trait:ident $arg:ident $bind:ident {$bind_ty:ty} $($rest:tt)*]) => {
4727        impl<Ret: JsGeneric $(, $A: JsGeneric)+> $trait for fn($($A),+) -> Ret {
4728            type $arg = $arg;
4729            type $bind = $bind_ty;
4730        }
4731
4732        impl_fn!(@traits [$($A)+] [$($rest)*]);
4733    };
4734}
4735
4736impl_fn!();
4737
4738/// Trait for argument tuples that can call or bind a `Function<T>`.
4739pub trait JsArgs<T: JsFunction> {
4740    type BindOutput;
4741    fn apply_call(self, func: &Function<T>, context: &JsValue) -> Result<T::Ret, JsValue>;
4742    fn apply_bind(self, func: &Function<T>, context: &JsValue) -> Self::BindOutput;
4743}
4744
4745// Manual impl for 0-arg
4746impl<Ret: JsGeneric, F: JsFunction<Ret = Ret>> JsArgs<F> for () {
4747    type BindOutput = Function<F>;
4748
4749    #[inline]
4750    fn apply_call(self, func: &Function<F>, context: &JsValue) -> Result<Ret, JsValue> {
4751        func.call0(context)
4752    }
4753
4754    #[inline]
4755    fn apply_bind(self, func: &Function<F>, context: &JsValue) -> Self::BindOutput {
4756        func.bind0(context)
4757    }
4758}
4759
4760macro_rules! impl_js_args {
4761    ($arity:literal $trait:ident $bind_output:ident [$($A:ident)+] [$($idx:tt)+] $call:ident $bind:ident) => {
4762        impl<Ret: JsGeneric, $($A: JsGeneric,)+ F: $trait<Ret = Ret, $($A = $A,)*>> JsArgs<F> for ($(&$A,)+)
4763        {
4764            type BindOutput = Function<<F as $trait>::$bind_output>;
4765
4766            #[inline]
4767            fn apply_call(self, func: &Function<F>, context: &JsValue) -> Result<Ret, JsValue> {
4768                func.$call(context, $(self.$idx),+)
4769            }
4770
4771            #[inline]
4772            fn apply_bind(self, func: &Function<F>, context: &JsValue) -> Self::BindOutput {
4773                func.$bind(context, $(self.$idx),+)
4774            }
4775        }
4776    };
4777}
4778
4779impl_js_args!(1 JsFunction1 Bind1 [Arg1] [0] call1 bind1);
4780impl_js_args!(2 JsFunction2 Bind2 [Arg1 Arg2] [0 1] call2 bind2);
4781impl_js_args!(3 JsFunction3 Bind3 [Arg1 Arg2 Arg3] [0 1 2] call3 bind3);
4782impl_js_args!(4 JsFunction4 Bind4 [Arg1 Arg2 Arg3 Arg4] [0 1 2 3] call4 bind4);
4783impl_js_args!(5 JsFunction5 Bind5 [Arg1 Arg2 Arg3 Arg4 Arg5] [0 1 2 3 4] call5 bind5);
4784impl_js_args!(6 JsFunction6 Bind6 [Arg1 Arg2 Arg3 Arg4 Arg5 Arg6] [0 1 2 3 4 5] call6 bind6);
4785impl_js_args!(7 JsFunction7 Bind7 [Arg1 Arg2 Arg3 Arg4 Arg5 Arg6 Arg7] [0 1 2 3 4 5 6] call7 bind7);
4786impl_js_args!(8 JsFunction8 Bind8 [Arg1 Arg2 Arg3 Arg4 Arg5 Arg6 Arg7 Arg8] [0 1 2 3 4 5 6 7] call8 bind8);
4787
4788impl<T: JsFunction> Function<T> {
4789    /// The `call()` method calls a function with a given `this` value and
4790    /// arguments provided as a tuple.
4791    ///
4792    /// This method accepts a tuple of references matching the function's
4793    /// argument types.
4794    ///
4795    /// # Example
4796    ///
4797    /// ```ignore
4798    /// // 0-arg function
4799    /// let f: Function<fn() -> Number> = get_fn();
4800    /// let result = f.call(&JsValue::NULL, ())?;
4801    ///
4802    /// // 1-arg function (note trailing comma for 1-tuple)
4803    /// let f: Function<fn(JsString) -> Number> = get_fn();
4804    /// let result = f.call(&JsValue::NULL, (&name,))?;
4805    ///
4806    /// // 2-arg function
4807    /// let f: Function<fn(JsString, Boolean) -> Number> = get_fn();
4808    /// let result = f.call(&JsValue::NULL, (&name, &flag))?;
4809    /// ```
4810    ///
4811    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
4812    #[inline]
4813    pub fn call<Args: JsArgs<T>>(&self, context: &JsValue, args: Args) -> Result<T::Ret, JsValue> {
4814        args.apply_call(self, context)
4815    }
4816
4817    /// The `bind()` method creates a new function that, when called, has its
4818    /// `this` keyword set to the provided value, with a given sequence of
4819    /// arguments preceding any provided when the new function is called.
4820    ///
4821    /// This method accepts a tuple of references to bind.
4822    ///
4823    /// # Example
4824    ///
4825    /// ```ignore
4826    /// let f: Function<fn(JsString, Boolean) -> Number> = get_fn();
4827    ///
4828    /// // Bind no args - same signature
4829    /// let bound: Function<fn(JsString, Boolean) -> Number> = f.bind(&ctx, ());
4830    ///
4831    /// // Bind one arg (use 1-tuple of references)
4832    /// let bound: Function<fn(Boolean) -> Number> = f.bind(&ctx, (&my_string,));
4833    ///
4834    /// // Bind two args - becomes 0-arg function
4835    /// let bound: Function<fn() -> Number> = f.bind(&ctx, (&my_string, &my_bool));
4836    /// ```
4837    ///
4838    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
4839    #[inline]
4840    pub fn bindn<Args: JsArgs<T>>(&self, context: &JsValue, args: Args) -> Args::BindOutput {
4841        args.apply_bind(self, context)
4842    }
4843
4844    /// The `bind()` method creates a new function that, when called, has its
4845    /// `this` keyword set to the provided value, with a given sequence of
4846    /// arguments preceding any provided when the new function is called.
4847    ///
4848    /// This method accepts a tuple of references to bind.
4849    ///
4850    /// # Example
4851    ///
4852    /// ```ignore
4853    /// let f: Function<fn(JsString, Boolean) -> Number> = get_fn();
4854    ///
4855    /// // Bind no args - same signature
4856    /// let bound: Function<fn(JsString, Boolean) -> Number> = f.bind(&ctx, ());
4857    ///
4858    /// // Bind one arg (use 1-tuple of references)
4859    /// let bound: Function<fn(Boolean) -> Number> = f.bind(&ctx, (&my_string,));
4860    ///
4861    /// // Bind two args - becomes 0-arg function
4862    /// let bound: Function<fn() -> Number> = f.bind(&ctx, (&my_string, &my_bool));
4863    /// ```
4864    ///
4865    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
4866    #[cfg(js_sys_unstable_apis)]
4867    #[inline]
4868    pub fn bind<Args: JsArgs<T>>(&self, context: &JsValue, args: Args) -> Args::BindOutput {
4869        args.apply_bind(self, context)
4870    }
4871}
4872
4873pub trait FunctionIntoClosure: JsFunction {
4874    type ClosureTypeMut: WasmClosure + ?Sized;
4875}
4876
4877macro_rules! impl_function_into_closure {
4878    ( $(($($var:ident)*))* ) => {$(
4879        impl<$($var: FromWasmAbi + JsGeneric,)* R: IntoWasmAbi + JsGeneric> FunctionIntoClosure for fn($($var),*) -> R {
4880            type ClosureTypeMut = dyn FnMut($($var),*) -> R;
4881        }
4882    )*};
4883}
4884
4885impl_function_into_closure! {
4886    ()
4887    (A)
4888    (A B)
4889    (A B C)
4890    (A B C D)
4891    (A B C D E)
4892    (A B C D E F)
4893    (A B C D E F G)
4894    (A B C D E F G H)
4895}
4896
4897impl<F: JsFunction> Function<F> {
4898    /// Convert a borrowed `ScopedClosure` into a typed JavaScript Function reference.
4899    ///
4900    /// The conversion is a direct type-safe conversion and upcast of a
4901    /// closure into its corresponding typed JavaScript Function,
4902    /// based on covariance and contravariance [`Upcast`] trait hierarchy.
4903    ///
4904    /// For transferring ownership to JS, use [`Function::from_closure`].
4905    #[inline]
4906    pub fn closure_ref<'a, C>(closure: &'a ScopedClosure<'_, C>) -> &'a Self
4907    where
4908        F: FunctionIntoClosure,
4909        C: WasmClosure + ?Sized,
4910        <F as FunctionIntoClosure>::ClosureTypeMut: UpcastFrom<<C as WasmClosure>::AsMut>,
4911    {
4912        closure.as_js_value().unchecked_ref()
4913    }
4914
4915    /// Convert a Rust closure into a typed JavaScript Function.
4916    ///
4917    /// This function releases ownership of the closure to JS, and provides
4918    /// an owned function handle for the same closure.
4919    ///
4920    /// The conversion is a direct type-safe conversion and upcast of a
4921    /// closure into its corresponding typed JavaScript Function,
4922    /// based on covariance and contravariance [`Upcast`] trait hierarchy.
4923    ///
4924    /// This method is only supported for static closures which do not have
4925    /// borrowed lifetime data, and thus can be released into JS.
4926    ///
4927    /// For borrowed closures, which cannot cede ownership to JS,
4928    /// instead use [`Function::closure_ref`].
4929    #[inline]
4930    pub fn from_closure<C>(closure: ScopedClosure<'static, C>) -> Self
4931    where
4932        F: FunctionIntoClosure,
4933        C: WasmClosure + ?Sized,
4934        <F as FunctionIntoClosure>::ClosureTypeMut: UpcastFrom<<C as WasmClosure>::AsMut>,
4935    {
4936        closure.into_js_value().unchecked_into()
4937    }
4938}
4939
4940#[cfg(not(js_sys_unstable_apis))]
4941impl Function {
4942    /// Returns the `Function` value of this JS value if it's an instance of a
4943    /// function.
4944    ///
4945    /// If this JS value is not an instance of a function then this returns
4946    /// `None`.
4947    #[deprecated(note = "recommended to use dyn_ref instead which is now equivalent")]
4948    pub fn try_from(val: &JsValue) -> Option<&Function> {
4949        val.dyn_ref()
4950    }
4951}
4952
4953#[cfg(feature = "unsafe-eval")]
4954impl Default for Function {
4955    fn default() -> Self {
4956        Self::new_no_args("")
4957    }
4958}
4959
4960// FinalizationRegistry
4961#[wasm_bindgen]
4962extern "C" {
4963    /// The `FinalizationRegistry` object lets you request a callback when an
4964    /// object is garbage-collected.
4965    ///
4966    /// `FinalizationRegistry` provides a way to request that a cleanup
4967    /// callback get called at some point when an object registered with the
4968    /// registry has been reclaimed (garbage-collected). Cleanup callbacks
4969    /// are sometimes called *finalizers*.
4970    ///
4971    /// Avoid where possible: cleanup callbacks should not be relied upon for
4972    /// anything essential. They are best used to reduce memory usage over the
4973    /// course of a program for objects that benefit from cleanup. Whether,
4974    /// when, and in what order callbacks fire is implementation-defined.
4975    ///
4976    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/FinalizationRegistry)
4977    #[wasm_bindgen(extends = Object, typescript_type = "FinalizationRegistry<any>")]
4978    #[derive(Clone, Debug, PartialEq, Eq)]
4979    pub type FinalizationRegistry;
4980
4981    /// Creates a new `FinalizationRegistry` with the given cleanup callback.
4982    ///
4983    /// The cleanup callback is invoked, at some point after a registered
4984    /// target is garbage-collected, with the `held_value` that was passed to
4985    /// [`FinalizationRegistry::register`]. Because callbacks may be deferred
4986    /// or skipped entirely, the callback should normally outlive the
4987    /// `FinalizationRegistry` (for example by being created via
4988    /// [`Function::from_closure`]).
4989    ///
4990    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/FinalizationRegistry/FinalizationRegistry)
4991    #[wasm_bindgen(constructor)]
4992    pub fn new(cleanup_callback: &Function<fn(JsValue) -> Undefined>) -> FinalizationRegistry;
4993
4994    /// Registers `target` with this `FinalizationRegistry`. When `target` is
4995    /// reclaimed by the garbage collector the cleanup callback may be called
4996    /// with `held_value`.
4997    ///
4998    /// `target` must be an object (or a non-registered symbol).
4999    ///
5000    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/FinalizationRegistry/register)
5001    #[wasm_bindgen(method)]
5002    pub fn register(this: &FinalizationRegistry, target: &JsValue, held_value: &JsValue);
5003
5004    /// Registers `target` with this `FinalizationRegistry`, with an
5005    /// `unregister_token` that can later be passed to
5006    /// [`FinalizationRegistry::unregister`] to remove the registration.
5007    ///
5008    /// `target` and `unregister_token` must be objects (or non-registered
5009    /// symbols), and the same value may be passed for both.
5010    ///
5011    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/FinalizationRegistry/register)
5012    #[wasm_bindgen(method, js_name = register)]
5013    pub fn register_with_token(
5014        this: &FinalizationRegistry,
5015        target: &JsValue,
5016        held_value: &JsValue,
5017        unregister_token: &JsValue,
5018    );
5019
5020    /// Unregisters all entries registered with this `FinalizationRegistry`
5021    /// using `unregister_token`. Returns `true` if any cells were removed.
5022    ///
5023    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/FinalizationRegistry/unregister)
5024    #[wasm_bindgen(method)]
5025    pub fn unregister(this: &FinalizationRegistry, unregister_token: &JsValue) -> bool;
5026}
5027
5028// Generator
5029#[wasm_bindgen]
5030extern "C" {
5031    #[wasm_bindgen(extends = Object, typescript_type = "Generator<any, any, any>")]
5032    #[derive(Clone, Debug, PartialEq, Eq)]
5033    pub type Generator<T = JsValue>;
5034
5035    /// The `next()` method returns an object with two properties done and value.
5036    /// You can also provide a parameter to the next method to send a value to the generator.
5037    ///
5038    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/next)
5039    #[cfg(not(js_sys_unstable_apis))]
5040    #[wasm_bindgen(method, catch)]
5041    pub fn next<T>(this: &Generator<T>, value: &T) -> Result<JsValue, JsValue>;
5042
5043    /// The `next()` method returns an object with two properties done and value.
5044    /// You can also provide a parameter to the next method to send a value to the generator.
5045    ///
5046    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/next)
5047    #[cfg(js_sys_unstable_apis)]
5048    #[wasm_bindgen(method, catch, js_name = next)]
5049    pub fn next<T: FromWasmAbi>(this: &Generator<T>, value: &T)
5050        -> Result<IteratorNext<T>, JsValue>;
5051
5052    // Next major: deprecate
5053    /// The `next()` method returns an object with two properties done and value.
5054    /// You can also provide a parameter to the next method to send a value to the generator.
5055    ///
5056    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/next)
5057    #[wasm_bindgen(method, catch)]
5058    pub fn next_iterator<T: FromWasmAbi>(
5059        this: &Generator<T>,
5060        value: &T,
5061    ) -> Result<IteratorNext<T>, JsValue>;
5062
5063    /// The `return()` method returns the given value and finishes the generator.
5064    ///
5065    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/return)
5066    #[cfg(not(js_sys_unstable_apis))]
5067    #[wasm_bindgen(method, js_name = "return")]
5068    pub fn return_<T>(this: &Generator<T>, value: &T) -> JsValue;
5069
5070    /// The `return()` method returns the given value and finishes the generator.
5071    ///
5072    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/return)
5073    #[cfg(js_sys_unstable_apis)]
5074    #[wasm_bindgen(method, catch, js_name = "return")]
5075    pub fn return_<T: FromWasmAbi>(
5076        this: &Generator<T>,
5077        value: &T,
5078    ) -> Result<IteratorNext<T>, JsValue>;
5079
5080    // Next major: deprecate
5081    /// The `return()` method returns the given value and finishes the generator.
5082    ///
5083    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/return)
5084    #[wasm_bindgen(method, catch, js_name = "return")]
5085    pub fn try_return<T: FromWasmAbi>(
5086        this: &Generator<T>,
5087        value: &T,
5088    ) -> Result<IteratorNext<T>, JsValue>;
5089
5090    /// The `throw()` method resumes the execution of a generator by throwing an error into it
5091    /// and returns an object with two properties done and value.
5092    ///
5093    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/throw)
5094    #[cfg(not(js_sys_unstable_apis))]
5095    #[wasm_bindgen(method, catch)]
5096    pub fn throw<T>(this: &Generator<T>, error: &Error) -> Result<JsValue, JsValue>;
5097
5098    /// The `throw()` method resumes the execution of a generator by throwing an error into it
5099    /// and returns an object with two properties done and value.
5100    ///
5101    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/throw)
5102    #[cfg(js_sys_unstable_apis)]
5103    #[wasm_bindgen(method, catch, js_name = throw)]
5104    pub fn throw<T: FromWasmAbi>(
5105        this: &Generator<T>,
5106        error: &JsValue,
5107    ) -> Result<IteratorNext<T>, JsValue>;
5108
5109    // Next major: deprecate
5110    /// The `throw()` method resumes the execution of a generator by throwing an error into it
5111    /// and returns an object with two properties done and value.
5112    ///
5113    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/throw)
5114    #[wasm_bindgen(method, catch, js_name = throw)]
5115    pub fn throw_value<T: FromWasmAbi>(
5116        this: &Generator<T>,
5117        error: &JsValue,
5118    ) -> Result<IteratorNext<T>, JsValue>;
5119}
5120
5121impl<T: FromWasmAbi> Iterable for Generator<T> {
5122    type Item = T;
5123}
5124
5125// AsyncGenerator
5126#[wasm_bindgen]
5127extern "C" {
5128    #[wasm_bindgen(extends = Object, typescript_type = "AsyncGenerator<any, any, any>")]
5129    #[derive(Clone, Debug, PartialEq, Eq)]
5130    pub type AsyncGenerator<T = JsValue>;
5131
5132    /// The `next()` method returns an object with two properties done and value.
5133    /// You can also provide a parameter to the next method to send a value to the generator.
5134    ///
5135    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncGenerator/next)
5136    #[wasm_bindgen(method, catch)]
5137    pub fn next<T>(
5138        this: &AsyncGenerator<T>,
5139        value: &T,
5140    ) -> Result<Promise<IteratorNext<T>>, JsValue>;
5141
5142    /// The `return()` method returns the given value and finishes the generator.
5143    ///
5144    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncGenerator/return)
5145    #[wasm_bindgen(method, js_name = "return", catch)]
5146    pub fn return_<T>(
5147        this: &AsyncGenerator<T>,
5148        value: &T,
5149    ) -> Result<Promise<IteratorNext<T>>, JsValue>;
5150
5151    /// The `throw()` method resumes the execution of a generator by throwing an error into it
5152    /// and returns an object with two properties done and value.
5153    ///
5154    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncGenerator/throw)
5155    #[wasm_bindgen(method, catch)]
5156    pub fn throw<T>(
5157        this: &AsyncGenerator<T>,
5158        error: &JsValue,
5159    ) -> Result<Promise<IteratorNext<T>>, JsValue>;
5160}
5161
5162impl<T: FromWasmAbi> AsyncIterable for AsyncGenerator<T> {
5163    type Item = T;
5164}
5165
5166// Map
5167#[wasm_bindgen]
5168extern "C" {
5169    #[wasm_bindgen(extends = Object, typescript_type = "Map<any, any>")]
5170    #[derive(Clone, Debug, PartialEq, Eq)]
5171    pub type Map<K = JsValue, V = JsValue>;
5172
5173    /// The Map object holds key-value pairs. Any value (both objects and
5174    /// primitive values) maybe used as either a key or a value.
5175    ///
5176    /// **Note:** Consider using [`Map::new_typed`] for typing support.
5177    ///
5178    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map)
5179    #[cfg(not(js_sys_unstable_apis))]
5180    #[wasm_bindgen(constructor)]
5181    pub fn new() -> Map;
5182
5183    /// The Map object holds key-value pairs. Any value (both objects and
5184    /// primitive values) maybe used as either a key or a value.
5185    ///
5186    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map)
5187    #[cfg(js_sys_unstable_apis)]
5188    #[wasm_bindgen(constructor)]
5189    pub fn new<K, V>() -> Map<K, V>;
5190
5191    // Next major: deprecate
5192    /// The Map object holds key-value pairs. Any value (both objects and
5193    /// primitive values) maybe used as either a key or a value.
5194    ///
5195    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map)
5196    #[wasm_bindgen(constructor)]
5197    pub fn new_typed<K, V>() -> Map<K, V>;
5198
5199    /// The Map object holds key-value pairs. Any value (both objects and
5200    /// primitive values) maybe used as either a key or a value.
5201    ///
5202    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map)
5203    #[wasm_bindgen(constructor, js_name = new)]
5204    pub fn new_from_entries<K, V, I: Iterable<Item = ArrayTuple<(K, V)>>>(entries: &I)
5205        -> Map<K, V>;
5206
5207    /// The `clear()` method removes all elements from a Map object.
5208    ///
5209    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/clear)
5210    #[wasm_bindgen(method)]
5211    pub fn clear<K, V>(this: &Map<K, V>);
5212
5213    /// The `delete()` method removes the specified element from a Map object.
5214    ///
5215    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/delete)
5216    #[wasm_bindgen(method)]
5217    pub fn delete<K, V>(this: &Map<K, V>, key: &K) -> bool;
5218
5219    /// The `forEach()` method executes a provided function once per each
5220    /// key/value pair in the Map object, in insertion order.
5221    /// Note that in Javascript land the `Key` and `Value` are reversed compared to normal expectations:
5222    /// # Examples
5223    /// ```
5224    /// let js_map = Map::new();
5225    /// js_map.for_each(&mut |value, key| {
5226    ///     // Do something here...
5227    /// })
5228    /// ```
5229    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/forEach)
5230    #[wasm_bindgen(method, js_name = forEach)]
5231    pub fn for_each<K, V>(this: &Map<K, V>, callback: &mut dyn FnMut(V, K));
5232
5233    /// The `forEach()` method executes a provided function once per each
5234    /// key/value pair in the Map object, in insertion order. _(Fallible variation)_
5235    /// Note that in Javascript land the `Key` and `Value` are reversed compared to normal expectations:
5236    /// # Examples
5237    /// ```
5238    /// let js_map = Map::new();
5239    /// js_map.for_each(&mut |value, key| {
5240    ///     // Do something here...
5241    /// })
5242    /// ```
5243    ///
5244    /// **Note:** Consider using [`Map::try_for_each`] if the callback might throw an error.
5245    ///
5246    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/forEach)
5247    #[wasm_bindgen(method, js_name = forEach, catch)]
5248    pub fn try_for_each<K, V>(
5249        this: &Map<K, V>,
5250        callback: &mut dyn FnMut(V, K) -> Result<(), JsError>,
5251    ) -> Result<(), JsValue>;
5252
5253    /// The `get()` method returns a specified element from a Map object.
5254    /// Returns `undefined` if the key is not found.
5255    ///
5256    /// **Note:** Consider using [`Map::get_checked`] to get an `Option<V>` instead.
5257    ///
5258    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/get)
5259    #[cfg(not(js_sys_unstable_apis))]
5260    #[wasm_bindgen(method)]
5261    pub fn get<K, V>(this: &Map<K, V>, key: &K) -> V;
5262
5263    /// The `get()` method returns a specified element from a Map object.
5264    /// Returns `None` if the key is not found.
5265    ///
5266    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/get)
5267    #[cfg(js_sys_unstable_apis)]
5268    #[wasm_bindgen(method)]
5269    pub fn get<K, V>(this: &Map<K, V>, key: &K) -> Option<V>;
5270
5271    /// The `get()` method returns a specified element from a Map object.
5272    /// Returns `None` if the key is not found.
5273    ///
5274    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/get)
5275    #[wasm_bindgen(method, js_name = get)]
5276    pub fn get_checked<K, V>(this: &Map<K, V>, key: &K) -> Option<V>;
5277
5278    /// The `has()` method returns a boolean indicating whether an element with
5279    /// the specified key exists or not.
5280    ///
5281    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/has)
5282    #[wasm_bindgen(method)]
5283    pub fn has<K, V>(this: &Map<K, V>, key: &K) -> bool;
5284
5285    /// The `set()` method adds or updates an element with a specified key
5286    /// and value to a Map object.
5287    ///
5288    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/set)
5289    #[wasm_bindgen(method)]
5290    pub fn set<K, V>(this: &Map<K, V>, key: &K, value: &V) -> Map<K, V>;
5291
5292    /// The value of size is an integer representing how many entries
5293    /// the Map object has. A set accessor function for size is undefined;
5294    /// you can not change this property.
5295    ///
5296    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/size)
5297    #[wasm_bindgen(method, getter)]
5298    pub fn size<K, V>(this: &Map<K, V>) -> u32;
5299}
5300
5301impl Default for Map<JsValue, JsValue> {
5302    fn default() -> Self {
5303        Self::new()
5304    }
5305}
5306
5307// Map Iterator
5308#[wasm_bindgen]
5309extern "C" {
5310    /// The `entries()` method returns a new Iterator object that contains
5311    /// the [key, value] pairs for each element in the Map object in
5312    /// insertion order.
5313    ///
5314    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/entries)
5315    #[cfg(not(js_sys_unstable_apis))]
5316    #[wasm_bindgen(method)]
5317    pub fn entries<K, V: FromWasmAbi>(this: &Map<K, V>) -> Iterator;
5318
5319    /// The `entries()` method returns a new Iterator object that contains
5320    /// the [key, value] pairs for each element in the Map object in
5321    /// insertion order.
5322    ///
5323    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/entries)
5324    #[cfg(js_sys_unstable_apis)]
5325    #[wasm_bindgen(method, js_name = entries)]
5326    pub fn entries<K: JsGeneric, V: FromWasmAbi + JsGeneric>(
5327        this: &Map<K, V>,
5328    ) -> Iterator<ArrayTuple<(K, V)>>;
5329
5330    // Next major: deprecate
5331    /// The `entries()` method returns a new Iterator object that contains
5332    /// the [key, value] pairs for each element in the Map object in
5333    /// insertion order.
5334    ///
5335    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/entries)
5336    #[wasm_bindgen(method, js_name = entries)]
5337    pub fn entries_typed<K: JsGeneric, V: FromWasmAbi + JsGeneric>(
5338        this: &Map<K, V>,
5339    ) -> Iterator<ArrayTuple<(K, V)>>;
5340
5341    /// The `keys()` method returns a new Iterator object that contains the
5342    /// keys for each element in the Map object in insertion order.
5343    ///
5344    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/keys)
5345    #[wasm_bindgen(method)]
5346    pub fn keys<K: FromWasmAbi, V: FromWasmAbi>(this: &Map<K, V>) -> Iterator<K>;
5347
5348    /// The `values()` method returns a new Iterator object that contains the
5349    /// values for each element in the Map object in insertion order.
5350    ///
5351    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/values)
5352    #[wasm_bindgen(method)]
5353    pub fn values<K, V: FromWasmAbi>(this: &Map<K, V>) -> Iterator<V>;
5354}
5355
5356impl<K, V> Iterable for Map<K, V> {
5357    type Item = ArrayTuple<(K, V)>;
5358}
5359
5360// Iterator
5361#[wasm_bindgen]
5362extern "C" {
5363    /// Any object that conforms to the JS iterator protocol. For example,
5364    /// something returned by `myArray[Symbol.iterator]()`.
5365    ///
5366    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols)
5367    #[derive(Clone, Debug)]
5368    #[wasm_bindgen(is_type_of = Iterator::looks_like_iterator, typescript_type = "Iterator<any>")]
5369    pub type Iterator<T = JsValue>;
5370
5371    /// The `next()` method always has to return an object with appropriate
5372    /// properties including done and value. If a non-object value gets returned
5373    /// (such as false or undefined), a TypeError ("iterator.next() returned a
5374    /// non-object value") will be thrown.
5375    #[wasm_bindgen(catch, method)]
5376    pub fn next<T: FromWasmAbi>(this: &Iterator<T>) -> Result<IteratorNext<T>, JsValue>;
5377}
5378
5379impl<T> UpcastFrom<Iterator<T>> for Object {}
5380
5381impl Iterator {
5382    fn looks_like_iterator(it: &JsValue) -> bool {
5383        #[wasm_bindgen]
5384        extern "C" {
5385            #[derive(Clone, Debug)]
5386            type MaybeIterator;
5387
5388            #[wasm_bindgen(method, getter)]
5389            fn next(this: &MaybeIterator) -> JsValue;
5390        }
5391
5392        if !it.is_object() {
5393            return false;
5394        }
5395
5396        let it = it.unchecked_ref::<MaybeIterator>();
5397
5398        it.next().is_function()
5399    }
5400}
5401
5402// iterators in JS are themselves iterable
5403impl<T> Iterable for Iterator<T> {
5404    type Item = T;
5405}
5406
5407// Async Iterator
5408#[wasm_bindgen]
5409extern "C" {
5410    /// Any object that conforms to the JS async iterator protocol. For example,
5411    /// something returned by `myObject[Symbol.asyncIterator]()`.
5412    ///
5413    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of)
5414    #[derive(Clone, Debug)]
5415    #[wasm_bindgen(is_type_of = Iterator::looks_like_iterator, typescript_type = "AsyncIterator<any>")]
5416    pub type AsyncIterator<T = JsValue>;
5417
5418    /// The `next()` method always has to return a Promise which resolves to an object
5419    /// with appropriate properties including done and value. If a non-object value
5420    /// gets returned (such as false or undefined), a TypeError ("iterator.next()
5421    /// returned a non-object value") will be thrown.
5422    #[cfg(not(js_sys_unstable_apis))]
5423    #[wasm_bindgen(catch, method)]
5424    pub fn next<T>(this: &AsyncIterator<T>) -> Result<Promise, JsValue>;
5425
5426    /// The `next()` method always has to return a Promise which resolves to an object
5427    /// with appropriate properties including done and value. If a non-object value
5428    /// gets returned (such as false or undefined), a TypeError ("iterator.next()
5429    /// returned a non-object value") will be thrown.
5430    #[cfg(js_sys_unstable_apis)]
5431    #[wasm_bindgen(catch, method, js_name = next)]
5432    pub fn next<T: FromWasmAbi>(
5433        this: &AsyncIterator<T>,
5434    ) -> Result<Promise<IteratorNext<T>>, JsValue>;
5435
5436    // Next major: deprecate
5437    /// The `next()` method always has to return a Promise which resolves to an object
5438    /// with appropriate properties including done and value. If a non-object value
5439    /// gets returned (such as false or undefined), a TypeError ("iterator.next()
5440    /// returned a non-object value") will be thrown.
5441    #[wasm_bindgen(catch, method, js_name = next)]
5442    pub fn next_iterator<T: FromWasmAbi>(
5443        this: &AsyncIterator<T>,
5444    ) -> Result<Promise<IteratorNext<T>>, JsValue>;
5445}
5446
5447impl<T> UpcastFrom<AsyncIterator<T>> for Object {}
5448
5449// iterators in JS are themselves iterable
5450impl<T> AsyncIterable for AsyncIterator<T> {
5451    type Item = T;
5452}
5453
5454/// An iterator over the JS `Symbol.iterator` iteration protocol.
5455///
5456/// Use the `IntoIterator for &js_sys::Iterator` implementation to create this.
5457pub struct Iter<'a, T = JsValue> {
5458    js: &'a Iterator<T>,
5459    state: IterState,
5460}
5461
5462/// An iterator over the JS `Symbol.iterator` iteration protocol.
5463///
5464/// Use the `IntoIterator for js_sys::Iterator` implementation to create this.
5465pub struct IntoIter<T = JsValue> {
5466    js: Iterator<T>,
5467    state: IterState,
5468}
5469
5470struct IterState {
5471    done: bool,
5472}
5473
5474impl<'a, T: FromWasmAbi + JsGeneric> IntoIterator for &'a Iterator<T> {
5475    type Item = Result<T, JsValue>;
5476    type IntoIter = Iter<'a, T>;
5477
5478    fn into_iter(self) -> Iter<'a, T> {
5479        Iter {
5480            js: self,
5481            state: IterState::new(),
5482        }
5483    }
5484}
5485
5486impl<T: FromWasmAbi + JsGeneric> core::iter::Iterator for Iter<'_, T> {
5487    type Item = Result<T, JsValue>;
5488
5489    fn next(&mut self) -> Option<Self::Item> {
5490        self.state.next(self.js)
5491    }
5492}
5493
5494impl<T: FromWasmAbi + JsGeneric> IntoIterator for Iterator<T> {
5495    type Item = Result<T, JsValue>;
5496    type IntoIter = IntoIter<T>;
5497
5498    fn into_iter(self) -> IntoIter<T> {
5499        IntoIter {
5500            js: self,
5501            state: IterState::new(),
5502        }
5503    }
5504}
5505
5506impl<T: FromWasmAbi + JsGeneric> core::iter::Iterator for IntoIter<T> {
5507    type Item = Result<T, JsValue>;
5508
5509    fn next(&mut self) -> Option<Self::Item> {
5510        self.state.next(&self.js)
5511    }
5512}
5513
5514impl IterState {
5515    fn new() -> IterState {
5516        IterState { done: false }
5517    }
5518
5519    fn next<T: FromWasmAbi + JsGeneric>(&mut self, js: &Iterator<T>) -> Option<Result<T, JsValue>> {
5520        if self.done {
5521            return None;
5522        }
5523        let next = match js.next() {
5524            Ok(val) => val,
5525            Err(e) => {
5526                self.done = true;
5527                return Some(Err(e));
5528            }
5529        };
5530        if next.done() {
5531            self.done = true;
5532            None
5533        } else {
5534            Some(Ok(next.value()))
5535        }
5536    }
5537}
5538
5539/// Create an iterator over `val` using the JS iteration protocol and
5540/// `Symbol.iterator`.
5541// #[cfg(not(js_sys_unstable_apis))]
5542pub fn try_iter(val: &JsValue) -> Result<Option<IntoIter<JsValue>>, JsValue> {
5543    let iter_sym = Symbol::iterator();
5544
5545    let iter_fn = Reflect::get_symbol::<Object>(val.unchecked_ref(), iter_sym.as_ref())?;
5546    let iter_fn: Function = match iter_fn.dyn_into() {
5547        Ok(iter_fn) => iter_fn,
5548        Err(_) => return Ok(None),
5549    };
5550
5551    let it: Iterator = match iter_fn.call0(val)?.dyn_into() {
5552        Ok(it) => it,
5553        Err(_) => return Ok(None),
5554    };
5555
5556    Ok(Some(it.into_iter()))
5557}
5558
5559/// Trait for JavaScript types that implement the iterable protocol via `Symbol.iterator`.
5560///
5561/// Types implementing this trait can be iterated over using JavaScript's iteration
5562/// protocol. The `Item` associated type specifies the type of values yielded.
5563///
5564/// ## Built-in Iterables
5565///
5566/// Many `js-sys` collection types implement `Iterable` out of the box:
5567///
5568/// ```ignore
5569/// use js_sys::{Array, Map, Set};
5570///
5571/// // Array<T> yields T
5572/// let arr: Array<Number> = get_numbers();
5573/// for value in arr.iter() {
5574///     let num: Number = value?;
5575/// }
5576///
5577/// // Map<K, V> yields Array (key-value pairs)
5578/// let map: Map<JsString, Number> = get_map();
5579/// for entry in map.iter() {
5580///     let pair: Array = entry?;
5581/// }
5582///
5583/// // Set<T> yields T
5584/// let set: Set<JsString> = get_set();
5585/// for value in set.iter() {
5586///     let s: JsString = value?;
5587/// }
5588/// ```
5589///
5590/// ## Typing Foreign Iterators
5591///
5592/// If you have a JavaScript value that implements the iterator protocol (has a `next()`
5593/// method) but isn't a built-in type, you can use [`JsCast`] to cast it to [`Iterator<T>`]:
5594///
5595/// ```ignore
5596/// use js_sys::Iterator;
5597/// use wasm_bindgen::JsCast;
5598///
5599/// // For a value you know implements the iterator protocol
5600/// fn process_iterator(js_iter: JsValue) {
5601///     // Checked cast - returns None if not an iterator
5602///     if let Some(iter) = js_iter.dyn_ref::<Iterator<Number>>() {
5603///         for value in iter.into_iter() {
5604///             let num: Number = value.unwrap();
5605///             // ...
5606///         }
5607///     }
5608/// }
5609///
5610/// // Or with unchecked cast when you're certain of the type
5611/// fn process_known_iterator(js_iter: JsValue) {
5612///     let iter: &Iterator<JsString> = js_iter.unchecked_ref();
5613///     for value in iter.into_iter() {
5614///         let s: JsString = value.unwrap();
5615///         // ...
5616///     }
5617/// }
5618/// ```
5619///
5620/// ## Using with `JsValue`
5621///
5622/// For dynamic or unknown iterables, use [`try_iter`] which returns an untyped iterator:
5623///
5624/// ```ignore
5625/// fn iterate_unknown(val: &JsValue) -> Result<(), JsValue> {
5626///     if let Some(iter) = js_sys::try_iter(val)? {
5627///         for item in iter {
5628///             let value: JsValue = item?;
5629///             // Handle dynamically...
5630///         }
5631///     }
5632///     Ok(())
5633/// }
5634/// ```
5635///
5636/// [`JsCast`]: wasm_bindgen::JsCast
5637/// [`Iterator<T>`]: Iterator
5638/// [`try_iter`]: crate::try_iter
5639pub trait Iterable {
5640    /// The type of values yielded by this iterable.
5641    type Item;
5642}
5643
5644impl<T: Iterable> Iterable for &T {
5645    type Item = T::Item;
5646}
5647
5648/// Trait for types known to implement the iterator protocol on Symbol.asyncIterator
5649pub trait AsyncIterable {
5650    type Item;
5651}
5652
5653impl<T: AsyncIterable> AsyncIterable for &T {
5654    type Item = T::Item;
5655}
5656
5657impl AsyncIterable for JsValue {
5658    type Item = JsValue;
5659}
5660
5661// IteratorNext
5662#[wasm_bindgen]
5663extern "C" {
5664    /// The result of calling `next()` on a JS iterator.
5665    ///
5666    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols)
5667    #[wasm_bindgen(extends = Object, typescript_type = "IteratorResult<any>")]
5668    #[derive(Clone, Debug, PartialEq, Eq)]
5669    pub type IteratorNext<T = JsValue>;
5670
5671    /// Has the value `true` if the iterator is past the end of the iterated
5672    /// sequence. In this case value optionally specifies the return value of
5673    /// the iterator.
5674    ///
5675    /// Has the value `false` if the iterator was able to produce the next value
5676    /// in the sequence. This is equivalent of not specifying the done property
5677    /// altogether.
5678    #[wasm_bindgen(method, getter)]
5679    pub fn done<T>(this: &IteratorNext<T>) -> bool;
5680
5681    /// Any JavaScript value returned by the iterator. Can be omitted when done
5682    /// is true.
5683    #[wasm_bindgen(method, getter)]
5684    pub fn value<T>(this: &IteratorNext<T>) -> T;
5685}
5686
5687#[allow(non_snake_case)]
5688pub mod Math {
5689    use super::*;
5690
5691    // Math
5692    #[wasm_bindgen]
5693    extern "C" {
5694        /// The `Math.abs()` function returns the absolute value of a number, that is
5695        /// Math.abs(x) = |x|
5696        ///
5697        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/abs)
5698        #[wasm_bindgen(js_namespace = Math)]
5699        pub fn abs(x: f64) -> f64;
5700
5701        /// The `Math.acos()` function returns the arccosine (in radians) of a
5702        /// number, that is ∀x∊[-1;1]
5703        /// Math.acos(x) = arccos(x) = the unique y∊[0;π] such that cos(y)=x
5704        ///
5705        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/acos)
5706        #[wasm_bindgen(js_namespace = Math)]
5707        pub fn acos(x: f64) -> f64;
5708
5709        /// The `Math.acosh()` function returns the hyperbolic arc-cosine of a
5710        /// number, that is ∀x ≥ 1
5711        /// Math.acosh(x) = arcosh(x) = the unique y ≥ 0 such that cosh(y) = x
5712        ///
5713        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/acosh)
5714        #[wasm_bindgen(js_namespace = Math)]
5715        pub fn acosh(x: f64) -> f64;
5716
5717        /// The `Math.asin()` function returns the arcsine (in radians) of a
5718        /// number, that is ∀x ∊ [-1;1]
5719        /// Math.asin(x) = arcsin(x) = the unique y∊[-π2;π2] such that sin(y) = x
5720        ///
5721        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/asin)
5722        #[wasm_bindgen(js_namespace = Math)]
5723        pub fn asin(x: f64) -> f64;
5724
5725        /// The `Math.asinh()` function returns the hyperbolic arcsine of a
5726        /// number, that is Math.asinh(x) = arsinh(x) = the unique y such that sinh(y) = x
5727        ///
5728        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/asinh)
5729        #[wasm_bindgen(js_namespace = Math)]
5730        pub fn asinh(x: f64) -> f64;
5731
5732        /// The `Math.atan()` function returns the arctangent (in radians) of a
5733        /// number, that is Math.atan(x) = arctan(x) = the unique y ∊ [-π2;π2]such that
5734        /// tan(y) = x
5735        #[wasm_bindgen(js_namespace = Math)]
5736        pub fn atan(x: f64) -> f64;
5737
5738        /// The `Math.atan2()` function returns the arctangent of the quotient of
5739        /// its arguments.
5740        ///
5741        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atan2)
5742        #[wasm_bindgen(js_namespace = Math)]
5743        pub fn atan2(y: f64, x: f64) -> f64;
5744
5745        /// The `Math.atanh()` function returns the hyperbolic arctangent of a number,
5746        /// that is ∀x ∊ (-1,1), Math.atanh(x) = arctanh(x) = the unique y such that
5747        /// tanh(y) = x
5748        ///
5749        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atanh)
5750        #[wasm_bindgen(js_namespace = Math)]
5751        pub fn atanh(x: f64) -> f64;
5752
5753        /// The `Math.cbrt() `function returns the cube root of a number, that is
5754        /// Math.cbrt(x) = ∛x = the unique y such that y^3 = x
5755        ///
5756        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cbrt)
5757        #[wasm_bindgen(js_namespace = Math)]
5758        pub fn cbrt(x: f64) -> f64;
5759
5760        /// The `Math.ceil()` function returns the smallest integer greater than
5761        /// or equal to a given number.
5762        ///
5763        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/ceil)
5764        #[wasm_bindgen(js_namespace = Math)]
5765        pub fn ceil(x: f64) -> f64;
5766
5767        /// The `Math.clz32()` function returns the number of leading zero bits in
5768        /// the 32-bit binary representation of a number.
5769        ///
5770        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/clz32)
5771        #[wasm_bindgen(js_namespace = Math)]
5772        pub fn clz32(x: i32) -> u32;
5773
5774        /// The `Math.cos()` static function returns the cosine of the specified angle,
5775        /// which must be specified in radians. This value is length(adjacent)/length(hypotenuse).
5776        ///
5777        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cos)
5778        #[wasm_bindgen(js_namespace = Math)]
5779        pub fn cos(x: f64) -> f64;
5780
5781        /// The `Math.cosh()` function returns the hyperbolic cosine of a number,
5782        /// that can be expressed using the constant e.
5783        ///
5784        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cosh)
5785        #[wasm_bindgen(js_namespace = Math)]
5786        pub fn cosh(x: f64) -> f64;
5787
5788        /// The `Math.exp()` function returns e^x, where x is the argument, and e is Euler's number
5789        /// (also known as Napier's constant), the base of the natural logarithms.
5790        ///
5791        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/exp)
5792        #[wasm_bindgen(js_namespace = Math)]
5793        pub fn exp(x: f64) -> f64;
5794
5795        /// The `Math.expm1()` function returns e^x - 1, where x is the argument, and e the base of the
5796        /// natural logarithms.
5797        ///
5798        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/expm1)
5799        #[wasm_bindgen(js_namespace = Math)]
5800        pub fn expm1(x: f64) -> f64;
5801
5802        /// The `Math.floor()` function returns the largest integer less than or
5803        /// equal to a given number.
5804        ///
5805        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/floor)
5806        #[wasm_bindgen(js_namespace = Math)]
5807        pub fn floor(x: f64) -> f64;
5808
5809        /// The `Math.fround()` function returns the nearest 32-bit single precision float representation
5810        /// of a Number.
5811        ///
5812        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/fround)
5813        #[wasm_bindgen(js_namespace = Math)]
5814        pub fn fround(x: f64) -> f32;
5815
5816        /// The `Math.hypot()` function returns the square root of the sum of squares of its arguments.
5817        ///
5818        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/hypot)
5819        #[wasm_bindgen(js_namespace = Math)]
5820        pub fn hypot(x: f64, y: f64) -> f64;
5821
5822        /// The `Math.imul()` function returns the result of the C-like 32-bit multiplication of the
5823        /// two parameters.
5824        ///
5825        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul)
5826        #[wasm_bindgen(js_namespace = Math)]
5827        pub fn imul(x: i32, y: i32) -> i32;
5828
5829        /// The `Math.log()` function returns the natural logarithm (base e) of a number.
5830        /// The JavaScript `Math.log()` function is equivalent to ln(x) in mathematics.
5831        ///
5832        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log)
5833        #[wasm_bindgen(js_namespace = Math)]
5834        pub fn log(x: f64) -> f64;
5835
5836        /// The `Math.log10()` function returns the base 10 logarithm of a number.
5837        ///
5838        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log10)
5839        #[wasm_bindgen(js_namespace = Math)]
5840        pub fn log10(x: f64) -> f64;
5841
5842        /// The `Math.log1p()` function returns the natural logarithm (base e) of 1 + a number.
5843        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log1p)
5844        #[wasm_bindgen(js_namespace = Math)]
5845        pub fn log1p(x: f64) -> f64;
5846
5847        /// The `Math.log2()` function returns the base 2 logarithm of a number.
5848        ///
5849        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log2)
5850        #[wasm_bindgen(js_namespace = Math)]
5851        pub fn log2(x: f64) -> f64;
5852
5853        /// The `Math.max()` function returns the largest of two numbers.
5854        ///
5855        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/max)
5856        #[wasm_bindgen(js_namespace = Math)]
5857        pub fn max(x: f64, y: f64) -> f64;
5858
5859        /// The static function `Math.min()` returns the lowest-valued number passed into it.
5860        ///
5861        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/min)
5862        #[wasm_bindgen(js_namespace = Math)]
5863        pub fn min(x: f64, y: f64) -> f64;
5864
5865        /// The `Math.pow()` function returns the base to the exponent power, that is, base^exponent.
5866        ///
5867        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/pow)
5868        #[wasm_bindgen(js_namespace = Math)]
5869        pub fn pow(base: f64, exponent: f64) -> f64;
5870
5871        /// The `Math.random()` function returns a floating-point, pseudo-random number
5872        /// in the range 0–1 (inclusive of 0, but not 1) with approximately uniform distribution
5873        /// over that range — which you can then scale to your desired range.
5874        /// The implementation selects the initial seed to the random number generation algorithm;
5875        /// it cannot be chosen or reset by the user.
5876        ///
5877        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random)
5878        #[wasm_bindgen(js_namespace = Math)]
5879        pub fn random() -> f64;
5880
5881        /// The `Math.round()` function returns the value of a number rounded to the nearest integer.
5882        ///
5883        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/round)
5884        #[wasm_bindgen(js_namespace = Math)]
5885        pub fn round(x: f64) -> f64;
5886
5887        /// The `Math.sign()` function returns the sign of a number, indicating whether the number is
5888        /// positive, negative or zero.
5889        ///
5890        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sign)
5891        #[wasm_bindgen(js_namespace = Math)]
5892        pub fn sign(x: f64) -> f64;
5893
5894        /// The `Math.sin()` function returns the sine of a number.
5895        ///
5896        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sin)
5897        #[wasm_bindgen(js_namespace = Math)]
5898        pub fn sin(x: f64) -> f64;
5899
5900        /// The `Math.sinh()` function returns the hyperbolic sine of a number, that can be expressed
5901        /// using the constant e: Math.sinh(x) = (e^x - e^-x)/2
5902        ///
5903        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sinh)
5904        #[wasm_bindgen(js_namespace = Math)]
5905        pub fn sinh(x: f64) -> f64;
5906
5907        /// The `Math.sqrt()` function returns the square root of a number, that is
5908        /// ∀x ≥ 0, Math.sqrt(x) = √x = the unique y ≥ 0 such that y^2 = x
5909        ///
5910        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sqrt)
5911        #[wasm_bindgen(js_namespace = Math)]
5912        pub fn sqrt(x: f64) -> f64;
5913
5914        /// The `Math.tan()` function returns the tangent of a number.
5915        ///
5916        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/tan)
5917        #[wasm_bindgen(js_namespace = Math)]
5918        pub fn tan(x: f64) -> f64;
5919
5920        /// The `Math.tanh()` function returns the hyperbolic tangent of a number, that is
5921        /// tanh x = sinh x / cosh x = (e^x - e^-x)/(e^x + e^-x) = (e^2x - 1)/(e^2x + 1)
5922        ///
5923        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/tanh)
5924        #[wasm_bindgen(js_namespace = Math)]
5925        pub fn tanh(x: f64) -> f64;
5926
5927        /// The `Math.trunc()` function returns the integer part of a number by removing any fractional
5928        /// digits.
5929        ///
5930        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/trunc)
5931        #[wasm_bindgen(js_namespace = Math)]
5932        pub fn trunc(x: f64) -> f64;
5933
5934        /// The `Math.PI` property represents the ratio of the circumference of a circle to its diameter,
5935        /// approximately 3.14159.
5936        ///
5937        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/PI)
5938        #[wasm_bindgen(thread_local_v2, js_namespace = Math)]
5939        pub static PI: f64;
5940    }
5941}
5942
5943// Number.
5944#[wasm_bindgen]
5945extern "C" {
5946    #[wasm_bindgen(extends = Object, is_type_of = |v| v.as_f64().is_some(), typescript_type = "number")]
5947    #[derive(Clone, PartialEq)]
5948    pub type Number;
5949
5950    /// The `Number.isFinite()` method determines whether the passed value is a finite number.
5951    ///
5952    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isFinite)
5953    #[wasm_bindgen(static_method_of = Number, js_name = isFinite)]
5954    pub fn is_finite(value: &JsValue) -> bool;
5955
5956    /// The `Number.isInteger()` method determines whether the passed value is an integer.
5957    ///
5958    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger)
5959    #[wasm_bindgen(static_method_of = Number, js_name = isInteger)]
5960    pub fn is_integer(value: &JsValue) -> bool;
5961
5962    /// The `Number.isNaN()` method determines whether the passed value is `NaN` and its type is Number.
5963    /// It is a more robust version of the original, global isNaN().
5964    ///
5965    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isNaN)
5966    #[wasm_bindgen(static_method_of = Number, js_name = isNaN)]
5967    pub fn is_nan(value: &JsValue) -> bool;
5968
5969    /// The `Number.isSafeInteger()` method determines whether the provided value is a number
5970    /// that is a safe integer.
5971    ///
5972    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger)
5973    #[wasm_bindgen(static_method_of = Number, js_name = isSafeInteger)]
5974    pub fn is_safe_integer(value: &JsValue) -> bool;
5975
5976    /// The `Number` JavaScript object is a wrapper object allowing
5977    /// you to work with numerical values. A `Number` object is
5978    /// created using the `Number()` constructor.
5979    ///
5980    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)
5981    #[cfg(not(js_sys_unstable_apis))]
5982    #[wasm_bindgen(constructor)]
5983    #[deprecated(note = "recommended to use `Number::from` instead")]
5984    #[allow(deprecated)]
5985    pub fn new(value: &JsValue) -> Number;
5986
5987    #[wasm_bindgen(constructor)]
5988    fn new_from_str(value: &str) -> Number;
5989
5990    /// The `Number.parseInt()` method parses a string argument and returns an
5991    /// integer of the specified radix or base.
5992    ///
5993    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/parseInt)
5994    #[wasm_bindgen(static_method_of = Number, js_name = parseInt)]
5995    pub fn parse_int(text: &str, radix: u8) -> f64;
5996
5997    /// The `Number.parseFloat()` method parses a string argument and returns a
5998    /// floating point number.
5999    ///
6000    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/parseFloat)
6001    #[wasm_bindgen(static_method_of = Number, js_name = parseFloat)]
6002    pub fn parse_float(text: &str) -> f64;
6003
6004    /// The `toLocaleString()` method returns a string with a language sensitive
6005    /// representation of this number.
6006    ///
6007    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString)
6008    #[cfg(not(js_sys_unstable_apis))]
6009    #[wasm_bindgen(method, js_name = toLocaleString)]
6010    pub fn to_locale_string(this: &Number, locale: &str) -> JsString;
6011
6012    /// The `toLocaleString()` method returns a string with a language sensitive
6013    /// representation of this number.
6014    ///
6015    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString)
6016    #[cfg(js_sys_unstable_apis)]
6017    #[wasm_bindgen(method, js_name = toLocaleString)]
6018    pub fn to_locale_string(
6019        this: &Number,
6020        locales: &[JsString],
6021        options: &Intl::NumberFormatOptions,
6022    ) -> JsString;
6023
6024    /// The `toPrecision()` method returns a string representing the Number
6025    /// object to the specified precision.
6026    ///
6027    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toPrecision)
6028    #[wasm_bindgen(catch, method, js_name = toPrecision)]
6029    pub fn to_precision(this: &Number, precision: u8) -> Result<JsString, JsValue>;
6030
6031    /// The `toFixed()` method returns a string representing the Number
6032    /// object using fixed-point notation.
6033    ///
6034    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed)
6035    #[wasm_bindgen(catch, method, js_name = toFixed)]
6036    pub fn to_fixed(this: &Number, digits: u8) -> Result<JsString, JsValue>;
6037
6038    /// The `toExponential()` method returns a string representing the Number
6039    /// object in exponential notation.
6040    ///
6041    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toExponential)
6042    #[wasm_bindgen(catch, method, js_name = toExponential)]
6043    pub fn to_exponential(this: &Number, fraction_digits: u8) -> Result<JsString, JsValue>;
6044
6045    /// The `toString()` method returns a string representing the
6046    /// specified Number object.
6047    ///
6048    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString)
6049    #[cfg(not(js_sys_unstable_apis))]
6050    #[deprecated(note = "Use `Number::to_string_with_radix` instead.")]
6051    #[allow(deprecated)]
6052    #[wasm_bindgen(catch, method, js_name = toString)]
6053    pub fn to_string(this: &Number, radix: u8) -> Result<JsString, JsValue>;
6054
6055    /// The `toString()` method returns a string representing the
6056    /// specified Number object.
6057    ///
6058    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString)
6059    #[wasm_bindgen(catch, method, js_name = toString)]
6060    pub fn to_string_with_radix(this: &Number, radix: u8) -> Result<JsString, JsValue>;
6061
6062    /// The `valueOf()` method returns the wrapped primitive value of
6063    /// a Number object.
6064    ///
6065    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/valueOf)
6066    #[wasm_bindgen(method, js_name = valueOf)]
6067    pub fn value_of(this: &Number) -> f64;
6068}
6069
6070impl Number {
6071    /// The smallest interval between two representable numbers.
6072    ///
6073    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/EPSILON)
6074    pub const EPSILON: f64 = f64::EPSILON;
6075    /// The maximum safe integer in JavaScript (2^53 - 1).
6076    ///
6077    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER)
6078    pub const MAX_SAFE_INTEGER: f64 = 9007199254740991.0;
6079    /// The largest positive representable number.
6080    ///
6081    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_VALUE)
6082    pub const MAX_VALUE: f64 = f64::MAX;
6083    /// The minimum safe integer in JavaScript (-(2^53 - 1)).
6084    ///
6085    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MIN_SAFE_INTEGER)
6086    pub const MIN_SAFE_INTEGER: f64 = -9007199254740991.0;
6087    /// The smallest positive representable number—that is, the positive number closest to zero
6088    /// (without actually being zero).
6089    ///
6090    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MIN_VALUE)
6091    // Cannot use f64::MIN_POSITIVE since that is the smallest **normal** positive number.
6092    pub const MIN_VALUE: f64 = 5E-324;
6093    /// Special "Not a Number" value.
6094    ///
6095    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/NaN)
6096    pub const NAN: f64 = f64::NAN;
6097    /// Special value representing negative infinity. Returned on overflow.
6098    ///
6099    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/NEGATIVE_INFINITY)
6100    pub const NEGATIVE_INFINITY: f64 = f64::NEG_INFINITY;
6101    /// Special value representing infinity. Returned on overflow.
6102    ///
6103    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/POSITIVE_INFINITY)
6104    pub const POSITIVE_INFINITY: f64 = f64::INFINITY;
6105
6106    /// Applies the binary `**` JS operator on the two `Number`s.
6107    ///
6108    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Exponentiation)
6109    #[inline]
6110    pub fn pow(&self, rhs: &Self) -> Self {
6111        JsValue::as_ref(self)
6112            .pow(JsValue::as_ref(rhs))
6113            .unchecked_into()
6114    }
6115
6116    /// Applies the binary `>>>` JS operator on the two `Number`s.
6117    ///
6118    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Unsigned_right_shift)
6119    #[inline]
6120    pub fn unsigned_shr(&self, rhs: &Self) -> Self {
6121        Number::from(JsValue::as_ref(self).unsigned_shr(JsValue::as_ref(rhs)))
6122    }
6123}
6124
6125macro_rules! number_from {
6126    ($($x:ident)*) => ($(
6127        impl From<$x> for Number {
6128            #[inline]
6129            fn from(x: $x) -> Number {
6130                Number::unchecked_from_js(JsValue::from(x))
6131            }
6132        }
6133
6134        impl PartialEq<$x> for Number {
6135            #[inline]
6136            fn eq(&self, other: &$x) -> bool {
6137                self.value_of() == f64::from(*other)
6138            }
6139        }
6140
6141        impl UpcastFrom<$x> for Number {}
6142    )*)
6143}
6144number_from!(i8 u8 i16 u16 i32 u32 f32 f64);
6145
6146// The only guarantee for a JS number
6147impl UpcastFrom<Number> for f64 {}
6148
6149/// The error type returned when a checked integral type conversion fails.
6150#[derive(Debug, Copy, Clone, PartialEq, Eq)]
6151pub struct TryFromIntError(());
6152
6153impl fmt::Display for TryFromIntError {
6154    fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
6155        fmt.write_str("out of range integral type conversion attempted")
6156    }
6157}
6158
6159#[cfg(feature = "std")]
6160impl std::error::Error for TryFromIntError {}
6161
6162macro_rules! number_try_from {
6163    ($($x:ident)*) => ($(
6164        impl TryFrom<$x> for Number {
6165            type Error = TryFromIntError;
6166
6167            #[inline]
6168            fn try_from(x: $x) -> Result<Number, Self::Error> {
6169                let x_f64 = x as f64;
6170                if (Number::MIN_SAFE_INTEGER..=Number::MAX_SAFE_INTEGER).contains(&x_f64) {
6171                    Ok(Number::from(x_f64))
6172                } else {
6173                    Err(TryFromIntError(()))
6174                }
6175            }
6176        }
6177    )*)
6178}
6179number_try_from!(i64 u64 i128 u128);
6180
6181impl From<&Number> for f64 {
6182    #[inline]
6183    fn from(n: &Number) -> f64 {
6184        n.value_of()
6185    }
6186}
6187
6188impl From<Number> for f64 {
6189    #[inline]
6190    fn from(n: Number) -> f64 {
6191        <f64 as From<&'_ Number>>::from(&n)
6192    }
6193}
6194
6195impl fmt::Debug for Number {
6196    #[inline]
6197    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
6198        fmt::Debug::fmt(&self.value_of(), f)
6199    }
6200}
6201
6202impl fmt::Display for Number {
6203    #[inline]
6204    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
6205        fmt::Display::fmt(&self.value_of(), f)
6206    }
6207}
6208
6209impl Default for Number {
6210    fn default() -> Self {
6211        Self::from(f64::default())
6212    }
6213}
6214
6215impl PartialEq<BigInt> for Number {
6216    #[inline]
6217    fn eq(&self, other: &BigInt) -> bool {
6218        JsValue::as_ref(self).loose_eq(JsValue::as_ref(other))
6219    }
6220}
6221
6222impl Not for &Number {
6223    type Output = BigInt;
6224
6225    #[inline]
6226    fn not(self) -> Self::Output {
6227        JsValue::as_ref(self).bit_not().unchecked_into()
6228    }
6229}
6230
6231forward_deref_unop!(impl Not, not for Number);
6232forward_js_unop!(impl Neg, neg for Number);
6233forward_js_binop!(impl BitAnd, bitand for Number);
6234forward_js_binop!(impl BitOr, bitor for Number);
6235forward_js_binop!(impl BitXor, bitxor for Number);
6236forward_js_binop!(impl Shl, shl for Number);
6237forward_js_binop!(impl Shr, shr for Number);
6238forward_js_binop!(impl Add, add for Number);
6239forward_js_binop!(impl Sub, sub for Number);
6240forward_js_binop!(impl Div, div for Number);
6241forward_js_binop!(impl Mul, mul for Number);
6242forward_js_binop!(impl Rem, rem for Number);
6243
6244sum_product!(Number);
6245
6246impl PartialOrd for Number {
6247    #[inline]
6248    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
6249        if Number::is_nan(self) || Number::is_nan(other) {
6250            None
6251        } else if self == other {
6252            Some(Ordering::Equal)
6253        } else if self.lt(other) {
6254            Some(Ordering::Less)
6255        } else {
6256            Some(Ordering::Greater)
6257        }
6258    }
6259
6260    #[inline]
6261    fn lt(&self, other: &Self) -> bool {
6262        JsValue::as_ref(self).lt(JsValue::as_ref(other))
6263    }
6264
6265    #[inline]
6266    fn le(&self, other: &Self) -> bool {
6267        JsValue::as_ref(self).le(JsValue::as_ref(other))
6268    }
6269
6270    #[inline]
6271    fn ge(&self, other: &Self) -> bool {
6272        JsValue::as_ref(self).ge(JsValue::as_ref(other))
6273    }
6274
6275    #[inline]
6276    fn gt(&self, other: &Self) -> bool {
6277        JsValue::as_ref(self).gt(JsValue::as_ref(other))
6278    }
6279}
6280
6281#[cfg(not(js_sys_unstable_apis))]
6282impl FromStr for Number {
6283    type Err = Infallible;
6284
6285    #[allow(deprecated)]
6286    #[inline]
6287    fn from_str(s: &str) -> Result<Self, Self::Err> {
6288        Ok(Number::new_from_str(s))
6289    }
6290}
6291
6292// Date.
6293#[wasm_bindgen]
6294extern "C" {
6295    #[wasm_bindgen(extends = Object, typescript_type = "Date")]
6296    #[derive(Clone, Debug, PartialEq, Eq)]
6297    pub type Date;
6298
6299    /// The `getDate()` method returns the day of the month for the
6300    /// specified date according to local time.
6301    ///
6302    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getDate)
6303    #[wasm_bindgen(method, js_name = getDate)]
6304    pub fn get_date(this: &Date) -> u32;
6305
6306    /// The `getDay()` method returns the day of the week for the specified date according to local time,
6307    /// where 0 represents Sunday. For the day of the month see getDate().
6308    ///
6309    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getDay)
6310    #[wasm_bindgen(method, js_name = getDay)]
6311    pub fn get_day(this: &Date) -> u32;
6312
6313    /// The `getFullYear()` method returns the year of the specified date according to local time.
6314    ///
6315    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getFullYear)
6316    #[wasm_bindgen(method, js_name = getFullYear)]
6317    pub fn get_full_year(this: &Date) -> u32;
6318
6319    /// The `getHours()` method returns the hour for the specified date, according to local time.
6320    ///
6321    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getHours)
6322    #[wasm_bindgen(method, js_name = getHours)]
6323    pub fn get_hours(this: &Date) -> u32;
6324
6325    /// The `getMilliseconds()` method returns the milliseconds in the specified date according to local time.
6326    ///
6327    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMilliseconds)
6328    #[wasm_bindgen(method, js_name = getMilliseconds)]
6329    pub fn get_milliseconds(this: &Date) -> u32;
6330
6331    /// The `getMinutes()` method returns the minutes in the specified date according to local time.
6332    ///
6333    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMinutes)
6334    #[wasm_bindgen(method, js_name = getMinutes)]
6335    pub fn get_minutes(this: &Date) -> u32;
6336
6337    /// The `getMonth()` method returns the month in the specified date according to local time,
6338    /// as a zero-based value (where zero indicates the first month of the year).
6339    ///
6340    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMonth)
6341    #[wasm_bindgen(method, js_name = getMonth)]
6342    pub fn get_month(this: &Date) -> u32;
6343
6344    /// The `getSeconds()` method returns the seconds in the specified date according to local time.
6345    ///
6346    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getSeconds)
6347    #[wasm_bindgen(method, js_name = getSeconds)]
6348    pub fn get_seconds(this: &Date) -> u32;
6349
6350    /// The `getTime()` method returns the numeric value corresponding to the time for the specified date
6351    /// according to universal time.
6352    ///
6353    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTime)
6354    #[wasm_bindgen(method, js_name = getTime)]
6355    pub fn get_time(this: &Date) -> f64;
6356
6357    /// The `getTimezoneOffset()` method returns the time zone difference, in minutes,
6358    /// from current locale (host system settings) to UTC.
6359    ///
6360    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset)
6361    #[wasm_bindgen(method, js_name = getTimezoneOffset)]
6362    pub fn get_timezone_offset(this: &Date) -> f64;
6363
6364    /// The `getUTCDate()` method returns the day (date) of the month in the specified date
6365    /// according to universal time.
6366    ///
6367    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCDate)
6368    #[wasm_bindgen(method, js_name = getUTCDate)]
6369    pub fn get_utc_date(this: &Date) -> u32;
6370
6371    /// The `getUTCDay()` method returns the day of the week in the specified date according to universal time,
6372    /// where 0 represents Sunday.
6373    ///
6374    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCDay)
6375    #[wasm_bindgen(method, js_name = getUTCDay)]
6376    pub fn get_utc_day(this: &Date) -> u32;
6377
6378    /// The `getUTCFullYear()` method returns the year in the specified date according to universal time.
6379    ///
6380    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCFullYear)
6381    #[wasm_bindgen(method, js_name = getUTCFullYear)]
6382    pub fn get_utc_full_year(this: &Date) -> u32;
6383
6384    /// The `getUTCHours()` method returns the hours in the specified date according to universal time.
6385    ///
6386    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCHours)
6387    #[wasm_bindgen(method, js_name = getUTCHours)]
6388    pub fn get_utc_hours(this: &Date) -> u32;
6389
6390    /// The `getUTCMilliseconds()` method returns the milliseconds in the specified date
6391    /// according to universal time.
6392    ///
6393    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMilliseconds)
6394    #[wasm_bindgen(method, js_name = getUTCMilliseconds)]
6395    pub fn get_utc_milliseconds(this: &Date) -> u32;
6396
6397    /// The `getUTCMinutes()` method returns the minutes in the specified date according to universal time.
6398    ///
6399    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMinutes)
6400    #[wasm_bindgen(method, js_name = getUTCMinutes)]
6401    pub fn get_utc_minutes(this: &Date) -> u32;
6402
6403    /// The `getUTCMonth()` returns the month of the specified date according to universal time,
6404    /// as a zero-based value (where zero indicates the first month of the year).
6405    ///
6406    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMonth)
6407    #[wasm_bindgen(method, js_name = getUTCMonth)]
6408    pub fn get_utc_month(this: &Date) -> u32;
6409
6410    /// The `getUTCSeconds()` method returns the seconds in the specified date according to universal time.
6411    ///
6412    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCSeconds)
6413    #[wasm_bindgen(method, js_name = getUTCSeconds)]
6414    pub fn get_utc_seconds(this: &Date) -> u32;
6415
6416    /// Creates a JavaScript `Date` instance that represents
6417    /// a single moment in time. `Date` objects are based on a time value that is
6418    /// the number of milliseconds since 1 January 1970 UTC.
6419    ///
6420    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
6421    #[wasm_bindgen(constructor)]
6422    pub fn new(init: &JsValue) -> Date;
6423
6424    /// Creates a JavaScript `Date` instance that represents the current moment in
6425    /// time.
6426    ///
6427    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
6428    #[wasm_bindgen(constructor)]
6429    pub fn new_0() -> Date;
6430
6431    /// Creates a JavaScript `Date` instance that represents
6432    /// a single moment in time. `Date` objects are based on a time value that is
6433    /// the number of milliseconds since 1 January 1970 UTC.
6434    ///
6435    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
6436    #[wasm_bindgen(constructor)]
6437    pub fn new_with_year_month(year: u32, month: i32) -> Date;
6438
6439    /// Creates a JavaScript `Date` instance that represents
6440    /// a single moment in time. `Date` objects are based on a time value that is
6441    /// the number of milliseconds since 1 January 1970 UTC.
6442    ///
6443    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
6444    #[wasm_bindgen(constructor)]
6445    pub fn new_with_year_month_day(year: u32, month: i32, day: i32) -> Date;
6446
6447    /// Creates a JavaScript `Date` instance that represents
6448    /// a single moment in time. `Date` objects are based on a time value that is
6449    /// the number of milliseconds since 1 January 1970 UTC.
6450    ///
6451    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
6452    #[wasm_bindgen(constructor)]
6453    pub fn new_with_year_month_day_hr(year: u32, month: i32, day: i32, hr: i32) -> Date;
6454
6455    /// Creates a JavaScript `Date` instance that represents
6456    /// a single moment in time. `Date` objects are based on a time value that is
6457    /// the number of milliseconds since 1 January 1970 UTC.
6458    ///
6459    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
6460    #[wasm_bindgen(constructor)]
6461    pub fn new_with_year_month_day_hr_min(
6462        year: u32,
6463        month: i32,
6464        day: i32,
6465        hr: i32,
6466        min: i32,
6467    ) -> Date;
6468
6469    /// Creates a JavaScript `Date` instance that represents
6470    /// a single moment in time. `Date` objects are based on a time value that is
6471    /// the number of milliseconds since 1 January 1970 UTC.
6472    ///
6473    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
6474    #[wasm_bindgen(constructor)]
6475    pub fn new_with_year_month_day_hr_min_sec(
6476        year: u32,
6477        month: i32,
6478        day: i32,
6479        hr: i32,
6480        min: i32,
6481        sec: i32,
6482    ) -> Date;
6483
6484    /// Creates a JavaScript `Date` instance that represents
6485    /// a single moment in time. `Date` objects are based on a time value that is
6486    /// the number of milliseconds since 1 January 1970 UTC.
6487    ///
6488    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
6489    #[wasm_bindgen(constructor)]
6490    pub fn new_with_year_month_day_hr_min_sec_milli(
6491        year: u32,
6492        month: i32,
6493        day: i32,
6494        hr: i32,
6495        min: i32,
6496        sec: i32,
6497        milli: i32,
6498    ) -> Date;
6499
6500    /// The `Date.now()` method returns the number of milliseconds
6501    /// elapsed since January 1, 1970 00:00:00 UTC.
6502    ///
6503    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now)
6504    #[wasm_bindgen(static_method_of = Date)]
6505    pub fn now() -> f64;
6506
6507    /// The `Date.parse()` method parses a string representation of a date, and returns the number of milliseconds
6508    /// since January 1, 1970, 00:00:00 UTC or `NaN` if the string is unrecognized or, in some cases,
6509    /// contains illegal date values (e.g. 2015-02-31).
6510    ///
6511    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse)
6512    #[wasm_bindgen(static_method_of = Date)]
6513    pub fn parse(date: &str) -> f64;
6514
6515    /// The `setDate()` method sets the day of the Date object relative to the beginning of the currently set month.
6516    ///
6517    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setDate)
6518    #[wasm_bindgen(method, js_name = setDate)]
6519    pub fn set_date(this: &Date, day: u32) -> f64;
6520
6521    /// The `setFullYear()` method sets the full year for a specified date according to local time.
6522    /// Returns new timestamp.
6523    ///
6524    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setFullYear)
6525    #[wasm_bindgen(method, js_name = setFullYear)]
6526    pub fn set_full_year(this: &Date, year: u32) -> f64;
6527
6528    /// The `setFullYear()` method sets the full year for a specified date according to local time.
6529    /// Returns new timestamp.
6530    ///
6531    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setFullYear)
6532    #[wasm_bindgen(method, js_name = setFullYear)]
6533    pub fn set_full_year_with_month(this: &Date, year: u32, month: i32) -> f64;
6534
6535    /// The `setFullYear()` method sets the full year for a specified date according to local time.
6536    /// Returns new timestamp.
6537    ///
6538    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setFullYear)
6539    #[wasm_bindgen(method, js_name = setFullYear)]
6540    pub fn set_full_year_with_month_date(this: &Date, year: u32, month: i32, date: i32) -> f64;
6541
6542    /// The `setHours()` method sets the hours for a specified date according to local time,
6543    /// and returns the number of milliseconds since January 1, 1970 00:00:00 UTC until the time represented
6544    /// by the updated Date instance.
6545    ///
6546    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setHours)
6547    #[wasm_bindgen(method, js_name = setHours)]
6548    pub fn set_hours(this: &Date, hours: u32) -> f64;
6549
6550    /// The `setMilliseconds()` method sets the milliseconds for a specified date according to local time.
6551    ///
6552    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setMilliseconds)
6553    #[wasm_bindgen(method, js_name = setMilliseconds)]
6554    pub fn set_milliseconds(this: &Date, milliseconds: u32) -> f64;
6555
6556    /// The `setMinutes()` method sets the minutes for a specified date according to local time.
6557    ///
6558    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setMinutes)
6559    #[wasm_bindgen(method, js_name = setMinutes)]
6560    pub fn set_minutes(this: &Date, minutes: u32) -> f64;
6561
6562    /// The `setMonth()` method sets the month for a specified date according to the currently set year.
6563    ///
6564    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setMonth)
6565    #[wasm_bindgen(method, js_name = setMonth)]
6566    pub fn set_month(this: &Date, month: u32) -> f64;
6567
6568    /// The `setSeconds()` method sets the seconds for a specified date according to local time.
6569    ///
6570    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setSeconds)
6571    #[wasm_bindgen(method, js_name = setSeconds)]
6572    pub fn set_seconds(this: &Date, seconds: u32) -> f64;
6573
6574    /// The `setTime()` method sets the Date object to the time represented by a number of milliseconds
6575    /// since January 1, 1970, 00:00:00 UTC.
6576    ///
6577    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setTime)
6578    #[wasm_bindgen(method, js_name = setTime)]
6579    pub fn set_time(this: &Date, time: f64) -> f64;
6580
6581    /// The `setUTCDate()` method sets the day of the month for a specified date
6582    /// according to universal time.
6583    ///
6584    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCDate)
6585    #[wasm_bindgen(method, js_name = setUTCDate)]
6586    pub fn set_utc_date(this: &Date, day: u32) -> f64;
6587
6588    /// The `setUTCFullYear()` method sets the full year for a specified date according to universal time.
6589    ///
6590    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCFullYear)
6591    #[wasm_bindgen(method, js_name = setUTCFullYear)]
6592    pub fn set_utc_full_year(this: &Date, year: u32) -> f64;
6593
6594    /// The `setUTCFullYear()` method sets the full year for a specified date according to universal time.
6595    ///
6596    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCFullYear)
6597    #[wasm_bindgen(method, js_name = setUTCFullYear)]
6598    pub fn set_utc_full_year_with_month(this: &Date, year: u32, month: i32) -> f64;
6599
6600    /// The `setUTCFullYear()` method sets the full year for a specified date according to universal time.
6601    ///
6602    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCFullYear)
6603    #[wasm_bindgen(method, js_name = setUTCFullYear)]
6604    pub fn set_utc_full_year_with_month_date(this: &Date, year: u32, month: i32, date: i32) -> f64;
6605
6606    /// The `setUTCHours()` method sets the hour for a specified date according to universal time,
6607    /// and returns the number of milliseconds since  January 1, 1970 00:00:00 UTC until the time
6608    /// represented by the updated Date instance.
6609    ///
6610    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCHours)
6611    #[wasm_bindgen(method, js_name = setUTCHours)]
6612    pub fn set_utc_hours(this: &Date, hours: u32) -> f64;
6613
6614    /// The `setUTCMilliseconds()` method sets the milliseconds for a specified date
6615    /// according to universal time.
6616    ///
6617    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCMilliseconds)
6618    #[wasm_bindgen(method, js_name = setUTCMilliseconds)]
6619    pub fn set_utc_milliseconds(this: &Date, milliseconds: u32) -> f64;
6620
6621    /// The `setUTCMinutes()` method sets the minutes for a specified date according to universal time.
6622    ///
6623    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCMinutes)
6624    #[wasm_bindgen(method, js_name = setUTCMinutes)]
6625    pub fn set_utc_minutes(this: &Date, minutes: u32) -> f64;
6626
6627    /// The `setUTCMonth()` method sets the month for a specified date according to universal time.
6628    ///
6629    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCMonth)
6630    #[wasm_bindgen(method, js_name = setUTCMonth)]
6631    pub fn set_utc_month(this: &Date, month: u32) -> f64;
6632
6633    /// The `setUTCSeconds()` method sets the seconds for a specified date according to universal time.
6634    ///
6635    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCSeconds)
6636    #[wasm_bindgen(method, js_name = setUTCSeconds)]
6637    pub fn set_utc_seconds(this: &Date, seconds: u32) -> f64;
6638
6639    /// The `toDateString()` method returns the date portion of a Date object
6640    /// in human readable form in American English.
6641    ///
6642    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toDateString)
6643    #[wasm_bindgen(method, js_name = toDateString)]
6644    pub fn to_date_string(this: &Date) -> JsString;
6645
6646    /// The `toISOString()` method returns a string in simplified extended ISO format (ISO
6647    /// 8601), which is always 24 or 27 characters long (YYYY-MM-DDTHH:mm:ss.sssZ or
6648    /// ±YYYYYY-MM-DDTHH:mm:ss.sssZ, respectively). The timezone is always zero UTC offset,
6649    /// as denoted by the suffix "Z"
6650    ///
6651    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
6652    #[wasm_bindgen(method, js_name = toISOString)]
6653    pub fn to_iso_string(this: &Date) -> JsString;
6654
6655    /// The `toJSON()` method returns a string representation of the Date object.
6656    ///
6657    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toJSON)
6658    #[wasm_bindgen(method, js_name = toJSON)]
6659    pub fn to_json(this: &Date) -> JsString;
6660
6661    /// The `toLocaleDateString()` method returns a string with a language sensitive
6662    /// representation of the date portion of this date. The new locales and options
6663    /// arguments let applications specify the language whose formatting conventions
6664    /// should be used and allow to customize the behavior of the function.
6665    /// In older implementations, which ignore the locales and options arguments,
6666    /// the locale used and the form of the string
6667    /// returned are entirely implementation dependent.
6668    ///
6669    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString)
6670    #[cfg(not(js_sys_unstable_apis))]
6671    #[wasm_bindgen(method, js_name = toLocaleDateString)]
6672    pub fn to_locale_date_string(this: &Date, locale: &str, options: &JsValue) -> JsString;
6673
6674    /// The `toLocaleDateString()` method returns a string with a language sensitive
6675    /// representation of the date portion of this date.
6676    ///
6677    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString)
6678    #[cfg(js_sys_unstable_apis)]
6679    #[wasm_bindgen(method, js_name = toLocaleDateString)]
6680    pub fn to_locale_date_string(
6681        this: &Date,
6682        locales: &[JsString],
6683        options: &Intl::DateTimeFormatOptions,
6684    ) -> JsString;
6685
6686    /// The `toLocaleString()` method returns a string with a language sensitive
6687    /// representation of this date. The new locales and options arguments
6688    /// let applications specify the language whose formatting conventions
6689    /// should be used and customize the behavior of the function.
6690    /// In older implementations, which ignore the locales
6691    /// and options arguments, the locale used and the form of the string
6692    /// returned are entirely implementation dependent.
6693    ///
6694    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString)
6695    #[cfg(not(js_sys_unstable_apis))]
6696    #[wasm_bindgen(method, js_name = toLocaleString)]
6697    pub fn to_locale_string(this: &Date, locale: &str, options: &JsValue) -> JsString;
6698
6699    /// The `toLocaleString()` method returns a string with a language sensitive
6700    /// representation of this date.
6701    ///
6702    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString)
6703    #[cfg(js_sys_unstable_apis)]
6704    #[wasm_bindgen(method, js_name = toLocaleString)]
6705    pub fn to_locale_string(
6706        this: &Date,
6707        locales: &[JsString],
6708        options: &Intl::DateTimeFormatOptions,
6709    ) -> JsString;
6710
6711    /// The `toLocaleTimeString()` method returns a string with a language sensitive
6712    /// representation of the time portion of this date. The new locales and options
6713    /// arguments let applications specify the language whose formatting conventions should be
6714    /// used and customize the behavior of the function. In older implementations, which ignore
6715    /// the locales and options arguments, the locale used and the form of the string
6716    /// returned are entirely implementation dependent.
6717    ///
6718    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleTimeString)
6719    #[cfg(not(js_sys_unstable_apis))]
6720    #[wasm_bindgen(method, js_name = toLocaleTimeString)]
6721    pub fn to_locale_time_string(this: &Date, locale: &str) -> JsString;
6722
6723    /// The `toLocaleTimeString()` method returns a string with a language sensitive
6724    /// representation of the time portion of this date.
6725    ///
6726    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleTimeString)
6727    #[cfg(js_sys_unstable_apis)]
6728    #[wasm_bindgen(method, js_name = toLocaleTimeString)]
6729    pub fn to_locale_time_string(
6730        this: &Date,
6731        locales: &[JsString],
6732        options: &Intl::DateTimeFormatOptions,
6733    ) -> JsString;
6734
6735    #[cfg(not(js_sys_unstable_apis))]
6736    #[wasm_bindgen(method, js_name = toLocaleTimeString)]
6737    pub fn to_locale_time_string_with_options(
6738        this: &Date,
6739        locale: &str,
6740        options: &JsValue,
6741    ) -> JsString;
6742
6743    /// The `toString()` method returns a string representing
6744    /// the specified Date object.
6745    ///
6746    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toString)
6747    #[cfg(not(js_sys_unstable_apis))]
6748    #[wasm_bindgen(method, js_name = toString)]
6749    pub fn to_string(this: &Date) -> JsString;
6750
6751    /// The `toTimeString()` method returns the time portion of a Date object in human
6752    /// readable form in American English.
6753    ///
6754    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toTimeString)
6755    #[wasm_bindgen(method, js_name = toTimeString)]
6756    pub fn to_time_string(this: &Date) -> JsString;
6757
6758    /// The `toUTCString()` method converts a date to a string,
6759    /// using the UTC time zone.
6760    ///
6761    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toUTCString)
6762    #[wasm_bindgen(method, js_name = toUTCString)]
6763    pub fn to_utc_string(this: &Date) -> JsString;
6764
6765    /// The `Date.UTC()` method accepts the same parameters as the
6766    /// longest form of the constructor, and returns the number of
6767    /// milliseconds in a `Date` object since January 1, 1970,
6768    /// 00:00:00, universal time.
6769    ///
6770    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/UTC)
6771    #[wasm_bindgen(static_method_of = Date, js_name = UTC)]
6772    pub fn utc(year: f64, month: f64) -> f64;
6773
6774    /// The `valueOf()` method  returns the primitive value of
6775    /// a Date object.
6776    ///
6777    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/valueOf)
6778    #[wasm_bindgen(method, js_name = valueOf)]
6779    pub fn value_of(this: &Date) -> f64;
6780
6781    /// The `toTemporalInstant()` method converts a legacy `Date` object to a
6782    /// `Temporal.Instant` object representing the same moment in time.
6783    ///
6784    /// This method is added by the Temporal proposal to facilitate migration
6785    /// from legacy `Date` to the new Temporal API.
6786    ///
6787    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toTemporalInstant)
6788    #[cfg(js_sys_unstable_apis)]
6789    #[wasm_bindgen(method, js_name = toTemporalInstant)]
6790    pub fn to_temporal_instant(this: &Date) -> Temporal::Instant;
6791}
6792
6793// Property Descriptor.
6794#[wasm_bindgen]
6795extern "C" {
6796    #[wasm_bindgen(extends = Object)]
6797    #[derive(Clone, Debug)]
6798    pub type PropertyDescriptor<T = JsValue>;
6799
6800    #[wasm_bindgen(method, getter = writable)]
6801    pub fn get_writable<T>(this: &PropertyDescriptor<T>) -> Option<bool>;
6802
6803    #[wasm_bindgen(method, setter = writable)]
6804    pub fn set_writable<T>(this: &PropertyDescriptor<T>, writable: bool);
6805
6806    #[wasm_bindgen(method, getter = enumerable)]
6807    pub fn get_enumerable<T>(this: &PropertyDescriptor<T>) -> Option<bool>;
6808
6809    #[wasm_bindgen(method, setter = enumerable)]
6810    pub fn set_enumerable<T>(this: &PropertyDescriptor<T>, enumerable: bool);
6811
6812    #[wasm_bindgen(method, getter = configurable)]
6813    pub fn get_configurable<T>(this: &PropertyDescriptor<T>) -> Option<bool>;
6814
6815    #[wasm_bindgen(method, setter = configurable)]
6816    pub fn set_configurable<T>(this: &PropertyDescriptor<T>, configurable: bool);
6817
6818    #[wasm_bindgen(method, getter = get)]
6819    pub fn get_get<T: JsGeneric>(this: &PropertyDescriptor<T>) -> Option<Function<fn() -> T>>;
6820
6821    #[wasm_bindgen(method, setter = get)]
6822    pub fn set_get<T: JsGeneric>(this: &PropertyDescriptor<T>, get: Function<fn() -> T>);
6823
6824    #[wasm_bindgen(method, getter = set)]
6825    pub fn get_set<T: JsGeneric>(
6826        this: &PropertyDescriptor<T>,
6827    ) -> Option<Function<fn(T) -> JsValue>>;
6828
6829    #[wasm_bindgen(method, setter = set)]
6830    pub fn set_set<T: JsGeneric>(this: &PropertyDescriptor<T>, set: Function<fn(T) -> JsValue>);
6831
6832    #[wasm_bindgen(method, getter = value)]
6833    pub fn get_value<T>(this: &PropertyDescriptor<T>) -> Option<T>;
6834
6835    #[wasm_bindgen(method, setter = value)]
6836    pub fn set_value<T>(this: &PropertyDescriptor<T>, value: &T);
6837}
6838
6839impl PropertyDescriptor {
6840    #[cfg(not(js_sys_unstable_apis))]
6841    pub fn new<T>() -> PropertyDescriptor<T> {
6842        JsCast::unchecked_into(Object::new())
6843    }
6844
6845    #[cfg(js_sys_unstable_apis)]
6846    pub fn new<T>() -> PropertyDescriptor<T> {
6847        JsCast::unchecked_into(Object::<JsValue>::new())
6848    }
6849
6850    #[cfg(not(js_sys_unstable_apis))]
6851    pub fn new_value<T: JsGeneric>(value: &T) -> PropertyDescriptor<T> {
6852        let desc: PropertyDescriptor<T> = JsCast::unchecked_into(Object::new());
6853        desc.set_value(value);
6854        desc
6855    }
6856
6857    #[cfg(js_sys_unstable_apis)]
6858    pub fn new_value<T: JsGeneric>(value: &T) -> PropertyDescriptor<T> {
6859        let desc: PropertyDescriptor<T> = JsCast::unchecked_into(Object::<JsValue>::new());
6860        desc.set_value(value);
6861        desc
6862    }
6863}
6864
6865impl Default for PropertyDescriptor {
6866    fn default() -> Self {
6867        PropertyDescriptor::new()
6868    }
6869}
6870
6871// Object.
6872#[wasm_bindgen]
6873extern "C" {
6874    #[wasm_bindgen(typescript_type = "object")]
6875    #[derive(Clone, Debug)]
6876    pub type Object<T = JsValue>;
6877
6878    // Next major: deprecate
6879    /// The `Object.assign()` method is used to copy the values of all enumerable
6880    /// own properties from one or more source objects to a target object. It
6881    /// will return the target object.
6882    ///
6883    /// **Note:** Consider using [`Object::try_assign`] to support error handling.
6884    ///
6885    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign)
6886    #[wasm_bindgen(static_method_of = Object)]
6887    pub fn assign<T>(target: &Object<T>, source: &Object<T>) -> Object<T>;
6888
6889    // Next major: deprecate
6890    /// The `Object.assign()` method is used to copy the values of all enumerable
6891    /// own properties from one or more source objects to a target object. It
6892    /// will return the target object.
6893    ///
6894    /// **Note:** Consider using [`Object::try_assign`] to support error handling.
6895    ///
6896    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign)
6897    #[wasm_bindgen(static_method_of = Object, js_name = assign, catch)]
6898    pub fn try_assign<T>(target: &Object<T>, source: &Object<T>) -> Result<Object<T>, JsValue>;
6899
6900    /// The `Object.assign()` method is used to copy the values of all enumerable
6901    /// own properties from one or more source objects to a target object. It
6902    /// will return the target object.
6903    ///
6904    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign)
6905    #[cfg(not(js_sys_unstable_apis))]
6906    #[wasm_bindgen(static_method_of = Object, js_name = assign)]
6907    #[deprecated(note = "use `assign_many` for arbitrary assign arguments instead")]
6908    #[allow(deprecated)]
6909    pub fn assign2<T>(target: &Object<T>, source1: &Object<T>, source2: &Object<T>) -> Object<T>;
6910
6911    /// The `Object.assign()` method is used to copy the values of all enumerable
6912    /// own properties from one or more source objects to a target object. It
6913    /// will return the target object.
6914    ///
6915    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign)
6916    #[cfg(not(js_sys_unstable_apis))]
6917    #[wasm_bindgen(static_method_of = Object, js_name = assign)]
6918    #[deprecated(note = "use `assign_many` for arbitrary assign arguments instead")]
6919    #[allow(deprecated)]
6920    pub fn assign3<T>(
6921        target: &Object<T>,
6922        source1: &Object<T>,
6923        source2: &Object<T>,
6924        source3: &Object<T>,
6925    ) -> Object<T>;
6926
6927    /// The `Object.assign()` method is used to copy the values of all enumerable
6928    /// own properties from one or more source objects to a target object. It
6929    /// will return the target object.
6930    ///
6931    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign)
6932    #[wasm_bindgen(static_method_of = Object, js_name = assign, catch, variadic)]
6933    pub fn assign_many<T>(target: &Object<T>, sources: &[Object<T>]) -> Result<Object<T>, JsValue>;
6934
6935    /// The constructor property returns a reference to the `Object` constructor
6936    /// function that created the instance object.
6937    ///
6938    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/constructor)
6939    #[wasm_bindgen(method, getter)]
6940    pub fn constructor<T>(this: &Object<T>) -> Function;
6941
6942    /// The `Object.create()` method creates a new object, using an existing
6943    /// object to provide the newly created object's prototype.
6944    ///
6945    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create)
6946    #[wasm_bindgen(static_method_of = Object)]
6947    pub fn create<T>(prototype: &Object<T>) -> Object<T>;
6948
6949    /// The static method `Object.defineProperty()` defines a new
6950    /// property directly on an object, or modifies an existing
6951    /// property on an object, and returns the object.
6952    ///
6953    /// **Note:** Consider using [`Object::define_property_str`] to support typing and error handling.
6954    ///
6955    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty)
6956    #[cfg(not(js_sys_unstable_apis))]
6957    #[wasm_bindgen(static_method_of = Object, js_name = defineProperty)]
6958    pub fn define_property<T>(obj: &Object<T>, prop: &JsValue, descriptor: &Object) -> Object<T>;
6959
6960    /// The static method `Object.defineProperty()` defines a new
6961    /// property directly on an object, or modifies an existing
6962    /// property on an object, and returns the object.
6963    ///
6964    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty)
6965    #[cfg(js_sys_unstable_apis)]
6966    #[wasm_bindgen(static_method_of = Object, js_name = defineProperty, catch)]
6967    pub fn define_property<T>(
6968        obj: &Object<T>,
6969        prop: &JsString,
6970        descriptor: &PropertyDescriptor<T>,
6971    ) -> Result<Object<T>, JsValue>;
6972
6973    // Next major: deprecate
6974    /// The static method `Object.defineProperty()` defines a new
6975    /// property directly on an object, or modifies an existing
6976    /// property on an object, and returns the object.
6977    ///
6978    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty)
6979    #[wasm_bindgen(static_method_of = Object, js_name = defineProperty, catch)]
6980    pub fn define_property_str<T>(
6981        obj: &Object<T>,
6982        prop: &JsString,
6983        descriptor: &PropertyDescriptor<T>,
6984    ) -> Result<Object<T>, JsValue>;
6985
6986    /// The static method `Object.defineProperty()` defines a new
6987    /// property directly on an object, or modifies an existing
6988    /// property on an object, and returns the object.
6989    ///
6990    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty)
6991    #[wasm_bindgen(static_method_of = Object, js_name = defineProperty, catch)]
6992    pub fn define_property_symbol<T>(
6993        obj: &Object<T>,
6994        prop: &Symbol,
6995        descriptor: &PropertyDescriptor<JsValue>,
6996    ) -> Result<Object<T>, JsValue>;
6997
6998    /// The `Object.defineProperties()` method defines new or modifies
6999    /// existing properties directly on an object, returning the
7000    /// object.
7001    ///
7002    /// **Note:** Consider using [`Object::try_define_properties`] to support typing and error handling.
7003    ///
7004    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperties)
7005    #[wasm_bindgen(static_method_of = Object, js_name = defineProperties)]
7006    pub fn define_properties<T>(obj: &Object<T>, props: &Object) -> Object<T>;
7007
7008    /// The `Object.defineProperties()` method defines new or modifies
7009    /// existing properties directly on an object, returning the
7010    /// object.
7011    ///
7012    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperties)
7013    #[cfg(js_sys_unstable_apis)]
7014    #[wasm_bindgen(static_method_of = Object, js_name = defineProperties, catch)]
7015    pub fn try_define_properties<T>(
7016        obj: &Object<T>,
7017        props: &Object<PropertyDescriptor<T>>,
7018    ) -> Result<Object<T>, JsValue>;
7019
7020    /// The `Object.entries()` method returns an array of a given
7021    /// object's own enumerable property [key, value] pairs, in the
7022    /// same order as that provided by a for...in loop (the difference
7023    /// being that a for-in loop enumerates properties in the
7024    /// prototype chain as well).
7025    ///
7026    /// **Note:** Consider using [`Object::entries_typed`] to support typing and error handling.
7027    ///
7028    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries)
7029    #[cfg(not(js_sys_unstable_apis))]
7030    #[wasm_bindgen(static_method_of = Object)]
7031    pub fn entries(object: &Object) -> Array;
7032
7033    /// The `Object.entries()` method returns an array of a given
7034    /// object's own enumerable property [key, value] pairs, in the
7035    /// same order as that provided by a for...in loop (the difference
7036    /// being that a for-in loop enumerates properties in the
7037    /// prototype chain as well).
7038    ///
7039    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries)
7040    #[cfg(js_sys_unstable_apis)]
7041    #[wasm_bindgen(static_method_of = Object, js_name = entries, catch)]
7042    pub fn entries<T: JsGeneric>(
7043        object: &Object<T>,
7044    ) -> Result<Array<ArrayTuple<(JsString, T)>>, JsValue>;
7045
7046    // Next major: deprecate
7047    /// The `Object.entries()` method returns an array of a given
7048    /// object's own enumerable property [key, value] pairs, in the
7049    /// same order as that provided by a for...in loop (the difference
7050    /// being that a for-in loop enumerates properties in the
7051    /// prototype chain as well).
7052    ///
7053    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries)
7054    #[wasm_bindgen(static_method_of = Object, js_name = entries, catch)]
7055    pub fn entries_typed<T: JsGeneric>(
7056        object: &Object<T>,
7057    ) -> Result<Array<ArrayTuple<(JsString, T)>>, JsValue>;
7058
7059    /// The `Object.freeze()` method freezes an object: that is, prevents new
7060    /// properties from being added to it; prevents existing properties from
7061    /// being removed; and prevents existing properties, or their enumerability,
7062    /// configurability, or writability, from being changed, it also prevents
7063    /// the prototype from being changed. The method returns the passed object.
7064    ///
7065    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze)
7066    #[wasm_bindgen(static_method_of = Object)]
7067    pub fn freeze<T>(value: &Object<T>) -> Object<T>;
7068
7069    /// The `Object.fromEntries()` method transforms a list of key-value pairs
7070    /// into an object.
7071    ///
7072    /// **Note:** Consider using [`Object::from_entries_typed`] to support typing and error handling.
7073    ///
7074    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/fromEntries)
7075    #[cfg(not(js_sys_unstable_apis))]
7076    #[wasm_bindgen(static_method_of = Object, catch, js_name = fromEntries)]
7077    pub fn from_entries(entries: &JsValue) -> Result<Object, JsValue>;
7078
7079    /// The `Object.fromEntries()` method transforms a list of key-value pairs
7080    /// into an object.
7081    ///
7082    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/fromEntries)
7083    #[cfg(js_sys_unstable_apis)]
7084    #[wasm_bindgen(static_method_of = Object, catch, js_name = fromEntries)]
7085    pub fn from_entries<T: JsGeneric, I: Iterable<Item = ArrayTuple<(JsString, T)>>>(
7086        entries: &I,
7087    ) -> Result<Object<T>, JsValue>;
7088
7089    // Next major: deprecate
7090    /// The `Object.fromEntries()` method transforms a list of key-value pairs
7091    /// into an object.
7092    ///
7093    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/fromEntries)
7094    #[wasm_bindgen(static_method_of = Object, catch, js_name = fromEntries)]
7095    pub fn from_entries_typed<T: JsGeneric, I: Iterable<Item = ArrayTuple<(JsString, T)>>>(
7096        entries: &I,
7097    ) -> Result<Object<T>, JsValue>;
7098
7099    /// The `Object.getOwnPropertyDescriptor()` method returns a
7100    /// property descriptor for an own property (that is, one directly
7101    /// present on an object and not in the object's prototype chain)
7102    /// of a given object.
7103    ///
7104    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor)
7105    #[cfg(not(js_sys_unstable_apis))]
7106    #[wasm_bindgen(static_method_of = Object, js_name = getOwnPropertyDescriptor)]
7107    pub fn get_own_property_descriptor<T>(obj: &Object<T>, prop: &JsValue) -> JsValue;
7108
7109    /// The `Object.getOwnPropertyDescriptor()` method returns a
7110    /// property descriptor for an own property (that is, one directly
7111    /// present on an object and not in the object's prototype chain)
7112    /// of a given object.
7113    ///
7114    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor)
7115    #[cfg(js_sys_unstable_apis)]
7116    #[wasm_bindgen(static_method_of = Object, js_name = getOwnPropertyDescriptor, catch)]
7117    pub fn get_own_property_descriptor<T>(
7118        obj: &Object<T>,
7119        prop: &JsString,
7120    ) -> Result<PropertyDescriptor<T>, JsValue>;
7121
7122    // Next major: deprecate
7123    /// The `Object.getOwnPropertyDescriptor()` method returns a
7124    /// property descriptor for an own property (that is, one directly
7125    /// present on an object and not in the object's prototype chain)
7126    /// of a given object.
7127    ///
7128    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor)
7129    #[wasm_bindgen(static_method_of = Object, js_name = getOwnPropertyDescriptor, catch)]
7130    pub fn get_own_property_descriptor_str<T>(
7131        obj: &Object<T>,
7132        prop: &JsString,
7133    ) -> Result<PropertyDescriptor<T>, JsValue>;
7134
7135    /// The `Object.getOwnPropertyDescriptor()` method returns a
7136    /// property descriptor for an own property (that is, one directly
7137    /// present on an object and not in the object's prototype chain)
7138    /// of a given object.
7139    ///
7140    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor)
7141    #[wasm_bindgen(static_method_of = Object, js_name = getOwnPropertyDescriptor, catch)]
7142    pub fn get_own_property_descriptor_symbol<T>(
7143        obj: &Object<T>,
7144        prop: &Symbol,
7145    ) -> Result<PropertyDescriptor<JsValue>, JsValue>;
7146
7147    /// The `Object.getOwnPropertyDescriptors()` method returns all own
7148    /// property descriptors of a given object.
7149    ///
7150    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptors)
7151    #[cfg(not(js_sys_unstable_apis))]
7152    #[wasm_bindgen(static_method_of = Object, js_name = getOwnPropertyDescriptors)]
7153    pub fn get_own_property_descriptors<T>(obj: &Object<T>) -> JsValue;
7154
7155    /// The `Object.getOwnPropertyDescriptors()` method returns all own
7156    /// property descriptors of a given object.
7157    ///
7158    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptors)
7159    #[cfg(js_sys_unstable_apis)]
7160    #[wasm_bindgen(static_method_of = Object, js_name = getOwnPropertyDescriptors, catch)]
7161    pub fn get_own_property_descriptors<T>(
7162        obj: &Object<T>,
7163    ) -> Result<Object<PropertyDescriptor<T>>, JsValue>;
7164
7165    /// The `Object.getOwnPropertyNames()` method returns an array of
7166    /// all properties (including non-enumerable properties except for
7167    /// those which use Symbol) found directly upon a given object.
7168    ///
7169    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames)
7170    #[cfg(not(js_sys_unstable_apis))]
7171    #[wasm_bindgen(static_method_of = Object, js_name = getOwnPropertyNames)]
7172    pub fn get_own_property_names<T>(obj: &Object<T>) -> Array;
7173
7174    /// The `Object.getOwnPropertyNames()` method returns an array of
7175    /// all properties (including non-enumerable properties except for
7176    /// those which use Symbol) found directly upon a given object.
7177    ///
7178    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames)
7179    #[cfg(js_sys_unstable_apis)]
7180    #[wasm_bindgen(static_method_of = Object, js_name = getOwnPropertyNames, catch)]
7181    pub fn get_own_property_names<T>(obj: &Object<T>) -> Result<Array<JsString>, JsValue>;
7182
7183    /// The `Object.getOwnPropertySymbols()` method returns an array of
7184    /// all symbol properties found directly upon a given object.
7185    ///
7186    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertySymbols)
7187    #[cfg(not(js_sys_unstable_apis))]
7188    #[wasm_bindgen(static_method_of = Object, js_name = getOwnPropertySymbols)]
7189    pub fn get_own_property_symbols<T>(obj: &Object<T>) -> Array;
7190
7191    /// The `Object.getOwnPropertySymbols()` method returns an array of
7192    /// all symbol properties found directly upon a given object.
7193    ///
7194    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertySymbols)
7195    #[cfg(js_sys_unstable_apis)]
7196    #[wasm_bindgen(static_method_of = Object, js_name = getOwnPropertySymbols, catch)]
7197    pub fn get_own_property_symbols<T>(obj: &Object<T>) -> Result<Array<Symbol>, JsValue>;
7198
7199    /// The `Object.getPrototypeOf()` method returns the prototype
7200    /// (i.e. the value of the internal [[Prototype]] property) of the
7201    /// specified object.
7202    ///
7203    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getPrototypeOf)
7204    #[wasm_bindgen(static_method_of = Object, js_name = getPrototypeOf)]
7205    pub fn get_prototype_of(obj: &JsValue) -> Object;
7206
7207    /// The `hasOwnProperty()` method returns a boolean indicating whether the
7208    /// object has the specified property as its own property (as opposed to
7209    /// inheriting it).
7210    ///
7211    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty)
7212    #[deprecated(note = "Use `Object::hasOwn` instead.")]
7213    #[allow(deprecated)]
7214    #[wasm_bindgen(method, js_name = hasOwnProperty)]
7215    pub fn has_own_property<T>(this: &Object<T>, property: &JsValue) -> bool;
7216
7217    /// The `Object.hasOwn()` method returns a boolean indicating whether the
7218    /// object passed in has the specified property as its own property (as
7219    /// opposed to inheriting it).
7220    ///
7221    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwn)
7222    #[cfg(not(js_sys_unstable_apis))]
7223    #[wasm_bindgen(static_method_of = Object, js_name = hasOwn)]
7224    pub fn has_own<T>(instance: &Object<T>, property: &JsValue) -> bool;
7225
7226    /// The `Object.hasOwn()` method returns a boolean indicating whether the
7227    /// object passed in has the specified property as its own property (as
7228    /// opposed to inheriting it).
7229    ///
7230    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwn)
7231    #[cfg(js_sys_unstable_apis)]
7232    #[wasm_bindgen(static_method_of = Object, js_name = hasOwn, catch)]
7233    pub fn has_own<T>(instance: &Object<T>, property: &JsString) -> Result<bool, JsValue>;
7234
7235    // Next major: deprecate
7236    /// The `Object.hasOwn()` method returns a boolean indicating whether the
7237    /// object passed in has the specified property as its own property (as
7238    /// opposed to inheriting it).
7239    ///
7240    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwn)
7241    #[wasm_bindgen(static_method_of = Object, js_name = hasOwn, catch)]
7242    pub fn has_own_str<T>(instance: &Object<T>, property: &JsString) -> Result<bool, JsValue>;
7243
7244    /// The `Object.hasOwn()` method returns a boolean indicating whether the
7245    /// object passed in has the specified property as its own property (as
7246    /// opposed to inheriting it).
7247    ///
7248    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwn)
7249    #[wasm_bindgen(static_method_of = Object, js_name = hasOwn, catch)]
7250    pub fn has_own_symbol<T>(instance: &Object<T>, property: &Symbol) -> Result<bool, JsValue>;
7251
7252    /// The `Object.is()` method determines whether two values are the same value.
7253    ///
7254    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is)
7255    #[wasm_bindgen(static_method_of = Object)]
7256    pub fn is(value1: &JsValue, value_2: &JsValue) -> bool;
7257
7258    /// The `Object.isExtensible()` method determines if an object is extensible
7259    /// (whether it can have new properties added to it).
7260    ///
7261    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isExtensible)
7262    #[wasm_bindgen(static_method_of = Object, js_name = isExtensible)]
7263    pub fn is_extensible<T>(object: &Object<T>) -> bool;
7264
7265    /// The `Object.isFrozen()` determines if an object is frozen.
7266    ///
7267    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isFrozen)
7268    #[wasm_bindgen(static_method_of = Object, js_name = isFrozen)]
7269    pub fn is_frozen<T>(object: &Object<T>) -> bool;
7270
7271    /// The `Object.isSealed()` method determines if an object is sealed.
7272    ///
7273    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isSealed)
7274    #[wasm_bindgen(static_method_of = Object, js_name = isSealed)]
7275    pub fn is_sealed<T>(object: &Object<T>) -> bool;
7276
7277    /// The `isPrototypeOf()` method checks if an object exists in another
7278    /// object's prototype chain.
7279    ///
7280    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isPrototypeOf)
7281    #[wasm_bindgen(method, js_name = isPrototypeOf)]
7282    pub fn is_prototype_of<T>(this: &Object<T>, value: &JsValue) -> bool;
7283
7284    /// The `Object.keys()` method returns an array of a given object's property
7285    /// names, in the same order as we get with a normal loop.
7286    ///
7287    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys)
7288    #[cfg(not(js_sys_unstable_apis))]
7289    #[wasm_bindgen(static_method_of = Object)]
7290    pub fn keys<T>(object: &Object<T>) -> Array;
7291
7292    /// The `Object.keys()` method returns an array of a given object's property
7293    /// names, in the same order as we get with a normal loop.
7294    ///
7295    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys)
7296    #[cfg(js_sys_unstable_apis)]
7297    #[wasm_bindgen(static_method_of = Object)]
7298    pub fn keys<T>(object: &Object<T>) -> Array<JsString>;
7299
7300    /// The [`Object`] constructor creates an object wrapper.
7301    ///
7302    /// **Note:** Consider using [`Object::new_typed`] for typed object records.
7303    ///
7304    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)
7305    #[wasm_bindgen(constructor)]
7306    pub fn new() -> Object;
7307
7308    // Next major: deprecate
7309    /// The [`Object`] constructor creates an object wrapper.
7310    ///
7311    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)
7312    #[wasm_bindgen(constructor)]
7313    pub fn new_typed<T>() -> Object<T>;
7314
7315    /// The `Object.preventExtensions()` method prevents new properties from
7316    /// ever being added to an object (i.e. prevents future extensions to the
7317    /// object).
7318    ///
7319    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/preventExtensions)
7320    #[wasm_bindgen(static_method_of = Object, js_name = preventExtensions)]
7321    pub fn prevent_extensions<T>(object: &Object<T>);
7322
7323    /// The `propertyIsEnumerable()` method returns a Boolean indicating
7324    /// whether the specified property is enumerable.
7325    ///
7326    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/propertyIsEnumerable)
7327    #[wasm_bindgen(method, js_name = propertyIsEnumerable)]
7328    pub fn property_is_enumerable<T>(this: &Object<T>, property: &JsValue) -> bool;
7329
7330    /// The `Object.seal()` method seals an object, preventing new properties
7331    /// from being added to it and marking all existing properties as
7332    /// non-configurable.  Values of present properties can still be changed as
7333    /// long as they are writable.
7334    ///
7335    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/seal)
7336    #[wasm_bindgen(static_method_of = Object)]
7337    pub fn seal<T>(value: &Object<T>) -> Object<T>;
7338
7339    /// The `Object.setPrototypeOf()` method sets the prototype (i.e., the
7340    /// internal `[[Prototype]]` property) of a specified object to another
7341    /// object or `null`.
7342    ///
7343    /// **Note:** Consider using [`Object::try_set_prototype_of`] to support errors.
7344    ///
7345    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/setPrototypeOf)
7346    #[wasm_bindgen(static_method_of = Object, js_name = setPrototypeOf)]
7347    pub fn set_prototype_of<T>(object: &Object<T>, prototype: &Object) -> Object<T>;
7348
7349    /// The `Object.setPrototypeOf()` method sets the prototype (i.e., the
7350    /// internal `[[Prototype]]` property) of a specified object to another
7351    /// object or `null`.
7352    ///
7353    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/setPrototypeOf)
7354    #[wasm_bindgen(static_method_of = Object, js_name = setPrototypeOf, catch)]
7355    pub fn try_set_prototype_of<T>(
7356        object: &Object<T>,
7357        prototype: &Object,
7358    ) -> Result<Object<T>, JsValue>;
7359
7360    /// The `toLocaleString()` method returns a string representing the object.
7361    /// This method is meant to be overridden by derived objects for
7362    /// locale-specific purposes.
7363    ///
7364    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toLocaleString)
7365    #[wasm_bindgen(method, js_name = toLocaleString)]
7366    pub fn to_locale_string<T>(this: &Object<T>) -> JsString;
7367
7368    // Next major: deprecate
7369    /// The `toString()` method returns a string representing the object.
7370    ///
7371    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString)
7372    #[wasm_bindgen(method, js_name = toString)]
7373    pub fn to_string<T>(this: &Object<T>) -> JsString;
7374
7375    /// The `toString()` method returns a string representing the object.
7376    ///
7377    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString)
7378    #[wasm_bindgen(method, js_name = toString)]
7379    pub fn to_js_string<T>(this: &Object<T>) -> JsString;
7380
7381    /// The `valueOf()` method returns the primitive value of the
7382    /// specified object.
7383    ///
7384    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/valueOf)
7385    #[wasm_bindgen(method, js_name = valueOf)]
7386    pub fn value_of<T>(this: &Object<T>) -> Object;
7387
7388    /// The `Object.values()` method returns an array of a given object's own
7389    /// enumerable property values, in the same order as that provided by a
7390    /// `for...in` loop (the difference being that a for-in loop enumerates
7391    /// properties in the prototype chain as well).
7392    ///
7393    /// **Note:** Consider using [`Object::try_values`] to support errors.
7394    ///
7395    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/values)
7396    #[cfg(not(js_sys_unstable_apis))]
7397    #[wasm_bindgen(static_method_of = Object)]
7398    pub fn values<T>(object: &Object<T>) -> Array<T>;
7399
7400    /// The `Object.values()` method returns an array of a given object's own
7401    /// enumerable property values, in the same order as that provided by a
7402    /// `for...in` loop (the difference being that a for-in loop enumerates
7403    /// properties in the prototype chain as well).
7404    ///
7405    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/values)
7406    #[cfg(js_sys_unstable_apis)]
7407    #[wasm_bindgen(static_method_of = Object, catch, js_name = values)]
7408    pub fn values<T>(object: &Object<T>) -> Result<Array<T>, JsValue>;
7409
7410    // Next major: deprecate
7411    /// The `Object.values()` method returns an array of a given object's own
7412    /// enumerable property values, in the same order as that provided by a
7413    /// `for...in` loop (the difference being that a for-in loop enumerates
7414    /// properties in the prototype chain as well).
7415    ///
7416    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/values)
7417    #[cfg(not(js_sys_unstable_apis))]
7418    #[wasm_bindgen(static_method_of = Object, catch, js_name = values)]
7419    pub fn try_values<T>(object: &Object<T>) -> Result<Array<T>, JsValue>;
7420}
7421
7422impl Object {
7423    /// Returns the `Object` value of this JS value if it's an instance of an
7424    /// object.
7425    ///
7426    /// If this JS value is not an instance of an object then this returns
7427    /// `None`.
7428    pub fn try_from(val: &JsValue) -> Option<&Object> {
7429        if val.is_object() {
7430            Some(val.unchecked_ref())
7431        } else {
7432            None
7433        }
7434    }
7435}
7436
7437impl PartialEq for Object {
7438    #[inline]
7439    fn eq(&self, other: &Object) -> bool {
7440        Object::is(self.as_ref(), other.as_ref())
7441    }
7442}
7443
7444impl Eq for Object {}
7445
7446impl Default for Object<JsValue> {
7447    fn default() -> Self {
7448        Self::new()
7449    }
7450}
7451
7452// Proxy
7453#[wasm_bindgen]
7454extern "C" {
7455    #[wasm_bindgen(typescript_type = "ProxyConstructor")]
7456    #[derive(Clone, Debug)]
7457    pub type Proxy;
7458
7459    /// The [`Proxy`] object is used to define custom behavior for fundamental
7460    /// operations (e.g. property lookup, assignment, enumeration, function
7461    /// invocation, etc).
7462    ///
7463    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy)
7464    #[wasm_bindgen(constructor)]
7465    pub fn new(target: &JsValue, handler: &Object) -> Proxy;
7466
7467    /// The `Proxy.revocable()` method is used to create a revocable [`Proxy`]
7468    /// object.
7469    ///
7470    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/revocable)
7471    #[wasm_bindgen(static_method_of = Proxy)]
7472    pub fn revocable(target: &JsValue, handler: &Object) -> Object;
7473}
7474
7475// RangeError
7476#[wasm_bindgen]
7477extern "C" {
7478    /// The `RangeError` object indicates an error when a value is not in the set
7479    /// or range of allowed values.
7480    ///
7481    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError)
7482    #[wasm_bindgen(extends = Error, extends = Object, typescript_type = "RangeError")]
7483    #[derive(Clone, Debug, PartialEq, Eq)]
7484    pub type RangeError;
7485
7486    /// The `RangeError` object indicates an error when a value is not in the set
7487    /// or range of allowed values.
7488    ///
7489    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError)
7490    #[wasm_bindgen(constructor)]
7491    pub fn new(message: &str) -> RangeError;
7492
7493    /// Creates a new `RangeError` with the given message and a typed
7494    /// [`ErrorOptions`] dictionary whose `cause` property indicates the
7495    /// original cause of the error.
7496    ///
7497    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError/RangeError)
7498    #[wasm_bindgen(constructor)]
7499    pub fn new_with_options(message: &str, options: &ErrorOptions) -> RangeError;
7500}
7501
7502// ReferenceError
7503#[wasm_bindgen]
7504extern "C" {
7505    /// The `ReferenceError` object represents an error when a non-existent
7506    /// variable is referenced.
7507    ///
7508    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError)
7509    #[wasm_bindgen(extends = Error, extends = Object, typescript_type = "ReferenceError")]
7510    #[derive(Clone, Debug, PartialEq, Eq)]
7511    pub type ReferenceError;
7512
7513    /// The `ReferenceError` object represents an error when a non-existent
7514    /// variable is referenced.
7515    ///
7516    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError)
7517    #[wasm_bindgen(constructor)]
7518    pub fn new(message: &str) -> ReferenceError;
7519
7520    /// Creates a new `ReferenceError` with the given message and a typed
7521    /// [`ErrorOptions`] dictionary whose `cause` property indicates the
7522    /// original cause of the error.
7523    ///
7524    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError/ReferenceError)
7525    #[wasm_bindgen(constructor)]
7526    pub fn new_with_options(message: &str, options: &ErrorOptions) -> ReferenceError;
7527}
7528
7529#[allow(non_snake_case)]
7530pub mod Reflect {
7531    use super::*;
7532
7533    // Reflect
7534    #[wasm_bindgen]
7535    extern "C" {
7536        /// The static `Reflect.apply()` method calls a target function with
7537        /// arguments as specified.
7538        ///
7539        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/apply)
7540        #[wasm_bindgen(js_namespace = Reflect, catch)]
7541        pub fn apply<T: JsFunction = fn() -> JsValue>(
7542            target: &Function<T>,
7543            this_argument: &JsValue,
7544            arguments_list: &Array,
7545        ) -> Result<<T as JsFunction>::Ret, JsValue>;
7546
7547        /// The static `Reflect.construct()` method acts like the new operator, but
7548        /// as a function.  It is equivalent to calling `new target(...args)`. It
7549        /// gives also the added option to specify a different prototype.
7550        ///
7551        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/construct)
7552        #[cfg(not(js_sys_unstable_apis))]
7553        #[wasm_bindgen(js_namespace = Reflect, catch)]
7554        pub fn construct<T: JsFunction = fn() -> JsValue>(
7555            target: &Function<T>,
7556            arguments_list: &Array,
7557        ) -> Result<JsValue, JsValue>;
7558
7559        /// The static `Reflect.construct()` method acts like the new operator, but
7560        /// as a function.  It is equivalent to calling `new target(...args)`. It
7561        /// gives also the added option to specify a different prototype.
7562        ///
7563        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/construct)
7564        #[cfg(js_sys_unstable_apis)]
7565        #[wasm_bindgen(js_namespace = Reflect, catch)]
7566        pub fn construct<T: JsFunction = fn() -> JsValue>(
7567            target: &Function<T>,
7568            arguments_list: &ArrayTuple, // DOTO: <A1, A2, A3, A4, A5, A6, A7, A8>,
7569        ) -> Result<JsValue, JsValue>;
7570
7571        /// The static `Reflect.construct()` method acts like the new operator, but
7572        /// as a function.  It is equivalent to calling `new target(...args)`. It
7573        /// gives also the added option to specify a different prototype.
7574        ///
7575        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/construct)
7576        #[wasm_bindgen(js_namespace = Reflect, js_name = construct, catch)]
7577        pub fn construct_with_new_target(
7578            target: &Function,
7579            arguments_list: &Array,
7580            new_target: &Function,
7581        ) -> Result<JsValue, JsValue>;
7582
7583        /// The static `Reflect.defineProperty()` method is like
7584        /// `Object.defineProperty()` but returns a `Boolean`.
7585        ///
7586        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/defineProperty)
7587        #[cfg(not(js_sys_unstable_apis))]
7588        #[wasm_bindgen(js_namespace = Reflect, js_name = defineProperty, catch)]
7589        pub fn define_property<T>(
7590            target: &Object<T>,
7591            property_key: &JsValue,
7592            attributes: &Object,
7593        ) -> Result<bool, JsValue>;
7594
7595        /// The static `Reflect.defineProperty()` method is like
7596        /// `Object.defineProperty()` but returns a `Boolean`.
7597        ///
7598        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/defineProperty)
7599        #[cfg(js_sys_unstable_apis)]
7600        #[wasm_bindgen(js_namespace = Reflect, js_name = defineProperty, catch)]
7601        pub fn define_property<T>(
7602            target: &Object<T>,
7603            property_key: &JsValue,
7604            attributes: &PropertyDescriptor<T>,
7605        ) -> Result<bool, JsValue>;
7606
7607        /// The static `Reflect.defineProperty()` method is like
7608        /// `Object.defineProperty()` but returns a `Boolean`.
7609        ///
7610        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/defineProperty)
7611        #[wasm_bindgen(js_namespace = Reflect, js_name = defineProperty, catch)]
7612        pub fn define_property_str<T>(
7613            target: &Object<T>,
7614            property_key: &JsString,
7615            attributes: &PropertyDescriptor<T>,
7616        ) -> Result<bool, JsValue>;
7617
7618        /// The static `Reflect.deleteProperty()` method allows to delete
7619        /// properties.  It is like the `delete` operator as a function.
7620        ///
7621        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/deleteProperty)
7622        #[wasm_bindgen(js_namespace = Reflect, js_name = deleteProperty, catch)]
7623        pub fn delete_property<T>(target: &Object<T>, key: &JsValue) -> Result<bool, JsValue>;
7624
7625        /// The static `Reflect.deleteProperty()` method allows to delete
7626        /// properties.  It is like the `delete` operator as a function.
7627        ///
7628        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/deleteProperty)
7629        #[wasm_bindgen(js_namespace = Reflect, js_name = deleteProperty, catch)]
7630        pub fn delete_property_str<T>(target: &Object<T>, key: &JsString) -> Result<bool, JsValue>;
7631
7632        /// The static `Reflect.get()` method works like getting a property from
7633        /// an object (`target[propertyKey]`) as a function.
7634        ///
7635        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/get)
7636        #[cfg(not(js_sys_unstable_apis))]
7637        #[wasm_bindgen(js_namespace = Reflect, catch)]
7638        pub fn get(target: &JsValue, key: &JsValue) -> Result<JsValue, JsValue>;
7639
7640        /// The static `Reflect.get()` method works like getting a property from
7641        /// an object (`target[propertyKey]`) as a function.
7642        ///
7643        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/get)
7644        #[cfg(js_sys_unstable_apis)]
7645        #[wasm_bindgen(js_namespace = Reflect, catch)]
7646        pub fn get<T>(target: &Object<T>, key: &JsString) -> Result<Option<T>, JsValue>;
7647
7648        /// The static `Reflect.get()` method works like getting a property from
7649        /// an object (`target[propertyKey]`) as a function.
7650        ///
7651        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/get)
7652        #[wasm_bindgen(js_namespace = Reflect, js_name = get, catch)]
7653        pub fn get_str<T>(target: &Object<T>, key: &JsString) -> Result<Option<T>, JsValue>;
7654
7655        /// The static `Reflect.get()` method works like getting a property from
7656        /// an object (`target[propertyKey]`) as a function.
7657        ///
7658        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/get)
7659        #[wasm_bindgen(js_namespace = Reflect, js_name = get, catch)]
7660        pub fn get_symbol<T>(target: &Object<T>, key: &Symbol) -> Result<JsValue, JsValue>;
7661
7662        /// The same as [`get`](fn.get.html)
7663        /// except the key is an `f64`, which is slightly faster.
7664        #[wasm_bindgen(js_namespace = Reflect, js_name = get, catch)]
7665        pub fn get_f64(target: &JsValue, key: f64) -> Result<JsValue, JsValue>;
7666
7667        /// The same as [`get`](fn.get.html)
7668        /// except the key is a `u32`, which is slightly faster.
7669        #[wasm_bindgen(js_namespace = Reflect, js_name = get, catch)]
7670        pub fn get_u32(target: &JsValue, key: u32) -> Result<JsValue, JsValue>;
7671
7672        /// The static `Reflect.getOwnPropertyDescriptor()` method is similar to
7673        /// `Object.getOwnPropertyDescriptor()`. It returns a property descriptor
7674        /// of the given property if it exists on the object, `undefined` otherwise.
7675        ///
7676        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/getOwnPropertyDescriptor)
7677        #[wasm_bindgen(js_namespace = Reflect, js_name = getOwnPropertyDescriptor, catch)]
7678        pub fn get_own_property_descriptor<T>(
7679            target: &Object<T>,
7680            property_key: &JsValue,
7681        ) -> Result<JsValue, JsValue>;
7682
7683        /// The static `Reflect.getOwnPropertyDescriptor()` method is similar to
7684        /// `Object.getOwnPropertyDescriptor()`. It returns a property descriptor
7685        /// of the given property if it exists on the object, `undefined` otherwise.
7686        ///
7687        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/getOwnPropertyDescriptor)
7688        #[wasm_bindgen(js_namespace = Reflect, js_name = getOwnPropertyDescriptor, catch)]
7689        pub fn get_own_property_descriptor_str<T>(
7690            target: &Object<T>,
7691            property_key: &JsString,
7692        ) -> Result<PropertyDescriptor<T>, JsValue>;
7693
7694        /// The static `Reflect.getPrototypeOf()` method is almost the same
7695        /// method as `Object.getPrototypeOf()`. It returns the prototype
7696        /// (i.e. the value of the internal `[[Prototype]]` property) of
7697        /// the specified object.
7698        ///
7699        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/getPrototypeOf)
7700        #[cfg(not(js_sys_unstable_apis))]
7701        #[wasm_bindgen(js_namespace = Reflect, js_name = getPrototypeOf, catch)]
7702        pub fn get_prototype_of(target: &JsValue) -> Result<Object, JsValue>;
7703
7704        /// The static `Reflect.getPrototypeOf()` method is almost the same
7705        /// method as `Object.getPrototypeOf()`. It returns the prototype
7706        /// (i.e. the value of the internal `[[Prototype]]` property) of
7707        /// the specified object.
7708        ///
7709        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/getPrototypeOf)
7710        #[cfg(js_sys_unstable_apis)]
7711        #[wasm_bindgen(js_namespace = Reflect, js_name = getPrototypeOf, catch)]
7712        pub fn get_prototype_of(target: &Object) -> Result<Object, JsValue>;
7713
7714        /// The static `Reflect.has()` method works like the in operator as a
7715        /// function.
7716        ///
7717        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/has)
7718        #[cfg(not(js_sys_unstable_apis))]
7719        #[wasm_bindgen(js_namespace = Reflect, catch)]
7720        pub fn has(target: &JsValue, property_key: &JsValue) -> Result<bool, JsValue>;
7721
7722        /// The static `Reflect.has()` method works like the in operator as a
7723        /// function.
7724        ///
7725        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/has)
7726        #[cfg(js_sys_unstable_apis)]
7727        #[wasm_bindgen(js_namespace = Reflect, catch)]
7728        pub fn has(target: &JsValue, property_key: &Symbol) -> Result<bool, JsValue>;
7729
7730        // Next major: deprecate
7731        /// The static `Reflect.has()` method works like the in operator as a
7732        /// function.
7733        ///
7734        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/has)
7735        #[wasm_bindgen(js_namespace = Reflect, js_name = has, catch)]
7736        pub fn has_str<T>(target: &Object<T>, property_key: &JsString) -> Result<bool, JsValue>;
7737
7738        /// The static `Reflect.has()` method works like the in operator as a
7739        /// function.
7740        ///
7741        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/has)
7742        #[wasm_bindgen(js_namespace = Reflect, js_name = has, catch)]
7743        pub fn has_symbol<T>(target: &Object<T>, property_key: &Symbol) -> Result<bool, JsValue>;
7744
7745        /// The static `Reflect.isExtensible()` method determines if an object is
7746        /// extensible (whether it can have new properties added to it). It is
7747        /// similar to `Object.isExtensible()`, but with some differences.
7748        ///
7749        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/isExtensible)
7750        #[wasm_bindgen(js_namespace = Reflect, js_name = isExtensible, catch)]
7751        pub fn is_extensible<T>(target: &Object<T>) -> Result<bool, JsValue>;
7752
7753        /// The static `Reflect.ownKeys()` method returns an array of the
7754        /// target object's own property keys.
7755        ///
7756        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/ownKeys)
7757        #[wasm_bindgen(js_namespace = Reflect, js_name = ownKeys, catch)]
7758        pub fn own_keys(target: &JsValue) -> Result<Array, JsValue>;
7759
7760        /// The static `Reflect.preventExtensions()` method prevents new
7761        /// properties from ever being added to an object (i.e. prevents
7762        /// future extensions to the object). It is similar to
7763        /// `Object.preventExtensions()`, but with some differences.
7764        ///
7765        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/preventExtensions)
7766        #[wasm_bindgen(js_namespace = Reflect, js_name = preventExtensions, catch)]
7767        pub fn prevent_extensions<T>(target: &Object<T>) -> Result<bool, JsValue>;
7768
7769        /// The static `Reflect.set()` method works like setting a
7770        /// property on an object.
7771        ///
7772        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/set)
7773        #[cfg(not(js_sys_unstable_apis))]
7774        #[wasm_bindgen(js_namespace = Reflect, catch)]
7775        pub fn set(
7776            target: &JsValue,
7777            property_key: &JsValue,
7778            value: &JsValue,
7779        ) -> Result<bool, JsValue>;
7780
7781        /// The static `Reflect.set()` method works like setting a
7782        /// property on an object.
7783        ///
7784        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/set)
7785        #[cfg(js_sys_unstable_apis)]
7786        #[wasm_bindgen(js_namespace = Reflect, catch)]
7787        pub fn set<T>(
7788            target: &Object<T>,
7789            property_key: &JsString,
7790            value: &T,
7791        ) -> Result<bool, JsValue>;
7792
7793        /// The static `Reflect.set()` method works like setting a
7794        /// property on an object.
7795        ///
7796        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/set)
7797        #[cfg(js_sys_unstable_apis)]
7798        #[wasm_bindgen(js_namespace = Reflect, catch)]
7799        pub fn set_symbol<T>(
7800            target: &Object<T>,
7801            property_key: &Symbol,
7802            value: &JsValue,
7803        ) -> Result<bool, JsValue>;
7804
7805        // Next major: deprecate
7806        /// The static `Reflect.set()` method works like setting a
7807        /// property on an object.
7808        ///
7809        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/set)
7810        #[wasm_bindgen(js_namespace = Reflect, js_name = set, catch)]
7811        pub fn set_str<T>(
7812            target: &Object<T>,
7813            property_key: &JsString,
7814            value: &T,
7815        ) -> Result<bool, JsValue>;
7816
7817        /// The same as [`set`](fn.set.html)
7818        /// except the key is an `f64`, which is slightly faster.
7819        #[wasm_bindgen(js_namespace = Reflect, js_name = set, catch)]
7820        pub fn set_f64(
7821            target: &JsValue,
7822            property_key: f64,
7823            value: &JsValue,
7824        ) -> Result<bool, JsValue>;
7825
7826        /// The same as [`set`](fn.set.html)
7827        /// except the key is a `u32`, which is slightly faster.
7828        #[wasm_bindgen(js_namespace = Reflect, js_name = set, catch)]
7829        pub fn set_u32(
7830            target: &JsValue,
7831            property_key: u32,
7832            value: &JsValue,
7833        ) -> Result<bool, JsValue>;
7834
7835        /// The static `Reflect.set()` method works like setting a
7836        /// property on an object.
7837        ///
7838        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/set)
7839        #[wasm_bindgen(js_namespace = Reflect, js_name = set, catch)]
7840        pub fn set_with_receiver(
7841            target: &JsValue,
7842            property_key: &JsValue,
7843            value: &JsValue,
7844            receiver: &JsValue,
7845        ) -> Result<bool, JsValue>;
7846
7847        /// The static `Reflect.setPrototypeOf()` method is the same
7848        /// method as `Object.setPrototypeOf()`. It sets the prototype
7849        /// (i.e., the internal `[[Prototype]]` property) of a specified
7850        /// object to another object or to null.
7851        ///
7852        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/setPrototypeOf)
7853        #[wasm_bindgen(js_namespace = Reflect, js_name = setPrototypeOf, catch)]
7854        pub fn set_prototype_of<T>(
7855            target: &Object<T>,
7856            prototype: &JsValue,
7857        ) -> Result<bool, JsValue>;
7858    }
7859}
7860
7861// RegExp
7862#[wasm_bindgen]
7863extern "C" {
7864    #[wasm_bindgen(extends = Object, typescript_type = "RegExp")]
7865    #[derive(Clone, Debug, PartialEq, Eq)]
7866    pub type RegExp;
7867
7868    /// The `exec()` method executes a search for a match in a specified
7869    /// string. Returns a result array, or null.
7870    ///
7871    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec)
7872    #[cfg(not(js_sys_unstable_apis))]
7873    #[wasm_bindgen(method)]
7874    pub fn exec(this: &RegExp, text: &str) -> Option<Array<JsString>>;
7875
7876    /// The `exec()` method executes a search for a match in a specified
7877    /// string. Returns a result array, or null.
7878    ///
7879    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec)
7880    #[cfg(js_sys_unstable_apis)]
7881    #[wasm_bindgen(method)]
7882    pub fn exec(this: &RegExp, text: &str) -> Option<RegExpMatchArray>;
7883
7884    /// The flags property returns a string consisting of the flags of
7885    /// the current regular expression object.
7886    ///
7887    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/flags)
7888    #[wasm_bindgen(method, getter)]
7889    pub fn flags(this: &RegExp) -> JsString;
7890
7891    /// The global property indicates whether or not the "g" flag is
7892    /// used with the regular expression. global is a read-only
7893    /// property of an individual regular expression instance.
7894    ///
7895    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/global)
7896    #[wasm_bindgen(method, getter)]
7897    pub fn global(this: &RegExp) -> bool;
7898
7899    /// The ignoreCase property indicates whether or not the "i" flag
7900    /// is used with the regular expression. ignoreCase is a read-only
7901    /// property of an individual regular expression instance.
7902    ///
7903    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/ignoreCase)
7904    #[wasm_bindgen(method, getter, js_name = ignoreCase)]
7905    pub fn ignore_case(this: &RegExp) -> bool;
7906
7907    /// The non-standard input property is a static property of
7908    /// regular expressions that contains the string against which a
7909    /// regular expression is matched. RegExp.$_ is an alias for this
7910    /// property.
7911    ///
7912    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/input)
7913    #[wasm_bindgen(static_method_of = RegExp, getter)]
7914    pub fn input() -> JsString;
7915
7916    /// The lastIndex is a read/write integer property of regular expression
7917    /// instances that specifies the index at which to start the next match.
7918    ///
7919    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastIndex)
7920    #[wasm_bindgen(structural, getter = lastIndex, method)]
7921    pub fn last_index(this: &RegExp) -> u32;
7922
7923    /// The lastIndex is a read/write integer property of regular expression
7924    /// instances that specifies the index at which to start the next match.
7925    ///
7926    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastIndex)
7927    #[wasm_bindgen(structural, setter = lastIndex, method)]
7928    pub fn set_last_index(this: &RegExp, index: u32);
7929
7930    /// The non-standard lastMatch property is a static and read-only
7931    /// property of regular expressions that contains the last matched
7932    /// characters. `RegExp.$&` is an alias for this property.
7933    ///
7934    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastMatch)
7935    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = lastMatch)]
7936    pub fn last_match() -> JsString;
7937
7938    /// The non-standard lastParen property is a static and read-only
7939    /// property of regular expressions that contains the last
7940    /// parenthesized substring match, if any. `RegExp.$+` is an alias
7941    /// for this property.
7942    ///
7943    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastParen)
7944    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = lastParen)]
7945    pub fn last_paren() -> JsString;
7946
7947    /// The non-standard leftContext property is a static and
7948    /// read-only property of regular expressions that contains the
7949    /// substring preceding the most recent match. `RegExp.$`` is an
7950    /// alias for this property.
7951    ///
7952    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/leftContext)
7953    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = leftContext)]
7954    pub fn left_context() -> JsString;
7955
7956    /// The multiline property indicates whether or not the "m" flag
7957    /// is used with the regular expression. multiline is a read-only
7958    /// property of an individual regular expression instance.
7959    ///
7960    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/multiline)
7961    #[wasm_bindgen(method, getter)]
7962    pub fn multiline(this: &RegExp) -> bool;
7963
7964    /// The non-standard $1, $2, $3, $4, $5, $6, $7, $8, $9 properties
7965    /// are static and read-only properties of regular expressions
7966    /// that contain parenthesized substring matches.
7967    ///
7968    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/n)
7969    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$1")]
7970    pub fn n1() -> JsString;
7971    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$2")]
7972    pub fn n2() -> JsString;
7973    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$3")]
7974    pub fn n3() -> JsString;
7975    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$4")]
7976    pub fn n4() -> JsString;
7977    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$5")]
7978    pub fn n5() -> JsString;
7979    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$6")]
7980    pub fn n6() -> JsString;
7981    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$7")]
7982    pub fn n7() -> JsString;
7983    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$8")]
7984    pub fn n8() -> JsString;
7985    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$9")]
7986    pub fn n9() -> JsString;
7987
7988    /// The `RegExp` constructor creates a regular expression object for matching text with a pattern.
7989    ///
7990    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp)
7991    #[wasm_bindgen(constructor)]
7992    pub fn new(pattern: &str, flags: &str) -> RegExp;
7993    #[wasm_bindgen(constructor)]
7994    pub fn new_regexp(pattern: &RegExp, flags: &str) -> RegExp;
7995
7996    /// The non-standard rightContext property is a static and
7997    /// read-only property of regular expressions that contains the
7998    /// substring following the most recent match. `RegExp.$'` is an
7999    /// alias for this property.
8000    ///
8001    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/rightContext)
8002    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = rightContext)]
8003    pub fn right_context() -> JsString;
8004
8005    /// The source property returns a String containing the source
8006    /// text of the regexp object, and it doesn't contain the two
8007    /// forward slashes on both sides and any flags.
8008    ///
8009    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/source)
8010    #[wasm_bindgen(method, getter)]
8011    pub fn source(this: &RegExp) -> JsString;
8012
8013    /// The sticky property reflects whether or not the search is
8014    /// sticky (searches in strings only from the index indicated by
8015    /// the lastIndex property of this regular expression). sticky is
8016    /// a read-only property of an individual regular expression
8017    /// object.
8018    ///
8019    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/sticky)
8020    #[wasm_bindgen(method, getter)]
8021    pub fn sticky(this: &RegExp) -> bool;
8022
8023    /// The `test()` method executes a search for a match between a
8024    /// regular expression and a specified string. Returns true or
8025    /// false.
8026    ///
8027    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test)
8028    #[wasm_bindgen(method)]
8029    pub fn test(this: &RegExp, text: &str) -> bool;
8030
8031    /// The `toString()` method returns a string representing the
8032    /// regular expression.
8033    ///
8034    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/toString)
8035    #[cfg(not(js_sys_unstable_apis))]
8036    #[wasm_bindgen(method, js_name = toString)]
8037    pub fn to_string(this: &RegExp) -> JsString;
8038
8039    /// The unicode property indicates whether or not the "u" flag is
8040    /// used with a regular expression. unicode is a read-only
8041    /// property of an individual regular expression instance.
8042    ///
8043    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/unicode)
8044    #[wasm_bindgen(method, getter)]
8045    pub fn unicode(this: &RegExp) -> bool;
8046}
8047
8048// RegExpMatchArray
8049#[wasm_bindgen]
8050extern "C" {
8051    /// The result array from `RegExp.exec()` or `String.matchAll()`.
8052    ///
8053    /// This is an array of strings with additional properties `index`, `input`, and `groups`.
8054    ///
8055    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec#return_value)
8056    #[wasm_bindgen(extends = Object, extends = Array, typescript_type = "RegExpMatchArray")]
8057    #[derive(Clone, Debug, PartialEq, Eq)]
8058    pub type RegExpMatchArray;
8059
8060    /// The 0-based index of the match in the string.
8061    #[wasm_bindgen(method, getter)]
8062    pub fn index(this: &RegExpMatchArray) -> u32;
8063
8064    /// The original string that was matched against.
8065    #[wasm_bindgen(method, getter)]
8066    pub fn input(this: &RegExpMatchArray) -> JsString;
8067
8068    /// An object of named capturing groups whose keys are the names and valuestype Array
8069    /// are the capturing groups, or `undefined` if no named capturing groups were defined.
8070    #[wasm_bindgen(method, getter)]
8071    pub fn groups(this: &RegExpMatchArray) -> Option<Object>;
8072
8073    /// The number of elements in the match array (full match + capture groups).
8074    #[wasm_bindgen(method, getter)]
8075    pub fn length(this: &RegExpMatchArray) -> u32;
8076
8077    /// Gets the matched string or capture group at the given index.
8078    /// Index 0 is the full match, indices 1+ are capture groups.
8079    #[wasm_bindgen(method, indexing_getter)]
8080    pub fn get(this: &RegExpMatchArray, index: u32) -> Option<JsString>;
8081}
8082
8083// Set
8084#[wasm_bindgen]
8085extern "C" {
8086    #[wasm_bindgen(extends = Object, typescript_type = "Set<any>")]
8087    #[derive(Clone, Debug, PartialEq, Eq)]
8088    pub type Set<T = JsValue>;
8089
8090    /// The [`Set`] object lets you store unique values of any type, whether
8091    /// primitive values or object references.
8092    ///
8093    /// **Note:** Consider using [`Set::new_typed`] to support typing.
8094    ///
8095    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set)
8096    #[cfg(not(js_sys_unstable_apis))]
8097    #[wasm_bindgen(constructor)]
8098    pub fn new(init: &JsValue) -> Set;
8099
8100    /// The [`Set`] object lets you store unique values of any type, whether
8101    /// primitive values or object references.
8102    ///
8103    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set)
8104    #[cfg(js_sys_unstable_apis)]
8105    #[wasm_bindgen(constructor)]
8106    pub fn new<T>() -> Set<T>;
8107
8108    // Next major: deprecate
8109    /// The [`Set`] object lets you store unique values of any type, whether
8110    /// primitive values or object references.
8111    ///
8112    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set)
8113    #[wasm_bindgen(constructor)]
8114    pub fn new_typed<T>() -> Set<T>;
8115
8116    /// The [`Set`] object lets you store unique values of any type, whether
8117    /// primitive values or object references.
8118    ///
8119    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set)
8120    #[wasm_bindgen(constructor, js_name = new)]
8121    pub fn new_empty<T>() -> Set<T>;
8122
8123    /// The [`Set`] object lets you store unique values of any type, whether
8124    /// primitive values or object references.
8125    ///
8126    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set)
8127    #[wasm_bindgen(constructor, js_name = new)]
8128    pub fn new_from_items<T>(items: &[T]) -> Set<T>;
8129
8130    /// The [`Set`] object lets you store unique values of any type, whether
8131    /// primitive values or object references.
8132    ///
8133    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set)
8134    #[wasm_bindgen(constructor, js_name = new, catch)]
8135    pub fn new_from_iterable<T, I: Iterable<Item = T>>(iterable: I) -> Result<Set<T>, JsValue>;
8136
8137    /// The `add()` method appends a new element with a specified value to the
8138    /// end of a [`Set`] object.
8139    ///
8140    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/add)
8141    #[wasm_bindgen(method)]
8142    pub fn add<T>(this: &Set<T>, value: &T) -> Set<T>;
8143
8144    /// The `clear()` method removes all elements from a [`Set`] object.
8145    ///
8146    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/clear)
8147    #[wasm_bindgen(method)]
8148    pub fn clear<T>(this: &Set<T>);
8149
8150    /// The `delete()` method removes the specified element from a [`Set`]
8151    /// object.
8152    ///
8153    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/delete)
8154    #[wasm_bindgen(method)]
8155    pub fn delete<T>(this: &Set<T>, value: &T) -> bool;
8156
8157    /// The `forEach()` method executes a provided function once for each value
8158    /// in the Set object, in insertion order.
8159    ///
8160    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/forEach)
8161    #[cfg(not(js_sys_unstable_apis))]
8162    #[wasm_bindgen(method, js_name = forEach)]
8163    pub fn for_each<T>(this: &Set<T>, callback: &mut dyn FnMut(T, T, Set<T>));
8164
8165    /// The `forEach()` method executes a provided function once for each value
8166    /// in the Set object, in insertion order.
8167    ///
8168    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/forEach)
8169    #[cfg(js_sys_unstable_apis)]
8170    #[wasm_bindgen(method, js_name = forEach)]
8171    pub fn for_each<T>(this: &Set<T>, callback: &mut dyn FnMut(T));
8172
8173    /// The `forEach()` method executes a provided function once for each value
8174    /// in the Set object, in insertion order.
8175    ///
8176    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/forEach)
8177    #[wasm_bindgen(method, js_name = forEach, catch)]
8178    pub fn try_for_each<T>(
8179        this: &Set<T>,
8180        callback: &mut dyn FnMut(T) -> Result<(), JsError>,
8181    ) -> Result<(), JsValue>;
8182
8183    /// The `has()` method returns a boolean indicating whether an element with
8184    /// the specified value exists in a [`Set`] object or not.
8185    ///
8186    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/has)
8187    #[wasm_bindgen(method)]
8188    pub fn has<T>(this: &Set<T>, value: &T) -> bool;
8189
8190    /// The size accessor property returns the number of elements in a [`Set`]
8191    /// object.
8192    ///
8193    /// [MDN documentation](https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Set/size)
8194    #[wasm_bindgen(method, getter)]
8195    pub fn size<T>(this: &Set<T>) -> u32;
8196
8197    /// The `union()` method returns a new set containing elements which are in
8198    /// either or both of this set and the given set.
8199    ///
8200    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/union)
8201    #[wasm_bindgen(method)]
8202    pub fn union<T>(this: &Set<T>, other: &Set<T>) -> Set<T>;
8203
8204    /// The `intersection()` method returns a new set containing elements which are
8205    /// in both this set and the given set.
8206    ///
8207    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/intersection)
8208    #[wasm_bindgen(method)]
8209    pub fn intersection<T>(this: &Set<T>, other: &Set<T>) -> Set<T>;
8210
8211    /// The `difference()` method returns a new set containing elements which are
8212    /// in this set but not in the given set.
8213    ///
8214    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/difference)
8215    #[wasm_bindgen(method)]
8216    pub fn difference<T>(this: &Set<T>, other: &Set<T>) -> Set<T>;
8217
8218    /// The `symmetricDifference()` method returns a new set containing elements
8219    /// which are in either this set or the given set, but not in both.
8220    ///
8221    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/symmetricDifference)
8222    #[wasm_bindgen(method, js_name = symmetricDifference)]
8223    pub fn symmetric_difference<T>(this: &Set<T>, other: &Set<T>) -> Set<T>;
8224
8225    /// The `isSubsetOf()` method returns a boolean indicating whether all elements
8226    /// of this set are in the given set.
8227    ///
8228    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/isSubsetOf)
8229    #[wasm_bindgen(method, js_name = isSubsetOf)]
8230    pub fn is_subset_of<T>(this: &Set<T>, other: &Set<T>) -> bool;
8231
8232    /// The `isSupersetOf()` method returns a boolean indicating whether all elements
8233    /// of the given set are in this set.
8234    ///
8235    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/isSupersetOf)
8236    #[wasm_bindgen(method, js_name = isSupersetOf)]
8237    pub fn is_superset_of<T>(this: &Set<T>, other: &Set<T>) -> bool;
8238
8239    /// The `isDisjointFrom()` method returns a boolean indicating whether this set
8240    /// has no elements in common with the given set.
8241    ///
8242    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/isDisjointFrom)
8243    #[wasm_bindgen(method, js_name = isDisjointFrom)]
8244    pub fn is_disjoint_from<T>(this: &Set<T>, other: &Set<T>) -> bool;
8245}
8246
8247impl Default for Set<JsValue> {
8248    fn default() -> Self {
8249        Self::new_typed()
8250    }
8251}
8252
8253impl<T> Iterable for Set<T> {
8254    type Item = T;
8255}
8256
8257// SetIterator
8258#[wasm_bindgen]
8259extern "C" {
8260    /// The `entries()` method returns a new Iterator object that contains an
8261    /// array of [value, value] for each element in the Set object, in insertion
8262    /// order. For Set objects there is no key like in Map objects. However, to
8263    /// keep the API similar to the Map object, each entry has the same value
8264    /// for its key and value here, so that an array [value, value] is returned.
8265    ///
8266    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/entries)
8267    #[cfg(not(js_sys_unstable_apis))]
8268    #[wasm_bindgen(method)]
8269    pub fn entries<T>(set: &Set<T>) -> Iterator;
8270
8271    /// The `entries()` method returns a new Iterator object that contains an
8272    /// array of [value, value] for each element in the Set object, in insertion
8273    /// order. For Set objects there is no key like in Map objects. However, to
8274    /// keep the API similar to the Map object, each entry has the same value
8275    /// for its key and value here, so that an array [value, value] is returned.
8276    ///
8277    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/entries)
8278    #[cfg(js_sys_unstable_apis)]
8279    #[wasm_bindgen(method, js_name = entries)]
8280    pub fn entries<T: JsGeneric>(set: &Set<T>) -> Iterator<ArrayTuple<(T, T)>>;
8281
8282    // Next major: deprecate
8283    /// The `entries()` method returns a new Iterator object that contains an
8284    /// array of [value, value] for each element in the Set object, in insertion
8285    /// order. For Set objects there is no key like in Map objects. However, to
8286    /// keep the API similar to the Map object, each entry has the same value
8287    /// for its key and value here, so that an array [value, value] is returned.
8288    ///
8289    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/entries)
8290    #[wasm_bindgen(method, js_name = entries)]
8291    pub fn entries_typed<T: JsGeneric>(set: &Set<T>) -> Iterator<ArrayTuple<(T, T)>>;
8292
8293    /// The `keys()` method is an alias for this method (for similarity with
8294    /// Map objects); it behaves exactly the same and returns values
8295    /// of Set elements.
8296    ///
8297    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/values)
8298    #[wasm_bindgen(method)]
8299    pub fn keys<T>(set: &Set<T>) -> Iterator<T>;
8300
8301    /// The `values()` method returns a new Iterator object that contains the
8302    /// values for each element in the Set object in insertion order.
8303    ///
8304    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/values)
8305    #[wasm_bindgen(method)]
8306    pub fn values<T>(set: &Set<T>) -> Iterator<T>;
8307}
8308
8309// SyntaxError
8310#[wasm_bindgen]
8311extern "C" {
8312    /// A `SyntaxError` is thrown when the JavaScript engine encounters tokens or
8313    /// token order that does not conform to the syntax of the language when
8314    /// parsing code.
8315    ///
8316    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError)
8317    #[wasm_bindgen(extends = Error, extends = Object, typescript_type = "SyntaxError")]
8318    #[derive(Clone, Debug, PartialEq, Eq)]
8319    pub type SyntaxError;
8320
8321    /// A `SyntaxError` is thrown when the JavaScript engine encounters tokens or
8322    /// token order that does not conform to the syntax of the language when
8323    /// parsing code.
8324    ///
8325    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError)
8326    #[wasm_bindgen(constructor)]
8327    pub fn new(message: &str) -> SyntaxError;
8328
8329    /// Creates a new `SyntaxError` with the given message and a typed
8330    /// [`ErrorOptions`] dictionary whose `cause` property indicates the
8331    /// original cause of the error.
8332    ///
8333    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError/SyntaxError)
8334    #[wasm_bindgen(constructor)]
8335    pub fn new_with_options(message: &str, options: &ErrorOptions) -> SyntaxError;
8336}
8337
8338// TypeError
8339#[wasm_bindgen]
8340extern "C" {
8341    /// The `TypeError` object represents an error when a value is not of the
8342    /// expected type.
8343    ///
8344    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError)
8345    #[wasm_bindgen(extends = Error, extends = Object, typescript_type = "TypeError")]
8346    #[derive(Clone, Debug, PartialEq, Eq)]
8347    pub type TypeError;
8348
8349    /// The `TypeError` object represents an error when a value is not of the
8350    /// expected type.
8351    ///
8352    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError)
8353    #[wasm_bindgen(constructor)]
8354    pub fn new(message: &str) -> TypeError;
8355
8356    /// Creates a new `TypeError` with the given message and a typed
8357    /// [`ErrorOptions`] dictionary whose `cause` property indicates the
8358    /// original cause of the error.
8359    ///
8360    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError/TypeError)
8361    #[wasm_bindgen(constructor)]
8362    pub fn new_with_options(message: &str, options: &ErrorOptions) -> TypeError;
8363}
8364
8365// URIError
8366#[wasm_bindgen]
8367extern "C" {
8368    /// The `URIError` object represents an error when a global URI handling
8369    /// function was used in a wrong way.
8370    ///
8371    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError)
8372    #[wasm_bindgen(extends = Error, extends = Object, js_name = URIError, typescript_type = "URIError")]
8373    #[derive(Clone, Debug, PartialEq, Eq)]
8374    pub type UriError;
8375
8376    /// The `URIError` object represents an error when a global URI handling
8377    /// function was used in a wrong way.
8378    ///
8379    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError)
8380    #[wasm_bindgen(constructor, js_class = "URIError")]
8381    pub fn new(message: &str) -> UriError;
8382
8383    /// Creates a new `URIError` with the given message and a typed
8384    /// [`ErrorOptions`] dictionary whose `cause` property indicates the
8385    /// original cause of the error.
8386    ///
8387    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError/URIError)
8388    #[wasm_bindgen(constructor, js_class = "URIError")]
8389    pub fn new_with_options(message: &str, options: &ErrorOptions) -> UriError;
8390}
8391
8392// WeakMap
8393#[wasm_bindgen]
8394extern "C" {
8395    #[wasm_bindgen(extends = Object, typescript_type = "WeakMap<object, any>")]
8396    #[derive(Clone, Debug, PartialEq, Eq)]
8397    pub type WeakMap<K = Object, V = JsValue>;
8398
8399    /// The [`WeakMap`] object is a collection of key/value pairs in which the
8400    /// keys are weakly referenced.  The keys must be objects and the values can
8401    /// be arbitrary values.
8402    ///
8403    /// **Note:** Consider using [`WeakMap::new_typed`] to support typing.
8404    ///
8405    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap)
8406    #[cfg(not(js_sys_unstable_apis))]
8407    #[wasm_bindgen(constructor)]
8408    pub fn new() -> WeakMap;
8409
8410    /// The [`WeakMap`] object is a collection of key/value pairs in which the
8411    /// keys are weakly referenced.  The keys must be objects and the values can
8412    /// be arbitrary values.
8413    ///
8414    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap)
8415    #[cfg(js_sys_unstable_apis)]
8416    #[wasm_bindgen(constructor)]
8417    pub fn new<K: JsGeneric = Object, V: JsGeneric = Object>() -> WeakMap<K, V>;
8418
8419    // Next major: deprecate
8420    /// The [`WeakMap`] object is a collection of key/value pairs in which the
8421    /// keys are weakly referenced.  The keys must be objects and the values can
8422    /// be arbitrary values.
8423    ///
8424    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap)
8425    #[wasm_bindgen(constructor)]
8426    pub fn new_typed<K: JsGeneric = Object, V: JsGeneric = Object>() -> WeakMap<K, V>;
8427
8428    /// The `set()` method sets the value for the key in the [`WeakMap`] object.
8429    /// Returns the [`WeakMap`] object.
8430    ///
8431    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/set)
8432    #[wasm_bindgen(method, js_class = "WeakMap")]
8433    pub fn set<K, V>(this: &WeakMap<K, V>, key: &K, value: &V) -> WeakMap<K, V>;
8434
8435    /// The `get()` method returns a specified by key element
8436    /// from a [`WeakMap`] object. Returns `undefined` if the key is not found.
8437    ///
8438    /// **Note:** Consider using [`WeakMap::get_checked`] to get an `Option<V>` instead.
8439    ///
8440    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/get)
8441    #[cfg(not(js_sys_unstable_apis))]
8442    #[wasm_bindgen(method)]
8443    pub fn get<K, V>(this: &WeakMap<K, V>, key: &K) -> V;
8444
8445    /// The `get()` method returns a specified by key element
8446    /// from a [`WeakMap`] object. Returns `None` if the key is not found.
8447    ///
8448    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/get)
8449    #[cfg(js_sys_unstable_apis)]
8450    #[wasm_bindgen(method)]
8451    pub fn get<K, V>(this: &WeakMap<K, V>, key: &K) -> Option<V>;
8452
8453    /// The `get()` method returns a specified by key element
8454    /// from a [`WeakMap`] object. Returns `None` if the key is not found.
8455    ///
8456    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/get)
8457    #[wasm_bindgen(method, js_name = get)]
8458    pub fn get_checked<K, V>(this: &WeakMap<K, V>, key: &K) -> Option<V>;
8459
8460    /// The `has()` method returns a boolean indicating whether an element with
8461    /// the specified key exists in the [`WeakMap`] object or not.
8462    ///
8463    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/has)
8464    #[wasm_bindgen(method)]
8465    pub fn has<K, V>(this: &WeakMap<K, V>, key: &K) -> bool;
8466
8467    /// The `delete()` method removes the specified element from a [`WeakMap`]
8468    /// object.
8469    ///
8470    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/delete)
8471    #[wasm_bindgen(method)]
8472    pub fn delete<K, V>(this: &WeakMap<K, V>, key: &K) -> bool;
8473}
8474
8475impl Default for WeakMap {
8476    fn default() -> Self {
8477        Self::new()
8478    }
8479}
8480
8481// WeakSet
8482#[wasm_bindgen]
8483extern "C" {
8484    #[wasm_bindgen(extends = Object, typescript_type = "WeakSet<object>")]
8485    #[derive(Clone, Debug, PartialEq, Eq)]
8486    pub type WeakSet<T = Object>;
8487
8488    /// The `WeakSet` object lets you store weakly held objects in a collection.
8489    ///
8490    /// **Note:** Consider using [`WeakSet::new_typed`] for typed sets.
8491    ///
8492    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet)
8493    #[cfg(not(js_sys_unstable_apis))]
8494    #[wasm_bindgen(constructor)]
8495    pub fn new() -> WeakSet;
8496
8497    /// The `WeakSet` object lets you store weakly held objects in a collection.
8498    ///
8499    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet)
8500    #[cfg(js_sys_unstable_apis)]
8501    #[wasm_bindgen(constructor)]
8502    pub fn new<T = Object>() -> WeakSet<T>;
8503
8504    // Next major: deprecate
8505    /// The `WeakSet` object lets you store weakly held objects in a collection.
8506    ///
8507    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet)
8508    #[wasm_bindgen(constructor)]
8509    pub fn new_typed<T = Object>() -> WeakSet<T>;
8510
8511    /// The `has()` method returns a boolean indicating whether an object exists
8512    /// in a WeakSet or not.
8513    ///
8514    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet/has)
8515    #[wasm_bindgen(method)]
8516    pub fn has<T>(this: &WeakSet<T>, value: &T) -> bool;
8517
8518    /// The `add()` method appends a new object to the end of a WeakSet object.
8519    ///
8520    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet/add)
8521    #[wasm_bindgen(method)]
8522    pub fn add<T>(this: &WeakSet<T>, value: &T) -> WeakSet<T>;
8523
8524    /// The `delete()` method removes the specified element from a WeakSet
8525    /// object.
8526    ///
8527    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet/delete)
8528    #[wasm_bindgen(method)]
8529    pub fn delete<T>(this: &WeakSet<T>, value: &T) -> bool;
8530}
8531
8532impl Default for WeakSet {
8533    fn default() -> Self {
8534        Self::new()
8535    }
8536}
8537
8538// WeakRef
8539#[wasm_bindgen]
8540extern "C" {
8541    #[wasm_bindgen(extends = Object, typescript_type = "WeakRef<object>")]
8542    #[derive(Clone, Debug, PartialEq, Eq)]
8543    pub type WeakRef<T = Object>;
8544
8545    /// The `WeakRef` object contains a weak reference to an object. A weak
8546    /// reference to an object is a reference that does not prevent the object
8547    /// from being reclaimed by the garbage collector.
8548    ///
8549    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakRef)
8550    #[wasm_bindgen(constructor)]
8551    pub fn new<T = Object>(target: &T) -> WeakRef<T>;
8552
8553    /// Returns the `Object` this `WeakRef` points to, or `None` if the
8554    /// object has been garbage collected.
8555    ///
8556    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakRef/deref)
8557    #[wasm_bindgen(method)]
8558    pub fn deref<T>(this: &WeakRef<T>) -> Option<T>;
8559}
8560
8561#[cfg(js_sys_unstable_apis)]
8562#[allow(non_snake_case)]
8563pub mod Temporal;
8564
8565#[allow(non_snake_case)]
8566pub mod WebAssembly {
8567    use super::*;
8568
8569    // WebAssembly
8570    #[wasm_bindgen]
8571    extern "C" {
8572        /// The `WebAssembly.compile()` function compiles a `WebAssembly.Module`
8573        /// from WebAssembly binary code.  This function is useful if it is
8574        /// necessary to a compile a module before it can be instantiated
8575        /// (otherwise, the `WebAssembly.instantiate()` function should be used).
8576        ///
8577        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/compile)
8578        #[cfg(not(js_sys_unstable_apis))]
8579        #[wasm_bindgen(js_namespace = WebAssembly)]
8580        pub fn compile(buffer_source: &JsValue) -> Promise<JsValue>;
8581
8582        /// The `WebAssembly.compile()` function compiles a `WebAssembly.Module`
8583        /// from WebAssembly binary code.  This function is useful if it is
8584        /// necessary to a compile a module before it can be instantiated
8585        /// (otherwise, the `WebAssembly.instantiate()` function should be used).
8586        ///
8587        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/compile)
8588        #[cfg(js_sys_unstable_apis)]
8589        #[wasm_bindgen(js_namespace = WebAssembly)]
8590        pub fn compile(buffer_source: &JsValue) -> Promise<Module>;
8591
8592        /// The `WebAssembly.compileStreaming()` function compiles a
8593        /// `WebAssembly.Module` module directly from a streamed underlying
8594        /// source. This function is useful if it is necessary to a compile a
8595        /// module before it can be instantiated (otherwise, the
8596        /// `WebAssembly.instantiateStreaming()` function should be used).
8597        ///
8598        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/compileStreaming)
8599        #[cfg(not(js_sys_unstable_apis))]
8600        #[wasm_bindgen(js_namespace = WebAssembly, js_name = compileStreaming)]
8601        pub fn compile_streaming(response: &Promise) -> Promise<JsValue>;
8602
8603        /// The `WebAssembly.compileStreaming()` function compiles a
8604        /// `WebAssembly.Module` module directly from a streamed underlying
8605        /// source. This function is useful if it is necessary to a compile a
8606        /// module before it can be instantiated (otherwise, the
8607        /// `WebAssembly.instantiateStreaming()` function should be used).
8608        ///
8609        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/compileStreaming)
8610        #[cfg(js_sys_unstable_apis)]
8611        #[wasm_bindgen(js_namespace = WebAssembly, js_name = compileStreaming)]
8612        pub fn compile_streaming(response: &Promise) -> Promise<Module>;
8613
8614        /// The `WebAssembly.instantiate()` function allows you to compile and
8615        /// instantiate WebAssembly code.
8616        ///
8617        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiate)
8618        #[cfg(not(js_sys_unstable_apis))]
8619        #[wasm_bindgen(js_namespace = WebAssembly, js_name = instantiate)]
8620        pub fn instantiate_buffer(buffer: &[u8], imports: &Object) -> Promise<JsValue>;
8621
8622        /// The `WebAssembly.instantiate()` function allows you to compile and
8623        /// instantiate WebAssembly code.
8624        ///
8625        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiate)
8626        #[cfg(js_sys_unstable_apis)]
8627        #[wasm_bindgen(js_namespace = WebAssembly, js_name = instantiate)]
8628        pub fn instantiate_buffer(buffer: &[u8], imports: &Object) -> Promise<Instance>;
8629
8630        /// The `WebAssembly.instantiate()` function allows you to compile and
8631        /// instantiate WebAssembly code.
8632        ///
8633        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiate)
8634        #[cfg(not(js_sys_unstable_apis))]
8635        #[wasm_bindgen(js_namespace = WebAssembly, js_name = instantiate)]
8636        pub fn instantiate_module(module: &Module, imports: &Object) -> Promise<JsValue>;
8637
8638        /// The `WebAssembly.instantiate()` function allows you to compile and
8639        /// instantiate WebAssembly code.
8640        ///
8641        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiate)
8642        #[cfg(js_sys_unstable_apis)]
8643        #[wasm_bindgen(js_namespace = WebAssembly, js_name = instantiate)]
8644        pub fn instantiate_module(module: &Module, imports: &Object) -> Promise<Instance>;
8645
8646        /// The `WebAssembly.instantiateStreaming()` function compiles and
8647        /// instantiates a WebAssembly module directly from a streamed
8648        /// underlying source. This is the most efficient, optimized way to load
8649        /// Wasm code.
8650        ///
8651        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiateStreaming)
8652        #[cfg(not(js_sys_unstable_apis))]
8653        #[wasm_bindgen(js_namespace = WebAssembly, js_name = instantiateStreaming)]
8654        pub fn instantiate_streaming(response: &JsValue, imports: &Object) -> Promise<JsValue>;
8655
8656        /// The `WebAssembly.instantiateStreaming()` function compiles and
8657        /// instantiates a WebAssembly module directly from a streamed
8658        /// underlying source. This is the most efficient, optimized way to load
8659        /// Wasm code.
8660        ///
8661        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiateStreaming)
8662        #[cfg(js_sys_unstable_apis)]
8663        #[wasm_bindgen(js_namespace = WebAssembly, js_name = instantiateStreaming)]
8664        pub fn instantiate_streaming(response: &JsValue, imports: &Object) -> Promise<Instance>;
8665
8666        /// The `WebAssembly.validate()` function validates a given typed
8667        /// array of WebAssembly binary code, returning whether the bytes
8668        /// form a valid Wasm module (`true`) or not (`false`).
8669        ///
8670        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/validate)
8671        #[wasm_bindgen(js_namespace = WebAssembly, catch)]
8672        pub fn validate(buffer_source: &JsValue) -> Result<bool, JsValue>;
8673    }
8674
8675    // WebAssembly.CompileError
8676    #[wasm_bindgen]
8677    extern "C" {
8678        /// The `WebAssembly.CompileError()` constructor creates a new
8679        /// WebAssembly `CompileError` object, which indicates an error during
8680        /// WebAssembly decoding or validation.
8681        ///
8682        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/CompileError)
8683        #[wasm_bindgen(extends = Error, js_namespace = WebAssembly, typescript_type = "WebAssembly.CompileError")]
8684        #[derive(Clone, Debug, PartialEq, Eq)]
8685        pub type CompileError;
8686
8687        /// The `WebAssembly.CompileError()` constructor creates a new
8688        /// WebAssembly `CompileError` object, which indicates an error during
8689        /// WebAssembly decoding or validation.
8690        ///
8691        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/CompileError)
8692        #[wasm_bindgen(constructor, js_namespace = WebAssembly)]
8693        pub fn new(message: &str) -> CompileError;
8694
8695        /// Creates a new `WebAssembly.CompileError` with the given message and
8696        /// a typed [`ErrorOptions`] dictionary whose `cause` property
8697        /// indicates the original cause of the error.
8698        ///
8699        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/CompileError/CompileError)
8700        #[wasm_bindgen(constructor, js_namespace = WebAssembly)]
8701        pub fn new_with_options(message: &str, options: &ErrorOptions) -> CompileError;
8702    }
8703
8704    // WebAssembly.Instance
8705    #[wasm_bindgen]
8706    extern "C" {
8707        /// A `WebAssembly.Instance` object is a stateful, executable instance
8708        /// of a `WebAssembly.Module`. Instance objects contain all the exported
8709        /// WebAssembly functions that allow calling into WebAssembly code from
8710        /// JavaScript.
8711        ///
8712        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance)
8713        #[wasm_bindgen(extends = Object, js_namespace = WebAssembly, typescript_type = "WebAssembly.Instance")]
8714        #[derive(Clone, Debug, PartialEq, Eq)]
8715        pub type Instance;
8716
8717        /// The `WebAssembly.Instance()` constructor function can be called to
8718        /// synchronously instantiate a given `WebAssembly.Module`
8719        /// object. However, the primary way to get an `Instance` is through the
8720        /// asynchronous `WebAssembly.instantiateStreaming()` function.
8721        ///
8722        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance)
8723        #[wasm_bindgen(catch, constructor, js_namespace = WebAssembly)]
8724        pub fn new(module: &Module, imports: &Object) -> Result<Instance, JsValue>;
8725
8726        /// The `exports` readonly property of the `WebAssembly.Instance` object
8727        /// prototype returns an object containing as its members all the
8728        /// functions exported from the WebAssembly module instance, to allow
8729        /// them to be accessed and used by JavaScript.
8730        ///
8731        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance/exports)
8732        #[wasm_bindgen(getter, method, js_namespace = WebAssembly)]
8733        pub fn exports(this: &Instance) -> Object;
8734    }
8735
8736    // WebAssembly.LinkError
8737    #[wasm_bindgen]
8738    extern "C" {
8739        /// The `WebAssembly.LinkError()` constructor creates a new WebAssembly
8740        /// LinkError object, which indicates an error during module
8741        /// instantiation (besides traps from the start function).
8742        ///
8743        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/LinkError)
8744        #[wasm_bindgen(extends = Error, js_namespace = WebAssembly, typescript_type = "WebAssembly.LinkError")]
8745        #[derive(Clone, Debug, PartialEq, Eq)]
8746        pub type LinkError;
8747
8748        /// The `WebAssembly.LinkError()` constructor creates a new WebAssembly
8749        /// LinkError object, which indicates an error during module
8750        /// instantiation (besides traps from the start function).
8751        ///
8752        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/LinkError)
8753        #[wasm_bindgen(constructor, js_namespace = WebAssembly)]
8754        pub fn new(message: &str) -> LinkError;
8755
8756        /// Creates a new `WebAssembly.LinkError` with the given message and a
8757        /// typed [`ErrorOptions`] dictionary whose `cause` property indicates
8758        /// the original cause of the error.
8759        ///
8760        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/LinkError/LinkError)
8761        #[wasm_bindgen(constructor, js_namespace = WebAssembly)]
8762        pub fn new_with_options(message: &str, options: &ErrorOptions) -> LinkError;
8763    }
8764
8765    // WebAssembly.RuntimeError
8766    #[wasm_bindgen]
8767    extern "C" {
8768        /// The `WebAssembly.RuntimeError()` constructor creates a new WebAssembly
8769        /// `RuntimeError` object — the type that is thrown whenever WebAssembly
8770        /// specifies a trap.
8771        ///
8772        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/RuntimeError)
8773        #[wasm_bindgen(extends = Error, js_namespace = WebAssembly, typescript_type = "WebAssembly.RuntimeError")]
8774        #[derive(Clone, Debug, PartialEq, Eq)]
8775        pub type RuntimeError;
8776
8777        /// The `WebAssembly.RuntimeError()` constructor creates a new WebAssembly
8778        /// `RuntimeError` object — the type that is thrown whenever WebAssembly
8779        /// specifies a trap.
8780        ///
8781        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/RuntimeError)
8782        #[wasm_bindgen(constructor, js_namespace = WebAssembly)]
8783        pub fn new(message: &str) -> RuntimeError;
8784
8785        /// Creates a new `WebAssembly.RuntimeError` with the given message
8786        /// and a typed [`ErrorOptions`] dictionary whose `cause` property
8787        /// indicates the original cause of the error.
8788        ///
8789        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/RuntimeError/RuntimeError)
8790        #[wasm_bindgen(constructor, js_namespace = WebAssembly)]
8791        pub fn new_with_options(message: &str, options: &ErrorOptions) -> RuntimeError;
8792    }
8793
8794    // WebAssembly.Module
8795    #[wasm_bindgen]
8796    extern "C" {
8797        /// A `WebAssembly.Module` object contains stateless WebAssembly code
8798        /// that has already been compiled by the browser and can be
8799        /// efficiently shared with Workers, and instantiated multiple times.
8800        ///
8801        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module)
8802        #[wasm_bindgen(js_namespace = WebAssembly, extends = Object, typescript_type = "WebAssembly.Module")]
8803        #[derive(Clone, Debug, PartialEq, Eq)]
8804        pub type Module;
8805
8806        /// A `WebAssembly.Module` object contains stateless WebAssembly code
8807        /// that has already been compiled by the browser and can be
8808        /// efficiently shared with Workers, and instantiated multiple times.
8809        ///
8810        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module)
8811        #[wasm_bindgen(constructor, js_namespace = WebAssembly, catch)]
8812        pub fn new(buffer_source: &JsValue) -> Result<Module, JsValue>;
8813
8814        /// The `WebAssembly.customSections()` function returns a copy of the
8815        /// contents of all custom sections in the given module with the given
8816        /// string name.
8817        ///
8818        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module/customSections)
8819        #[wasm_bindgen(static_method_of = Module, js_namespace = WebAssembly, js_name = customSections)]
8820        pub fn custom_sections(module: &Module, sectionName: &str) -> Array;
8821
8822        /// The `WebAssembly.exports()` function returns an array containing
8823        /// descriptions of all the declared exports of the given `Module`.
8824        ///
8825        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module/exports)
8826        #[wasm_bindgen(static_method_of = Module, js_namespace = WebAssembly)]
8827        pub fn exports(module: &Module) -> Array;
8828
8829        /// The `WebAssembly.imports()` function returns an array containing
8830        /// descriptions of all the declared imports of the given `Module`.
8831        ///
8832        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module/imports)
8833        #[wasm_bindgen(static_method_of = Module, js_namespace = WebAssembly)]
8834        pub fn imports(module: &Module) -> Array;
8835    }
8836
8837    // WebAssembly.Table
8838    #[wasm_bindgen]
8839    extern "C" {
8840        /// The `WebAssembly.Table()` constructor creates a new `Table` object
8841        /// of the given size and element type.
8842        ///
8843        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table)
8844        #[wasm_bindgen(js_namespace = WebAssembly, extends = Object, typescript_type = "WebAssembly.Table")]
8845        #[derive(Clone, Debug, PartialEq, Eq)]
8846        pub type Table;
8847
8848        /// The `WebAssembly.Table()` constructor creates a new `Table` object
8849        /// of the given size and element type.
8850        ///
8851        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table)
8852        #[wasm_bindgen(constructor, js_namespace = WebAssembly, catch)]
8853        pub fn new(table_descriptor: &Object) -> Result<Table, JsValue>;
8854
8855        /// The `WebAssembly.Table()` constructor creates a new `Table` object
8856        /// of the given size and element type.
8857        ///
8858        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table)
8859        #[wasm_bindgen(constructor, js_namespace = WebAssembly, catch)]
8860        pub fn new_with_value(table_descriptor: &Object, value: JsValue) -> Result<Table, JsValue>;
8861
8862        /// The length prototype property of the `WebAssembly.Table` object
8863        /// returns the length of the table, i.e. the number of elements in the
8864        /// table.
8865        ///
8866        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/length)
8867        #[wasm_bindgen(method, getter, js_namespace = WebAssembly)]
8868        pub fn length(this: &Table) -> u32;
8869
8870        /// The `get()` prototype method of the `WebAssembly.Table()` object
8871        /// retrieves a function reference stored at a given index.
8872        ///
8873        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/get)
8874        #[wasm_bindgen(method, catch, js_namespace = WebAssembly)]
8875        pub fn get(this: &Table, index: u32) -> Result<Function, JsValue>;
8876
8877        /// The `get()` prototype method of the `WebAssembly.Table()` object
8878        /// retrieves a function reference stored at a given index.
8879        ///
8880        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/get)
8881        #[wasm_bindgen(method, catch, js_namespace = WebAssembly, js_name = get)]
8882        pub fn get_raw(this: &Table, index: u32) -> Result<JsValue, JsValue>;
8883
8884        /// The `grow()` prototype method of the `WebAssembly.Table` object
8885        /// increases the size of the `Table` instance by a specified number of
8886        /// elements.
8887        ///
8888        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/grow)
8889        #[wasm_bindgen(method, catch, js_namespace = WebAssembly)]
8890        pub fn grow(this: &Table, additional_capacity: u32) -> Result<u32, JsValue>;
8891
8892        /// The `grow()` prototype method of the `WebAssembly.Table` object
8893        /// increases the size of the `Table` instance by a specified number of
8894        /// elements.
8895        ///
8896        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/grow)
8897        #[wasm_bindgen(method, catch, js_namespace = WebAssembly, js_name = grow)]
8898        pub fn grow_with_value(
8899            this: &Table,
8900            additional_capacity: u32,
8901            value: JsValue,
8902        ) -> Result<u32, JsValue>;
8903
8904        /// The `set()` prototype method of the `WebAssembly.Table` object mutates a
8905        /// reference stored at a given index to a different value.
8906        ///
8907        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/set)
8908        #[wasm_bindgen(method, catch, js_namespace = WebAssembly)]
8909        pub fn set(this: &Table, index: u32, function: &Function) -> Result<(), JsValue>;
8910
8911        /// The `set()` prototype method of the `WebAssembly.Table` object mutates a
8912        /// reference stored at a given index to a different value.
8913        ///
8914        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/set)
8915        #[wasm_bindgen(method, catch, js_namespace = WebAssembly, js_name = set)]
8916        pub fn set_raw(this: &Table, index: u32, value: &JsValue) -> Result<(), JsValue>;
8917    }
8918
8919    // WebAssembly.Tag
8920    #[wasm_bindgen]
8921    extern "C" {
8922        /// The `WebAssembly.Tag()` constructor creates a new `Tag` object
8923        ///
8924        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Tag)
8925        #[wasm_bindgen(js_namespace = WebAssembly, extends = Object, typescript_type = "WebAssembly.Tag")]
8926        #[derive(Clone, Debug, PartialEq, Eq)]
8927        pub type Tag;
8928
8929        /// The `WebAssembly.Tag()` constructor creates a new `Tag` object
8930        ///
8931        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Tag)
8932        #[wasm_bindgen(constructor, js_namespace = WebAssembly, catch)]
8933        pub fn new(tag_descriptor: &Object) -> Result<Tag, JsValue>;
8934    }
8935
8936    // WebAssembly.Exception
8937    #[wasm_bindgen]
8938    extern "C" {
8939        /// The `WebAssembly.Exception()` constructor creates a new `Exception` object
8940        ///
8941        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Exception)
8942        #[wasm_bindgen(js_namespace = WebAssembly, extends = Object, typescript_type = "WebAssembly.Exception")]
8943        #[derive(Clone, Debug, PartialEq, Eq)]
8944        pub type Exception;
8945
8946        /// The `WebAssembly.Exception()` constructor creates a new `Exception` object
8947        ///
8948        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Exception)
8949        #[wasm_bindgen(constructor, js_namespace = WebAssembly, catch)]
8950        pub fn new(tag: &Tag, payload: &Array) -> Result<Exception, JsValue>;
8951
8952        /// The `WebAssembly.Exception()` constructor creates a new `Exception` object
8953        ///
8954        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Exception)
8955        #[wasm_bindgen(constructor, js_namespace = WebAssembly, catch)]
8956        pub fn new_with_options(
8957            tag: &Tag,
8958            payload: &Array,
8959            options: &Object,
8960        ) -> Result<Exception, JsValue>;
8961
8962        /// The `is()` prototype method of the `WebAssembly.Exception` can be used to
8963        /// test if the Exception matches a given tag.
8964        ///
8965        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Exception/is)
8966        #[wasm_bindgen(method, js_namespace = WebAssembly)]
8967        pub fn is(this: &Exception, tag: &Tag) -> bool;
8968
8969        /// The `getArg()` prototype method of the `WebAssembly.Exception` can be used
8970        /// to get the value of a specified item in the exception's data arguments
8971        ///
8972        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Exception/getArg)
8973        #[wasm_bindgen(method, js_namespace = WebAssembly, js_name = getArg, catch)]
8974        pub fn get_arg(this: &Exception, tag: &Tag, index: u32) -> Result<JsValue, JsValue>;
8975    }
8976
8977    // WebAssembly.Global
8978    #[wasm_bindgen]
8979    extern "C" {
8980        /// The `WebAssembly.Global()` constructor creates a new `Global` object
8981        /// of the given type and value.
8982        ///
8983        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Global)
8984        #[wasm_bindgen(js_namespace = WebAssembly, extends = Object, typescript_type = "WebAssembly.Global")]
8985        #[derive(Clone, Debug, PartialEq, Eq)]
8986        pub type Global;
8987
8988        /// The `WebAssembly.Global()` constructor creates a new `Global` object
8989        /// of the given type and value.
8990        ///
8991        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Global)
8992        #[wasm_bindgen(constructor, js_namespace = WebAssembly, catch)]
8993        pub fn new(global_descriptor: &Object, value: &JsValue) -> Result<Global, JsValue>;
8994
8995        /// The value prototype property of the `WebAssembly.Global` object
8996        /// returns the value of the global.
8997        ///
8998        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Global)
8999        #[wasm_bindgen(method, getter, js_namespace = WebAssembly)]
9000        pub fn value(this: &Global) -> JsValue;
9001        #[wasm_bindgen(method, setter = value, js_namespace = WebAssembly)]
9002        pub fn set_value(this: &Global, value: &JsValue);
9003    }
9004
9005    // WebAssembly.Memory
9006    #[wasm_bindgen]
9007    extern "C" {
9008        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory)
9009        #[wasm_bindgen(js_namespace = WebAssembly, extends = Object, typescript_type = "WebAssembly.Memory")]
9010        #[derive(Clone, Debug, PartialEq, Eq)]
9011        pub type Memory;
9012
9013        /// The `WebAssembly.Memory()` constructor creates a new `Memory` object
9014        /// which is a resizable `ArrayBuffer` that holds the raw bytes of
9015        /// memory accessed by a WebAssembly `Instance`.
9016        ///
9017        /// A memory created by JavaScript or in WebAssembly code will be
9018        /// accessible and mutable from both JavaScript and WebAssembly.
9019        ///
9020        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory)
9021        #[wasm_bindgen(constructor, js_namespace = WebAssembly, catch)]
9022        pub fn new(descriptor: &Object) -> Result<Memory, JsValue>;
9023
9024        /// An accessor property that returns the buffer contained in the
9025        /// memory.
9026        ///
9027        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory/buffer)
9028        #[wasm_bindgen(method, getter, js_namespace = WebAssembly)]
9029        pub fn buffer(this: &Memory) -> JsValue;
9030
9031        /// The `grow()` prototype method of the `Memory` object increases the
9032        /// size of the memory instance by a specified number of WebAssembly
9033        /// pages.
9034        ///
9035        /// Takes the number of pages to grow (64KiB in size) and returns the
9036        /// previous size of memory, in pages.
9037        ///
9038        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory/grow)
9039        #[wasm_bindgen(method, js_namespace = WebAssembly)]
9040        pub fn grow(this: &Memory, pages: u32) -> u32;
9041    }
9042
9043    // WebAssembly.Suspending / WebAssembly.promising (JSPI — JS Promise Integration)
9044    #[wasm_bindgen]
9045    extern "C" {
9046        /// A `WebAssembly.Suspending` object wraps a JavaScript async function
9047        /// so it can be used as a WebAssembly import under
9048        /// [JSPI (JS Promise Integration)][jspi].
9049        ///
9050        /// When WASM calls a `Suspending`-wrapped import that returns a
9051        /// `Promise`, the WASM fiber suspends until the promise settles; the
9052        /// resolved value is then returned to WASM as if the call had returned
9053        /// synchronously.  The browser's event loop is **not** blocked.
9054        ///
9055        /// [jspi]: https://github.com/WebAssembly/js-promise-integration
9056        ///
9057        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Suspending)
9058        #[wasm_bindgen(
9059            js_namespace = WebAssembly,
9060            extends = Object,
9061            typescript_type = "WebAssembly.Suspending"
9062        )]
9063        #[derive(Clone, Debug, PartialEq, Eq)]
9064        pub type Suspending;
9065
9066        /// Wraps `func` (an async function) in a `WebAssembly.Suspending` object.
9067        ///
9068        /// Pass the returned object as a WASM import.  Every call to that
9069        /// import from WASM will suspend the current fiber and resume it with
9070        /// the resolved value once `func`'s returned `Promise` settles.
9071        #[wasm_bindgen(constructor, js_namespace = WebAssembly)]
9072        pub fn new(func: &Function) -> Suspending;
9073
9074        /// Wraps a WebAssembly exported `Function` so that calling it returns a
9075        /// `Promise` and enables JSPI suspension inside.
9076        ///
9077        /// Use `WebAssembly.promising` to obtain a "promising" wrapper around a
9078        /// raw WASM export; any JSPI suspensions that occur while the function
9079        /// executes will resolve the returned `Promise` when the fiber finishes.
9080        ///
9081        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/promising)
9082        #[wasm_bindgen(js_namespace = WebAssembly)]
9083        pub fn promising(func: &Function) -> Function;
9084    }
9085}
9086
9087/// The `JSON` object contains methods for parsing [JavaScript Object
9088/// Notation (JSON)](https://json.org/) and converting values to JSON. It
9089/// can't be called or constructed, and aside from its two method
9090/// properties, it has no interesting functionality of its own.
9091#[allow(non_snake_case)]
9092pub mod JSON {
9093    use super::*;
9094
9095    // JSON
9096    #[wasm_bindgen]
9097    extern "C" {
9098        /// The `JSON.parse()` method parses a JSON string, constructing the
9099        /// JavaScript value or object described by the string.
9100        ///
9101        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse)
9102        #[wasm_bindgen(catch, js_namespace = JSON)]
9103        pub fn parse(text: &str) -> Result<JsValue, JsValue>;
9104
9105        /// The `JSON.stringify()` method converts a JavaScript value to a JSON string.
9106        ///
9107        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)
9108        #[wasm_bindgen(catch, js_namespace = JSON)]
9109        pub fn stringify(obj: &JsValue) -> Result<JsString, JsValue>;
9110
9111        /// The `JSON.stringify()` method converts a JavaScript value to a JSON string.
9112        ///
9113        /// The `replacer` argument is a function that alters the behavior of the stringification
9114        /// process, or an array of String and Number objects that serve as a whitelist
9115        /// for selecting/filtering the properties of the value object to be included
9116        /// in the JSON string. If this value is null or not provided, all properties
9117        /// of the object are included in the resulting JSON string.
9118        ///
9119        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)
9120        #[cfg(not(js_sys_unstable_apis))]
9121        #[wasm_bindgen(catch, js_namespace = JSON, js_name = stringify)]
9122        pub fn stringify_with_replacer(
9123            obj: &JsValue,
9124            replacer: &JsValue,
9125        ) -> Result<JsString, JsValue>;
9126
9127        /// The `JSON.stringify()` method converts a JavaScript value to a JSON string.
9128        ///
9129        /// The `replacer` argument is a function that alters the behavior of the stringification
9130        /// process, or an array of String and Number objects that serve as a whitelist
9131        /// for selecting/filtering the properties of the value object to be included
9132        /// in the JSON string. If this value is null or not provided, all properties
9133        /// of the object are included in the resulting JSON string.
9134        ///
9135        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)
9136        #[cfg(js_sys_unstable_apis)]
9137        #[wasm_bindgen(catch, js_namespace = JSON, js_name = stringify)]
9138        pub fn stringify_with_replacer<'a>(
9139            obj: &JsValue,
9140            replacer: &mut dyn FnMut(JsString, JsValue) -> Result<Option<JsValue>, JsError>,
9141            space: Option<u32>,
9142        ) -> Result<JsString, JsValue>;
9143
9144        // Next major: deprecate
9145        /// The `JSON.stringify()` method converts a JavaScript value to a JSON string.
9146        ///
9147        /// The `replacer` argument is a function that alters the behavior of the stringification
9148        /// process, or an array of String and Number objects that serve as a whitelist
9149        /// for selecting/filtering the properties of the value object to be included
9150        /// in the JSON string. If this value is null or not provided, all properties
9151        /// of the object are included in the resulting JSON string.
9152        ///
9153        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)
9154        #[wasm_bindgen(catch, js_namespace = JSON, js_name = stringify)]
9155        pub fn stringify_with_replacer_func<'a>(
9156            obj: &JsValue,
9157            replacer: &mut dyn FnMut(JsString, JsValue) -> Result<Option<JsValue>, JsError>,
9158            space: Option<u32>,
9159        ) -> Result<JsString, JsValue>;
9160
9161        /// The `JSON.stringify()` method converts a JavaScript value to a JSON string.
9162        ///
9163        /// The `replacer` argument is a function that alters the behavior of the stringification
9164        /// process, or an array of String and Number objects that serve as a whitelist
9165        /// for selecting/filtering the properties of the value object to be included
9166        /// in the JSON string. If this value is null or not provided, all properties
9167        /// of the object are included in the resulting JSON string.
9168        ///
9169        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)
9170        #[wasm_bindgen(catch, js_namespace = JSON, js_name = stringify)]
9171        pub fn stringify_with_replacer_list(
9172            obj: &JsValue,
9173            replacer: Vec<String>,
9174            space: Option<u32>,
9175        ) -> Result<JsString, JsValue>;
9176
9177        // Next major: deprecate
9178        /// The `JSON.stringify()` method converts a JavaScript value to a JSON string.
9179        ///
9180        /// The `replacer` argument is a function that alters the behavior of the stringification
9181        /// process, or an array of String and Number objects that serve as a whitelist
9182        /// for selecting/filtering the properties of the value object to be included
9183        /// in the JSON string. If this value is null or not provided, all properties
9184        /// of the object are included in the resulting JSON string.
9185        ///
9186        /// The `space` argument is a String or Number object that's used to insert white space into
9187        /// the output JSON string for readability purposes. If this is a Number, it
9188        /// indicates the number of space characters to use as white space; this number
9189        /// is capped at 10 (if it is greater, the value is just 10). Values less than
9190        /// 1 indicate that no space should be used. If this is a String, the string
9191        /// (or the first 10 characters of the string, if it's longer than that) is
9192        /// used as white space. If this parameter is not provided (or is null), no
9193        /// white space is used.
9194        ///
9195        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)
9196        #[wasm_bindgen(catch, js_namespace = JSON, js_name = stringify)]
9197        pub fn stringify_with_replacer_and_space(
9198            obj: &JsValue,
9199            replacer: &JsValue,
9200            space: &JsValue,
9201        ) -> Result<JsString, JsValue>;
9202    }
9203}
9204// JsString
9205#[wasm_bindgen]
9206extern "C" {
9207    #[wasm_bindgen(js_name = String, extends = Object, is_type_of = JsValue::is_string, typescript_type = "string")]
9208    #[derive(Clone, PartialEq, Eq)]
9209    pub type JsString;
9210
9211    /// The length property of a String object indicates the length of a string,
9212    /// in UTF-16 code units.
9213    ///
9214    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length)
9215    #[wasm_bindgen(method, getter)]
9216    pub fn length(this: &JsString) -> u32;
9217
9218    /// The 'at()' method returns a new string consisting of the single UTF-16
9219    /// code unit located at the specified offset into the string, counting from
9220    /// the end if it's negative.
9221    ///
9222    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/at)
9223    #[wasm_bindgen(method, js_class = "String")]
9224    pub fn at(this: &JsString, index: i32) -> Option<JsString>;
9225
9226    /// The String object's `charAt()` method returns a new string consisting of
9227    /// the single UTF-16 code unit located at the specified offset into the
9228    /// string.
9229    ///
9230    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charAt)
9231    #[wasm_bindgen(method, js_class = "String", js_name = charAt)]
9232    pub fn char_at(this: &JsString, index: u32) -> JsString;
9233
9234    /// The `charCodeAt()` method returns an integer between 0 and 65535
9235    /// representing the UTF-16 code unit at the given index (the UTF-16 code
9236    /// unit matches the Unicode code point for code points representable in a
9237    /// single UTF-16 code unit, but might also be the first code unit of a
9238    /// surrogate pair for code points not representable in a single UTF-16 code
9239    /// unit, e.g. Unicode code points > 0x10000).  If you want the entire code
9240    /// point value, use `codePointAt()`.
9241    ///
9242    /// Returns `NaN` if index is out of range.
9243    ///
9244    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charCodeAt)
9245    #[wasm_bindgen(method, js_class = "String", js_name = charCodeAt)]
9246    pub fn char_code_at(this: &JsString, index: u32) -> f64;
9247
9248    /// The `codePointAt()` method returns a non-negative integer that is the
9249    /// Unicode code point value.
9250    ///
9251    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt)
9252    #[cfg(not(js_sys_unstable_apis))]
9253    #[wasm_bindgen(method, js_class = "String", js_name = codePointAt)]
9254    pub fn code_point_at(this: &JsString, pos: u32) -> JsValue;
9255
9256    /// The `codePointAt()` method returns a non-negative integer that is the
9257    /// Unicode code point value.
9258    ///
9259    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt)
9260    #[cfg(js_sys_unstable_apis)]
9261    #[wasm_bindgen(method, js_class = "String", js_name = codePointAt)]
9262    pub fn code_point_at(this: &JsString, pos: u32) -> Option<u32>;
9263
9264    // Next major: deprecate
9265    /// The `codePointAt()` method returns a non-negative integer that is the
9266    /// Unicode code point value.
9267    ///
9268    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt)
9269    #[wasm_bindgen(method, js_class = "String", js_name = codePointAt)]
9270    pub fn try_code_point_at(this: &JsString, pos: u32) -> Option<u16>;
9271
9272    /// The `concat()` method concatenates the string arguments to the calling
9273    /// string and returns a new string.
9274    ///
9275    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/concat)
9276    #[cfg(not(js_sys_unstable_apis))]
9277    #[wasm_bindgen(method, js_class = "String")]
9278    pub fn concat(this: &JsString, string_2: &JsValue) -> JsString;
9279
9280    /// The `concat()` method concatenates the string arguments to the calling
9281    /// string and returns a new string.
9282    ///
9283    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/concat)
9284    #[cfg(js_sys_unstable_apis)]
9285    #[wasm_bindgen(method, js_class = "String")]
9286    pub fn concat(this: &JsString, string: &JsString) -> JsString;
9287
9288    /// The `concat()` method concatenates the string arguments to the calling
9289    /// string and returns a new string.
9290    ///
9291    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/concat)
9292    #[wasm_bindgen(method, js_class = "String")]
9293    pub fn concat_many(this: &JsString, strings: &[JsString]) -> JsString;
9294
9295    /// The `endsWith()` method determines whether a string ends with the characters of a
9296    /// specified string, returning true or false as appropriate.
9297    ///
9298    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith)
9299    #[cfg(not(js_sys_unstable_apis))]
9300    #[wasm_bindgen(method, js_class = "String", js_name = endsWith)]
9301    pub fn ends_with(this: &JsString, search_string: &str, length: i32) -> bool;
9302
9303    /// The `endsWith()` method determines whether a string ends with the characters of a
9304    /// specified string, returning true or false as appropriate.
9305    ///
9306    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith)
9307    #[cfg(js_sys_unstable_apis)]
9308    #[wasm_bindgen(method, js_class = "String", js_name = endsWith)]
9309    pub fn ends_with(this: &JsString, search_string: &str) -> bool;
9310
9311    /// The static `String.fromCharCode()` method returns a string created from
9312    /// the specified sequence of UTF-16 code units.
9313    ///
9314    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
9315    ///
9316    /// # Notes
9317    ///
9318    /// There are a few bindings to `from_char_code` in `js-sys`: `from_char_code1`, `from_char_code2`, etc...
9319    /// with different arities.
9320    #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode, variadic)]
9321    pub fn from_char_code(char_codes: &[u16]) -> JsString;
9322
9323    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
9324    #[cfg(not(js_sys_unstable_apis))]
9325    #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)]
9326    pub fn from_char_code1(a: u32) -> JsString;
9327
9328    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
9329    #[cfg(js_sys_unstable_apis)]
9330    #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)]
9331    pub fn from_char_code1(a: u16) -> JsString;
9332
9333    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
9334    #[cfg(not(js_sys_unstable_apis))]
9335    #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)]
9336    pub fn from_char_code2(a: u32, b: u32) -> JsString;
9337
9338    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
9339    #[cfg(js_sys_unstable_apis)]
9340    #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)]
9341    pub fn from_char_code2(a: u16, b: u16) -> JsString;
9342
9343    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
9344    #[cfg(not(js_sys_unstable_apis))]
9345    #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)]
9346    pub fn from_char_code3(a: u32, b: u32, c: u32) -> JsString;
9347
9348    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
9349    #[cfg(js_sys_unstable_apis)]
9350    #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)]
9351    pub fn from_char_code3(a: u16, b: u16, c: u16) -> JsString;
9352
9353    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
9354    #[cfg(not(js_sys_unstable_apis))]
9355    #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)]
9356    pub fn from_char_code4(a: u32, b: u32, c: u32, d: u32) -> JsString;
9357
9358    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
9359    #[cfg(js_sys_unstable_apis)]
9360    #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)]
9361    pub fn from_char_code4(a: u16, b: u16, c: u16, d: u16) -> JsString;
9362
9363    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
9364    #[cfg(not(js_sys_unstable_apis))]
9365    #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)]
9366    pub fn from_char_code5(a: u32, b: u32, c: u32, d: u32, e: u32) -> JsString;
9367
9368    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
9369    #[cfg(js_sys_unstable_apis)]
9370    #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)]
9371    pub fn from_char_code5(a: u16, b: u16, c: u16, d: u16, e: u16) -> JsString;
9372
9373    /// The static `String.fromCodePoint()` method returns a string created by
9374    /// using the specified sequence of code points.
9375    ///
9376    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)
9377    ///
9378    /// # Exceptions
9379    ///
9380    /// A RangeError is thrown if an invalid Unicode code point is given
9381    ///
9382    /// # Notes
9383    ///
9384    /// There are a few bindings to `from_code_point` in `js-sys`: `from_code_point1`, `from_code_point2`, etc...
9385    /// with different arities.
9386    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = fromCodePoint, variadic)]
9387    pub fn from_code_point(code_points: &[u32]) -> Result<JsString, JsValue>;
9388
9389    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)
9390    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = fromCodePoint)]
9391    pub fn from_code_point1(a: u32) -> Result<JsString, JsValue>;
9392
9393    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)
9394    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = fromCodePoint)]
9395    pub fn from_code_point2(a: u32, b: u32) -> Result<JsString, JsValue>;
9396
9397    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)
9398    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = fromCodePoint)]
9399    pub fn from_code_point3(a: u32, b: u32, c: u32) -> Result<JsString, JsValue>;
9400
9401    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)
9402    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = fromCodePoint)]
9403    pub fn from_code_point4(a: u32, b: u32, c: u32, d: u32) -> Result<JsString, JsValue>;
9404
9405    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)
9406    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = fromCodePoint)]
9407    pub fn from_code_point5(a: u32, b: u32, c: u32, d: u32, e: u32) -> Result<JsString, JsValue>;
9408
9409    /// The `includes()` method determines whether one string may be found
9410    /// within another string, returning true or false as appropriate.
9411    ///
9412    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes)
9413    #[wasm_bindgen(method, js_class = "String")]
9414    pub fn includes(this: &JsString, search_string: &str, position: i32) -> bool;
9415
9416    /// The `indexOf()` method returns the index within the calling String
9417    /// object of the first occurrence of the specified value, starting the
9418    /// search at fromIndex.  Returns -1 if the value is not found.
9419    ///
9420    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf)
9421    #[wasm_bindgen(method, js_class = "String", js_name = indexOf)]
9422    pub fn index_of(this: &JsString, search_value: &str, from_index: i32) -> i32;
9423
9424    /// The `lastIndexOf()` method returns the index within the calling String
9425    /// object of the last occurrence of the specified value, searching
9426    /// backwards from fromIndex.  Returns -1 if the value is not found.
9427    ///
9428    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/lastIndexOf)
9429    #[wasm_bindgen(method, js_class = "String", js_name = lastIndexOf)]
9430    pub fn last_index_of(this: &JsString, search_value: &str, from_index: i32) -> i32;
9431
9432    /// The `localeCompare()` method returns a number indicating whether
9433    /// a reference string comes before or after or is the same as
9434    /// the given string in sort order.
9435    ///
9436    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare)
9437    #[cfg(not(js_sys_unstable_apis))]
9438    #[wasm_bindgen(method, js_class = "String", js_name = localeCompare)]
9439    pub fn locale_compare(
9440        this: &JsString,
9441        compare_string: &str,
9442        locales: &Array,
9443        options: &Object,
9444    ) -> i32;
9445
9446    /// The `localeCompare()` method returns a number indicating whether
9447    /// a reference string comes before or after or is the same as
9448    /// the given string in sort order.
9449    ///
9450    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare)
9451    #[cfg(js_sys_unstable_apis)]
9452    #[wasm_bindgen(method, js_class = "String", js_name = localeCompare)]
9453    pub fn locale_compare(
9454        this: &JsString,
9455        compare_string: &str,
9456        locales: &[JsString],
9457        options: &Intl::CollatorOptions,
9458    ) -> i32;
9459
9460    /// The `match()` method retrieves the matches when matching a string against a regular expression.
9461    ///
9462    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match)
9463    #[wasm_bindgen(method, js_class = "String", js_name = match)]
9464    pub fn match_(this: &JsString, pattern: &RegExp) -> Option<Object>;
9465
9466    /// The `match_all()` method is similar to `match()`, but gives an iterator of `exec()` arrays, which preserve capture groups.
9467    ///
9468    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/matchAll)
9469    #[cfg(not(js_sys_unstable_apis))]
9470    #[wasm_bindgen(method, js_class = "String", js_name = matchAll)]
9471    pub fn match_all(this: &JsString, pattern: &RegExp) -> Iterator;
9472
9473    /// The `match_all()` method is similar to `match()`, but gives an iterator of `exec()` arrays, which preserve capture groups.
9474    ///
9475    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/matchAll)
9476    #[cfg(js_sys_unstable_apis)]
9477    #[wasm_bindgen(method, js_class = "String", js_name = matchAll)]
9478    pub fn match_all(this: &JsString, pattern: &RegExp) -> Iterator<RegExpMatchArray>;
9479
9480    /// The `normalize()` method returns the Unicode Normalization Form
9481    /// of a given string (if the value isn't a string, it will be converted to one first).
9482    ///
9483    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize)
9484    #[wasm_bindgen(method, js_class = "String")]
9485    pub fn normalize(this: &JsString, form: &str) -> JsString;
9486
9487    /// The `padEnd()` method pads the current string with a given string
9488    /// (repeated, if needed) so that the resulting string reaches a given
9489    /// length. The padding is applied from the end (right) of the current
9490    /// string.
9491    ///
9492    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padEnd)
9493    #[wasm_bindgen(method, js_class = "String", js_name = padEnd)]
9494    pub fn pad_end(this: &JsString, target_length: u32, pad_string: &str) -> JsString;
9495
9496    /// The `padStart()` method pads the current string with another string
9497    /// (repeated, if needed) so that the resulting string reaches the given
9498    /// length. The padding is applied from the start (left) of the current
9499    /// string.
9500    ///
9501    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padStart)
9502    #[wasm_bindgen(method, js_class = "String", js_name = padStart)]
9503    pub fn pad_start(this: &JsString, target_length: u32, pad_string: &str) -> JsString;
9504
9505    /// The `repeat()` method constructs and returns a new string which contains the specified
9506    /// number of copies of the string on which it was called, concatenated together.
9507    ///
9508    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat)
9509    #[wasm_bindgen(method, js_class = "String")]
9510    pub fn repeat(this: &JsString, count: i32) -> JsString;
9511
9512    /// The `replace()` method returns a new string with some or all matches of a pattern
9513    /// replaced by a replacement. The pattern can be a string or a RegExp, and
9514    /// the replacement can be a string or a function to be called for each match.
9515    ///
9516    /// Note: The original string will remain unchanged.
9517    ///
9518    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace)
9519    #[wasm_bindgen(method, js_class = "String")]
9520    pub fn replace(this: &JsString, pattern: &str, replacement: &str) -> JsString;
9521
9522    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace)
9523    #[cfg(not(js_sys_unstable_apis))]
9524    #[wasm_bindgen(method, js_class = "String", js_name = replace)]
9525    pub fn replace_with_function(
9526        this: &JsString,
9527        pattern: &str,
9528        replacement: &Function,
9529    ) -> JsString;
9530
9531    /// The replacer function signature is `(match, offset, string) -> replacement`
9532    /// for patterns without capture groups, or `(match, p1, p2, ..., pN, offset, string, groups) -> replacement`
9533    /// when capture groups are present.
9534    ///
9535    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace)
9536    #[cfg(js_sys_unstable_apis)]
9537    #[wasm_bindgen(method, js_class = "String", js_name = replace)]
9538    pub fn replace_with_function(
9539        this: &JsString,
9540        pattern: &str,
9541        replacement: &Function<fn(JsString) -> JsString>,
9542    ) -> JsString;
9543
9544    #[wasm_bindgen(method, js_class = "String", js_name = replace)]
9545    pub fn replace_by_pattern(this: &JsString, pattern: &RegExp, replacement: &str) -> JsString;
9546
9547    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace)
9548    #[cfg(not(js_sys_unstable_apis))]
9549    #[wasm_bindgen(method, js_class = "String", js_name = replace)]
9550    pub fn replace_by_pattern_with_function(
9551        this: &JsString,
9552        pattern: &RegExp,
9553        replacement: &Function,
9554    ) -> JsString;
9555
9556    /// The replacer function signature is `(match, offset, string) -> replacement`
9557    /// for patterns without capture groups, or `(match, p1, p2, ..., pN, offset, string, groups) -> replacement`
9558    /// when capture groups are present.
9559    ///
9560    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace)
9561    #[cfg(js_sys_unstable_apis)]
9562    #[wasm_bindgen(method, js_class = "String", js_name = replace)]
9563    pub fn replace_by_pattern_with_function(
9564        this: &JsString,
9565        pattern: &RegExp,
9566        replacement: &Function<fn(JsString) -> JsString>,
9567    ) -> JsString;
9568
9569    /// The `replace_all()` method returns a new string with all matches of a pattern
9570    /// replaced by a replacement. The pattern can be a string or a global RegExp, and
9571    /// the replacement can be a string or a function to be called for each match.
9572    ///
9573    /// Note: The original string will remain unchanged.
9574    ///
9575    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replaceAll)
9576    #[wasm_bindgen(method, js_class = "String", js_name = replaceAll)]
9577    pub fn replace_all(this: &JsString, pattern: &str, replacement: &str) -> JsString;
9578
9579    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replaceAll)
9580    #[cfg(not(js_sys_unstable_apis))]
9581    #[wasm_bindgen(method, js_class = "String", js_name = replaceAll)]
9582    pub fn replace_all_with_function(
9583        this: &JsString,
9584        pattern: &str,
9585        replacement: &Function,
9586    ) -> JsString;
9587
9588    /// The replacer function signature is `(match, offset, string) -> replacement`
9589    /// for patterns without capture groups, or `(match, p1, p2, ..., pN, offset, string, groups) -> replacement`
9590    /// when capture groups are present.
9591    ///
9592    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replaceAll)
9593    #[cfg(js_sys_unstable_apis)]
9594    #[wasm_bindgen(method, js_class = "String", js_name = replaceAll)]
9595    pub fn replace_all_with_function(
9596        this: &JsString,
9597        pattern: &str,
9598        replacement: &Function<fn(JsString) -> JsString>,
9599    ) -> JsString;
9600
9601    #[wasm_bindgen(method, js_class = "String", js_name = replaceAll)]
9602    pub fn replace_all_by_pattern(this: &JsString, pattern: &RegExp, replacement: &str)
9603        -> JsString;
9604
9605    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replaceAll)
9606    #[cfg(not(js_sys_unstable_apis))]
9607    #[wasm_bindgen(method, js_class = "String", js_name = replaceAll)]
9608    pub fn replace_all_by_pattern_with_function(
9609        this: &JsString,
9610        pattern: &RegExp,
9611        replacement: &Function,
9612    ) -> JsString;
9613
9614    /// The replacer function signature is `(match, offset, string) -> replacement`
9615    /// for patterns without capture groups, or `(match, p1, p2, ..., pN, offset, string, groups) -> replacement`
9616    /// when capture groups are present.
9617    ///
9618    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replaceAll)
9619    #[cfg(js_sys_unstable_apis)]
9620    #[wasm_bindgen(method, js_class = "String", js_name = replaceAll)]
9621    pub fn replace_all_by_pattern_with_function(
9622        this: &JsString,
9623        pattern: &RegExp,
9624        replacement: &Function<fn(JsString) -> JsString>,
9625    ) -> JsString;
9626
9627    /// The `search()` method executes a search for a match between
9628    /// a regular expression and this String object.
9629    ///
9630    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/search)
9631    #[wasm_bindgen(method, js_class = "String")]
9632    pub fn search(this: &JsString, pattern: &RegExp) -> i32;
9633
9634    /// The `slice()` method extracts a section of a string and returns it as a
9635    /// new string, without modifying the original string.
9636    ///
9637    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice)
9638    #[wasm_bindgen(method, js_class = "String")]
9639    pub fn slice(this: &JsString, start: u32, end: u32) -> JsString;
9640
9641    /// The `split()` method splits a String object into an array of strings by separating the string
9642    /// into substrings, using a specified separator string to determine where to make each split.
9643    ///
9644    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split)
9645    #[wasm_bindgen(method, js_class = "String")]
9646    pub fn split(this: &JsString, separator: &str) -> Array;
9647
9648    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split)
9649    #[wasm_bindgen(method, js_class = "String", js_name = split)]
9650    pub fn split_limit(this: &JsString, separator: &str, limit: u32) -> Array;
9651
9652    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split)
9653    #[wasm_bindgen(method, js_class = "String", js_name = split)]
9654    pub fn split_by_pattern(this: &JsString, pattern: &RegExp) -> Array;
9655
9656    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split)
9657    #[wasm_bindgen(method, js_class = "String", js_name = split)]
9658    pub fn split_by_pattern_limit(this: &JsString, pattern: &RegExp, limit: u32) -> Array;
9659
9660    /// The `startsWith()` method determines whether a string begins with the
9661    /// characters of a specified string, returning true or false as
9662    /// appropriate.
9663    ///
9664    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith)
9665    #[wasm_bindgen(method, js_class = "String", js_name = startsWith)]
9666    pub fn starts_with(this: &JsString, search_string: &str, position: u32) -> bool;
9667
9668    /// The `substring()` method returns the part of the string between the
9669    /// start and end indexes, or to the end of the string.
9670    ///
9671    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring)
9672    #[wasm_bindgen(method, js_class = "String")]
9673    pub fn substring(this: &JsString, index_start: u32, index_end: u32) -> JsString;
9674
9675    /// The `substr()` method returns the part of a string between
9676    /// the start index and a number of characters after it.
9677    ///
9678    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr)
9679    #[wasm_bindgen(method, js_class = "String")]
9680    pub fn substr(this: &JsString, start: i32, length: i32) -> JsString;
9681
9682    /// The `toLocaleLowerCase()` method returns the calling string value converted to lower case,
9683    /// according to any locale-specific case mappings.
9684    ///
9685    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase)
9686    #[wasm_bindgen(method, js_class = "String", js_name = toLocaleLowerCase)]
9687    pub fn to_locale_lower_case(this: &JsString, locale: Option<&str>) -> JsString;
9688
9689    /// The `toLocaleUpperCase()` method returns the calling string value converted to upper case,
9690    /// according to any locale-specific case mappings.
9691    ///
9692    /// [MDN documentation](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleUpperCase)
9693    #[wasm_bindgen(method, js_class = "String", js_name = toLocaleUpperCase)]
9694    pub fn to_locale_upper_case(this: &JsString, locale: Option<&str>) -> JsString;
9695
9696    /// The `toLowerCase()` method returns the calling string value
9697    /// converted to lower case.
9698    ///
9699    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLowerCase)
9700    #[wasm_bindgen(method, js_class = "String", js_name = toLowerCase)]
9701    pub fn to_lower_case(this: &JsString) -> JsString;
9702
9703    /// The `toString()` method returns a string representing the specified
9704    /// object.
9705    ///
9706    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toString)
9707    #[cfg(not(js_sys_unstable_apis))]
9708    #[wasm_bindgen(method, js_class = "String", js_name = toString)]
9709    pub fn to_string(this: &JsString) -> JsString;
9710
9711    /// The `toUpperCase()` method returns the calling string value converted to
9712    /// uppercase (the value will be converted to a string if it isn't one).
9713    ///
9714    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase)
9715    #[wasm_bindgen(method, js_class = "String", js_name = toUpperCase)]
9716    pub fn to_upper_case(this: &JsString) -> JsString;
9717
9718    /// The `trim()` method removes whitespace from both ends of a string.
9719    /// Whitespace in this context is all the whitespace characters (space, tab,
9720    /// no-break space, etc.) and all the line terminator characters (LF, CR,
9721    /// etc.).
9722    ///
9723    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trim)
9724    #[wasm_bindgen(method, js_class = "String")]
9725    pub fn trim(this: &JsString) -> JsString;
9726
9727    /// The `trimEnd()` method removes whitespace from the end of a string.
9728    /// `trimRight()` is an alias of this method.
9729    ///
9730    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimEnd)
9731    #[wasm_bindgen(method, js_class = "String", js_name = trimEnd)]
9732    pub fn trim_end(this: &JsString) -> JsString;
9733
9734    /// The `trimEnd()` method removes whitespace from the end of a string.
9735    /// `trimRight()` is an alias of this method.
9736    ///
9737    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimEnd)
9738    #[wasm_bindgen(method, js_class = "String", js_name = trimRight)]
9739    pub fn trim_right(this: &JsString) -> JsString;
9740
9741    /// The `trimStart()` method removes whitespace from the beginning of a
9742    /// string. `trimLeft()` is an alias of this method.
9743    ///
9744    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimStart)
9745    #[wasm_bindgen(method, js_class = "String", js_name = trimStart)]
9746    pub fn trim_start(this: &JsString) -> JsString;
9747
9748    /// The `trimStart()` method removes whitespace from the beginning of a
9749    /// string. `trimLeft()` is an alias of this method.
9750    ///
9751    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimStart)
9752    #[wasm_bindgen(method, js_class = "String", js_name = trimLeft)]
9753    pub fn trim_left(this: &JsString) -> JsString;
9754
9755    /// The `valueOf()` method returns the primitive value of a `String` object.
9756    ///
9757    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/valueOf)
9758    #[wasm_bindgen(method, js_class = "String", js_name = valueOf)]
9759    pub fn value_of(this: &JsString) -> JsString;
9760
9761    /// The static `raw()` method is a tag function of template literals,
9762    /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
9763    ///
9764    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
9765    #[wasm_bindgen(catch, variadic, static_method_of = JsString, js_class = "String")]
9766    pub fn raw(call_site: &Object, substitutions: &Array) -> Result<JsString, JsValue>;
9767
9768    /// The static `raw()` method is a tag function of template literals,
9769    /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
9770    ///
9771    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
9772    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = raw)]
9773    pub fn raw_0(call_site: &Object) -> Result<JsString, JsValue>;
9774
9775    /// The static `raw()` method is a tag function of template literals,
9776    /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
9777    ///
9778    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
9779    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = raw)]
9780    pub fn raw_1(call_site: &Object, substitutions_1: &str) -> Result<JsString, JsValue>;
9781
9782    /// The static `raw()` method is a tag function of template literals,
9783    /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
9784    ///
9785    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
9786    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = raw)]
9787    pub fn raw_2(
9788        call_site: &Object,
9789        substitutions1: &str,
9790        substitutions2: &str,
9791    ) -> Result<JsString, JsValue>;
9792
9793    /// The static `raw()` method is a tag function of template literals,
9794    /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
9795    ///
9796    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
9797    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = raw)]
9798    pub fn raw_3(
9799        call_site: &Object,
9800        substitutions1: &str,
9801        substitutions2: &str,
9802        substitutions3: &str,
9803    ) -> Result<JsString, JsValue>;
9804
9805    /// The static `raw()` method is a tag function of template literals,
9806    /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
9807    ///
9808    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
9809    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = raw)]
9810    pub fn raw_4(
9811        call_site: &Object,
9812        substitutions1: &str,
9813        substitutions2: &str,
9814        substitutions3: &str,
9815        substitutions4: &str,
9816    ) -> Result<JsString, JsValue>;
9817
9818    /// The static `raw()` method is a tag function of template literals,
9819    /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
9820    ///
9821    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
9822    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = raw)]
9823    pub fn raw_5(
9824        call_site: &Object,
9825        substitutions1: &str,
9826        substitutions2: &str,
9827        substitutions3: &str,
9828        substitutions4: &str,
9829        substitutions5: &str,
9830    ) -> Result<JsString, JsValue>;
9831
9832    /// The static `raw()` method is a tag function of template literals,
9833    /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
9834    ///
9835    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
9836    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = raw)]
9837    pub fn raw_6(
9838        call_site: &Object,
9839        substitutions1: &str,
9840        substitutions2: &str,
9841        substitutions3: &str,
9842        substitutions4: &str,
9843        substitutions5: &str,
9844        substitutions6: &str,
9845    ) -> Result<JsString, JsValue>;
9846
9847    /// The static `raw()` method is a tag function of template literals,
9848    /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
9849    ///
9850    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
9851    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = raw)]
9852    pub fn raw_7(
9853        call_site: &Object,
9854        substitutions1: &str,
9855        substitutions2: &str,
9856        substitutions3: &str,
9857        substitutions4: &str,
9858        substitutions5: &str,
9859        substitutions6: &str,
9860        substitutions7: &str,
9861    ) -> Result<JsString, JsValue>;
9862}
9863
9864// These upcasts are non-castable due to the constraints on the function
9865// but the UpcastFrom covariance must still extend through closure types.
9866// (impl UpcastFrom really just means CovariantGeneric relation)
9867impl UpcastFrom<String> for JsString {}
9868impl UpcastFrom<JsString> for String {}
9869
9870impl UpcastFrom<&str> for JsString {}
9871impl UpcastFrom<JsString> for &str {}
9872
9873impl UpcastFrom<char> for JsString {}
9874impl UpcastFrom<JsString> for char {}
9875
9876impl wasm_bindgen::__rt::marker::JsStringLikeSealed for JsString {}
9877impl wasm_bindgen::__rt::marker::JsStringLikeSealed for &JsString {}
9878impl wasm_bindgen::JsStringLike for JsString {}
9879impl wasm_bindgen::JsStringLike for &JsString {}
9880
9881impl JsString {
9882    /// Returns the `JsString` value of this JS value if it's an instance of a
9883    /// string.
9884    ///
9885    /// If this JS value is not an instance of a string then this returns
9886    /// `None`.
9887    #[cfg(not(js_sys_unstable_apis))]
9888    #[deprecated(note = "recommended to use dyn_ref instead which is now equivalent")]
9889    pub fn try_from(val: &JsValue) -> Option<&JsString> {
9890        val.dyn_ref()
9891    }
9892
9893    /// Returns whether this string is a valid UTF-16 string.
9894    ///
9895    /// This is useful for learning whether `String::from(..)` will return a
9896    /// lossless representation of the JS string. If this string contains
9897    /// unpaired surrogates then `String::from` will succeed but it will be a
9898    /// lossy representation of the JS string because unpaired surrogates will
9899    /// become replacement characters.
9900    ///
9901    /// If this function returns `false` then to get a lossless representation
9902    /// of the string you'll need to manually use the `iter` method (or the
9903    /// `char_code_at` accessor) to view the raw character codes.
9904    ///
9905    /// For more information, see the documentation on [JS strings vs Rust
9906    /// strings][docs]
9907    ///
9908    /// [docs]: https://wasm-bindgen.github.io/wasm-bindgen/reference/types/str.html
9909    pub fn is_valid_utf16(&self) -> bool {
9910        core::char::decode_utf16(self.iter()).all(|i| i.is_ok())
9911    }
9912
9913    /// Returns an iterator over the `u16` character codes that make up this JS
9914    /// string.
9915    ///
9916    /// This method will call `char_code_at` for each code in this JS string,
9917    /// returning an iterator of the codes in sequence.
9918    pub fn iter(
9919        &self,
9920    ) -> impl ExactSizeIterator<Item = u16> + DoubleEndedIterator<Item = u16> + '_ {
9921        (0..self.length()).map(move |i| self.char_code_at(i) as u16)
9922    }
9923
9924    /// If this string consists of a single Unicode code point, then this method
9925    /// converts it into a Rust `char` without doing any allocations.
9926    ///
9927    /// If this JS value is not a valid UTF-8 or consists of more than a single
9928    /// codepoint, then this returns `None`.
9929    ///
9930    /// Note that a single Unicode code point might be represented as more than
9931    /// one code unit on the JavaScript side. For example, a JavaScript string
9932    /// `"\uD801\uDC37"` is actually a single Unicode code point U+10437 which
9933    /// corresponds to a character '𐐷'.
9934    pub fn as_char(&self) -> Option<char> {
9935        let len = self.length();
9936
9937        if len == 0 || len > 2 {
9938            return None;
9939        }
9940
9941        #[cfg(not(js_sys_unstable_apis))]
9942        let cp = self.code_point_at(0).as_f64().unwrap_throw() as u32;
9943        #[cfg(js_sys_unstable_apis)]
9944        let cp = self.code_point_at(0)?;
9945
9946        let c = core::char::from_u32(cp)?;
9947
9948        if c.len_utf16() as u32 == len {
9949            Some(c)
9950        } else {
9951            None
9952        }
9953    }
9954}
9955
9956impl PartialEq<str> for JsString {
9957    #[allow(clippy::cmp_owned)] // prevent infinite recursion
9958    fn eq(&self, other: &str) -> bool {
9959        String::from(self) == other
9960    }
9961}
9962
9963impl<'a> PartialEq<&'a str> for JsString {
9964    fn eq(&self, other: &&'a str) -> bool {
9965        <JsString as PartialEq<str>>::eq(self, other)
9966    }
9967}
9968
9969impl PartialEq<String> for JsString {
9970    fn eq(&self, other: &String) -> bool {
9971        <JsString as PartialEq<str>>::eq(self, other)
9972    }
9973}
9974
9975impl<'a> PartialEq<&'a String> for JsString {
9976    fn eq(&self, other: &&'a String) -> bool {
9977        <JsString as PartialEq<str>>::eq(self, other)
9978    }
9979}
9980
9981impl Default for JsString {
9982    fn default() -> Self {
9983        Self::from("")
9984    }
9985}
9986
9987impl<'a> From<&'a str> for JsString {
9988    fn from(s: &'a str) -> Self {
9989        JsString::unchecked_from_js(JsValue::from_str(s))
9990    }
9991}
9992
9993impl From<String> for JsString {
9994    fn from(s: String) -> Self {
9995        From::from(&*s)
9996    }
9997}
9998
9999impl From<char> for JsString {
10000    #[inline]
10001    fn from(c: char) -> Self {
10002        JsString::from_code_point1(c as u32).unwrap_throw()
10003    }
10004}
10005
10006impl<'a> From<&'a JsString> for String {
10007    fn from(s: &'a JsString) -> Self {
10008        s.obj.as_string().unwrap_throw()
10009    }
10010}
10011
10012impl From<JsString> for String {
10013    fn from(s: JsString) -> Self {
10014        From::from(&s)
10015    }
10016}
10017
10018impl fmt::Debug for JsString {
10019    #[inline]
10020    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
10021        fmt::Debug::fmt(&String::from(self), f)
10022    }
10023}
10024
10025impl fmt::Display for JsString {
10026    #[inline]
10027    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
10028        fmt::Display::fmt(&String::from(self), f)
10029    }
10030}
10031
10032impl str::FromStr for JsString {
10033    type Err = convert::Infallible;
10034    fn from_str(s: &str) -> Result<Self, Self::Err> {
10035        Ok(JsString::from(s))
10036    }
10037}
10038
10039// Symbol
10040#[wasm_bindgen]
10041extern "C" {
10042    #[wasm_bindgen(is_type_of = JsValue::is_symbol, typescript_type = "Symbol")]
10043    #[derive(Clone, Debug)]
10044    pub type Symbol;
10045
10046    /// The `Symbol.hasInstance` well-known symbol is used to determine
10047    /// if a constructor object recognizes an object as its instance.
10048    /// The `instanceof` operator's behavior can be customized by this symbol.
10049    ///
10050    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/hasInstance)
10051    #[wasm_bindgen(static_method_of = Symbol, getter, js_name = hasInstance)]
10052    pub fn has_instance() -> Symbol;
10053
10054    /// The `Symbol.isConcatSpreadable` well-known symbol is used to configure
10055    /// if an object should be flattened to its array elements when using the
10056    /// `Array.prototype.concat()` method.
10057    ///
10058    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/isConcatSpreadable)
10059    #[wasm_bindgen(static_method_of = Symbol, getter, js_name = isConcatSpreadable)]
10060    pub fn is_concat_spreadable() -> Symbol;
10061
10062    /// The `Symbol.asyncIterator` well-known symbol specifies the default AsyncIterator for an object.
10063    /// If this property is set on an object, it is an async iterable and can be used in a `for await...of` loop.
10064    ///
10065    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/asyncIterator)
10066    #[wasm_bindgen(static_method_of = Symbol, getter, js_name = asyncIterator)]
10067    pub fn async_iterator() -> Symbol;
10068
10069    /// The `Symbol.iterator` well-known symbol specifies the default iterator
10070    /// for an object.  Used by `for...of`.
10071    ///
10072    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/iterator)
10073    #[wasm_bindgen(static_method_of = Symbol, getter)]
10074    pub fn iterator() -> Symbol;
10075
10076    /// The `Symbol.match` well-known symbol specifies the matching of a regular
10077    /// expression against a string. This function is called by the
10078    /// `String.prototype.match()` method.
10079    ///
10080    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/match)
10081    #[wasm_bindgen(static_method_of = Symbol, getter, js_name = match)]
10082    pub fn match_() -> Symbol;
10083
10084    /// The `Symbol.replace` well-known symbol specifies the method that
10085    /// replaces matched substrings of a string.  This function is called by the
10086    /// `String.prototype.replace()` method.
10087    ///
10088    /// For more information, see `RegExp.prototype[@@replace]()` and
10089    /// `String.prototype.replace()`.
10090    ///
10091    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/replace)
10092    #[wasm_bindgen(static_method_of = Symbol, getter)]
10093    pub fn replace() -> Symbol;
10094
10095    /// The `Symbol.search` well-known symbol specifies the method that returns
10096    /// the index within a string that matches the regular expression.  This
10097    /// function is called by the `String.prototype.search()` method.
10098    ///
10099    /// For more information, see `RegExp.prototype[@@search]()` and
10100    /// `String.prototype.search()`.
10101    ///
10102    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/search)
10103    #[wasm_bindgen(static_method_of = Symbol, getter)]
10104    pub fn search() -> Symbol;
10105
10106    /// The well-known symbol `Symbol.species` specifies a function-valued
10107    /// property that the constructor function uses to create derived objects.
10108    ///
10109    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/species)
10110    #[wasm_bindgen(static_method_of = Symbol, getter)]
10111    pub fn species() -> Symbol;
10112
10113    /// The `Symbol.split` well-known symbol specifies the method that splits a
10114    /// string at the indices that match a regular expression.  This function is
10115    /// called by the `String.prototype.split()` method.
10116    ///
10117    /// For more information, see `RegExp.prototype[@@split]()` and
10118    /// `String.prototype.split()`.
10119    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/split)
10120    #[wasm_bindgen(static_method_of = Symbol, getter)]
10121    pub fn split() -> Symbol;
10122
10123    /// The `Symbol.toPrimitive` is a symbol that specifies a function valued
10124    /// property that is called to convert an object to a corresponding
10125    /// primitive value.
10126    ///
10127    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toPrimitive)
10128    #[wasm_bindgen(static_method_of = Symbol, getter, js_name = toPrimitive)]
10129    pub fn to_primitive() -> Symbol;
10130
10131    /// The `Symbol.toStringTag` well-known symbol is a string valued property
10132    /// that is used in the creation of the default string description of an
10133    /// object.  It is accessed internally by the `Object.prototype.toString()`
10134    /// method.
10135    ///
10136    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toString)
10137    #[wasm_bindgen(static_method_of = Symbol, getter, js_name = toStringTag)]
10138    pub fn to_string_tag() -> Symbol;
10139
10140    /// The `Symbol.for(key)` method searches for existing symbols in a runtime-wide symbol registry with
10141    /// the given key and returns it if found.
10142    /// Otherwise a new symbol gets created in the global symbol registry with this key.
10143    ///
10144    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/for)
10145    #[wasm_bindgen(static_method_of = Symbol, js_name = for)]
10146    pub fn for_(key: &str) -> Symbol;
10147
10148    /// The `Symbol.keyFor(sym)` method retrieves a shared symbol key from the global symbol registry for the given symbol.
10149    ///
10150    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/keyFor)
10151    #[wasm_bindgen(static_method_of = Symbol, js_name = keyFor)]
10152    pub fn key_for(sym: &Symbol) -> JsValue;
10153
10154    // Next major: deprecate
10155    /// The `toString()` method returns a string representing the specified Symbol object.
10156    ///
10157    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toString)
10158    #[wasm_bindgen(method, js_name = toString)]
10159    pub fn to_string(this: &Symbol) -> JsString;
10160
10161    /// The `toString()` method returns a string representing the specified Symbol object.
10162    ///
10163    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toString)
10164    #[wasm_bindgen(method, js_name = toString)]
10165    pub fn to_js_string(this: &Symbol) -> JsString;
10166
10167    /// The `Symbol.unscopables` well-known symbol is used to specify an object
10168    /// value of whose own and inherited property names are excluded from the
10169    /// with environment bindings of the associated object.
10170    ///
10171    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/unscopables)
10172    #[wasm_bindgen(static_method_of = Symbol, getter)]
10173    pub fn unscopables() -> Symbol;
10174
10175    /// The `valueOf()` method returns the primitive value of a Symbol object.
10176    ///
10177    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/valueOf)
10178    #[wasm_bindgen(method, js_name = valueOf)]
10179    pub fn value_of(this: &Symbol) -> Symbol;
10180}
10181
10182#[allow(non_snake_case)]
10183pub mod Intl {
10184    use super::*;
10185
10186    // Intl
10187    #[wasm_bindgen]
10188    extern "C" {
10189        /// The `Intl.getCanonicalLocales()` method returns an array containing
10190        /// the canonical locale names. Duplicates will be omitted and elements
10191        /// will be validated as structurally valid language tags.
10192        ///
10193        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/getCanonicalLocales)
10194        #[cfg(not(js_sys_unstable_apis))]
10195        #[wasm_bindgen(js_name = getCanonicalLocales, js_namespace = Intl)]
10196        pub fn get_canonical_locales(s: &JsValue) -> Array;
10197
10198        /// The `Intl.getCanonicalLocales()` method returns an array containing
10199        /// the canonical locale names. Duplicates will be omitted and elements
10200        /// will be validated as structurally valid language tags.
10201        ///
10202        /// Throws a `RangeError` if any of the strings are not valid locale identifiers.
10203        ///
10204        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/getCanonicalLocales)
10205        #[cfg(js_sys_unstable_apis)]
10206        #[wasm_bindgen(js_name = getCanonicalLocales, js_namespace = Intl, catch)]
10207        pub fn get_canonical_locales(s: &[JsString]) -> Result<Array<JsString>, JsValue>;
10208
10209        /// The `Intl.supportedValuesOf()` method returns an array containing the
10210        /// supported calendar, collation, currency, numbering system, or unit values
10211        /// supported by the implementation.
10212        ///
10213        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/supportedValuesOf)
10214        #[wasm_bindgen(js_name = supportedValuesOf, js_namespace = Intl)]
10215        pub fn supported_values_of(key: SupportedValuesKey) -> Array<JsString>;
10216    }
10217
10218    // Intl string enums
10219
10220    /// Key for `Intl.supportedValuesOf()`.
10221    #[wasm_bindgen]
10222    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10223    pub enum SupportedValuesKey {
10224        Calendar = "calendar",
10225        Collation = "collation",
10226        Currency = "currency",
10227        NumberingSystem = "numberingSystem",
10228        TimeZone = "timeZone",
10229        Unit = "unit",
10230    }
10231
10232    /// Locale matching algorithm for Intl constructors.
10233    #[wasm_bindgen]
10234    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10235    pub enum LocaleMatcher {
10236        Lookup = "lookup",
10237        BestFit = "best fit",
10238    }
10239
10240    /// Usage for `Intl.Collator`.
10241    #[wasm_bindgen]
10242    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10243    pub enum CollatorUsage {
10244        Sort = "sort",
10245        Search = "search",
10246    }
10247
10248    /// Sensitivity for `Intl.Collator`.
10249    #[wasm_bindgen]
10250    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10251    pub enum CollatorSensitivity {
10252        Base = "base",
10253        Accent = "accent",
10254        Case = "case",
10255        Variant = "variant",
10256    }
10257
10258    /// Case first option for `Intl.Collator`.
10259    #[wasm_bindgen]
10260    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10261    pub enum CollatorCaseFirst {
10262        Upper = "upper",
10263        Lower = "lower",
10264        False = "false",
10265    }
10266
10267    /// Style for `Intl.NumberFormat`.
10268    #[wasm_bindgen]
10269    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10270    pub enum NumberFormatStyle {
10271        Decimal = "decimal",
10272        Currency = "currency",
10273        Percent = "percent",
10274        Unit = "unit",
10275    }
10276
10277    /// Currency display for `Intl.NumberFormat`.
10278    #[wasm_bindgen]
10279    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10280    pub enum CurrencyDisplay {
10281        Code = "code",
10282        Symbol = "symbol",
10283        NarrowSymbol = "narrowSymbol",
10284        Name = "name",
10285    }
10286
10287    /// Currency sign for `Intl.NumberFormat`.
10288    #[wasm_bindgen]
10289    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10290    pub enum CurrencySign {
10291        Standard = "standard",
10292        Accounting = "accounting",
10293    }
10294
10295    /// Unit display for `Intl.NumberFormat`.
10296    #[wasm_bindgen]
10297    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10298    pub enum UnitDisplay {
10299        Short = "short",
10300        Narrow = "narrow",
10301        Long = "long",
10302    }
10303
10304    /// Notation for `Intl.NumberFormat`.
10305    #[wasm_bindgen]
10306    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10307    pub enum NumberFormatNotation {
10308        Standard = "standard",
10309        Scientific = "scientific",
10310        Engineering = "engineering",
10311        Compact = "compact",
10312    }
10313
10314    /// Compact display for `Intl.NumberFormat`.
10315    #[wasm_bindgen]
10316    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10317    pub enum CompactDisplay {
10318        Short = "short",
10319        Long = "long",
10320    }
10321
10322    /// Sign display for `Intl.NumberFormat`.
10323    #[wasm_bindgen]
10324    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10325    pub enum SignDisplay {
10326        Auto = "auto",
10327        Never = "never",
10328        Always = "always",
10329        ExceptZero = "exceptZero",
10330    }
10331
10332    /// Rounding mode for `Intl.NumberFormat`.
10333    #[wasm_bindgen]
10334    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10335    pub enum RoundingMode {
10336        Ceil = "ceil",
10337        Floor = "floor",
10338        Expand = "expand",
10339        Trunc = "trunc",
10340        HalfCeil = "halfCeil",
10341        HalfFloor = "halfFloor",
10342        HalfExpand = "halfExpand",
10343        HalfTrunc = "halfTrunc",
10344        HalfEven = "halfEven",
10345    }
10346
10347    /// Rounding priority for `Intl.NumberFormat`.
10348    #[wasm_bindgen]
10349    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10350    pub enum RoundingPriority {
10351        Auto = "auto",
10352        MorePrecision = "morePrecision",
10353        LessPrecision = "lessPrecision",
10354    }
10355
10356    /// Trailing zero display for `Intl.NumberFormat`.
10357    #[wasm_bindgen]
10358    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10359    pub enum TrailingZeroDisplay {
10360        Auto = "auto",
10361        StripIfInteger = "stripIfInteger",
10362    }
10363
10364    /// Use grouping option for `Intl.NumberFormat`.
10365    ///
10366    /// Determines whether to use grouping separators, such as thousands
10367    /// separators or thousand/lakh/crore separators.
10368    ///
10369    /// The default is `Min2` if notation is "compact", and `Auto` otherwise.
10370    ///
10371    /// Note: The string values `"true"` and `"false"` are accepted by JavaScript
10372    /// but are always converted to the default value. Use `True` and `False`
10373    /// variants for the boolean behavior.
10374    ///
10375    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#usegrouping)
10376    #[wasm_bindgen]
10377    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10378    pub enum UseGrouping {
10379        /// Display grouping separators even if the locale prefers otherwise.
10380        Always = "always",
10381        /// Display grouping separators based on the locale preference,
10382        /// which may also be dependent on the currency.
10383        Auto = "auto",
10384        /// Display grouping separators when there are at least 2 digits in a group.
10385        Min2 = "min2",
10386        /// Same as `Always`. Display grouping separators even if the locale prefers otherwise.
10387        True = "true",
10388        /// Display no grouping separators.
10389        False = "false",
10390    }
10391
10392    /// Date/time style for `Intl.DateTimeFormat`.
10393    #[wasm_bindgen]
10394    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10395    pub enum DateTimeStyle {
10396        Full = "full",
10397        Long = "long",
10398        Medium = "medium",
10399        Short = "short",
10400    }
10401
10402    /// Hour cycle for `Intl.DateTimeFormat`.
10403    #[wasm_bindgen]
10404    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10405    pub enum HourCycle {
10406        H11 = "h11",
10407        H12 = "h12",
10408        H23 = "h23",
10409        H24 = "h24",
10410    }
10411
10412    /// Weekday format for `Intl.DateTimeFormat`.
10413    #[wasm_bindgen]
10414    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10415    pub enum WeekdayFormat {
10416        Narrow = "narrow",
10417        Short = "short",
10418        Long = "long",
10419    }
10420
10421    /// Era format for `Intl.DateTimeFormat`.
10422    #[wasm_bindgen]
10423    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10424    pub enum EraFormat {
10425        Narrow = "narrow",
10426        Short = "short",
10427        Long = "long",
10428    }
10429
10430    /// Year format for `Intl.DateTimeFormat`.
10431    #[wasm_bindgen]
10432    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10433    pub enum YearFormat {
10434        Numeric = "numeric",
10435        TwoDigit = "2-digit",
10436    }
10437
10438    /// Month format for `Intl.DateTimeFormat`.
10439    #[wasm_bindgen]
10440    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10441    pub enum MonthFormat {
10442        #[wasm_bindgen]
10443        Numeric = "numeric",
10444        #[wasm_bindgen]
10445        TwoDigit = "2-digit",
10446        #[wasm_bindgen]
10447        Narrow = "narrow",
10448        #[wasm_bindgen]
10449        Short = "short",
10450        #[wasm_bindgen]
10451        Long = "long",
10452    }
10453
10454    /// Day format for `Intl.DateTimeFormat`.
10455    #[wasm_bindgen]
10456    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10457    pub enum DayFormat {
10458        #[wasm_bindgen]
10459        Numeric = "numeric",
10460        #[wasm_bindgen]
10461        TwoDigit = "2-digit",
10462    }
10463
10464    /// Hour/minute/second format for `Intl.DateTimeFormat`.
10465    #[wasm_bindgen]
10466    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10467    pub enum NumericFormat {
10468        #[wasm_bindgen]
10469        Numeric = "numeric",
10470        #[wasm_bindgen]
10471        TwoDigit = "2-digit",
10472    }
10473
10474    /// Time zone name format for `Intl.DateTimeFormat`.
10475    #[wasm_bindgen]
10476    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10477    pub enum TimeZoneNameFormat {
10478        Short = "short",
10479        Long = "long",
10480        ShortOffset = "shortOffset",
10481        LongOffset = "longOffset",
10482        ShortGeneric = "shortGeneric",
10483        LongGeneric = "longGeneric",
10484    }
10485
10486    /// Day period format for `Intl.DateTimeFormat`.
10487    #[wasm_bindgen]
10488    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10489    pub enum DayPeriodFormat {
10490        Narrow = "narrow",
10491        Short = "short",
10492        Long = "long",
10493    }
10494
10495    /// Part type for `DateTimeFormat.formatToParts()`.
10496    #[wasm_bindgen]
10497    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10498    pub enum DateTimeFormatPartType {
10499        Day = "day",
10500        DayPeriod = "dayPeriod",
10501        Era = "era",
10502        FractionalSecond = "fractionalSecond",
10503        Hour = "hour",
10504        Literal = "literal",
10505        Minute = "minute",
10506        Month = "month",
10507        RelatedYear = "relatedYear",
10508        Second = "second",
10509        TimeZoneName = "timeZoneName",
10510        Weekday = "weekday",
10511        Year = "year",
10512        YearName = "yearName",
10513    }
10514
10515    /// Part type for `NumberFormat.formatToParts()`.
10516    #[wasm_bindgen]
10517    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10518    pub enum NumberFormatPartType {
10519        Compact = "compact",
10520        Currency = "currency",
10521        Decimal = "decimal",
10522        ExponentInteger = "exponentInteger",
10523        ExponentMinusSign = "exponentMinusSign",
10524        ExponentSeparator = "exponentSeparator",
10525        Fraction = "fraction",
10526        Group = "group",
10527        Infinity = "infinity",
10528        Integer = "integer",
10529        Literal = "literal",
10530        MinusSign = "minusSign",
10531        Nan = "nan",
10532        PercentSign = "percentSign",
10533        PlusSign = "plusSign",
10534        Unit = "unit",
10535        Unknown = "unknown",
10536    }
10537
10538    /// Type for `Intl.PluralRules` (cardinal or ordinal).
10539    #[wasm_bindgen]
10540    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10541    pub enum PluralRulesType {
10542        Cardinal = "cardinal",
10543        Ordinal = "ordinal",
10544    }
10545
10546    /// Plural category returned by `PluralRules.select()`.
10547    #[wasm_bindgen]
10548    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10549    pub enum PluralCategory {
10550        Zero = "zero",
10551        One = "one",
10552        Two = "two",
10553        Few = "few",
10554        Many = "many",
10555        Other = "other",
10556    }
10557
10558    /// Numeric option for `Intl.RelativeTimeFormat`.
10559    #[wasm_bindgen]
10560    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10561    pub enum RelativeTimeFormatNumeric {
10562        Always = "always",
10563        Auto = "auto",
10564    }
10565
10566    /// Style for `Intl.RelativeTimeFormat`.
10567    #[wasm_bindgen]
10568    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10569    pub enum RelativeTimeFormatStyle {
10570        Long = "long",
10571        Short = "short",
10572        Narrow = "narrow",
10573    }
10574
10575    /// Unit for `RelativeTimeFormat.format()`.
10576    #[wasm_bindgen]
10577    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10578    pub enum RelativeTimeFormatUnit {
10579        Year = "year",
10580        Years = "years",
10581        Quarter = "quarter",
10582        Quarters = "quarters",
10583        Month = "month",
10584        Months = "months",
10585        Week = "week",
10586        Weeks = "weeks",
10587        Day = "day",
10588        Days = "days",
10589        Hour = "hour",
10590        Hours = "hours",
10591        Minute = "minute",
10592        Minutes = "minutes",
10593        Second = "second",
10594        Seconds = "seconds",
10595    }
10596
10597    /// Part type for `RelativeTimeFormat.formatToParts()`.
10598    #[wasm_bindgen]
10599    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10600    pub enum RelativeTimeFormatPartType {
10601        Literal = "literal",
10602        Integer = "integer",
10603        Decimal = "decimal",
10604        Fraction = "fraction",
10605    }
10606
10607    /// Source indicator for range format parts.
10608    ///
10609    /// Indicates which part of the range (start, end, or shared) a formatted
10610    /// part belongs to when using `formatRangeToParts()`.
10611    ///
10612    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/formatRangeToParts#description)
10613    #[wasm_bindgen]
10614    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10615    pub enum RangeSource {
10616        /// The part is from the start of the range.
10617        StartRange = "startRange",
10618        /// The part is from the end of the range.
10619        EndRange = "endRange",
10620        /// The part is shared between start and end (e.g., a separator or common element).
10621        Shared = "shared",
10622    }
10623
10624    /// Type for `Intl.ListFormat`.
10625    #[wasm_bindgen]
10626    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10627    pub enum ListFormatType {
10628        /// For lists of standalone items (default).
10629        Conjunction = "conjunction",
10630        /// For lists representing alternatives.
10631        Disjunction = "disjunction",
10632        /// For lists of values with units.
10633        Unit = "unit",
10634    }
10635
10636    /// Style for `Intl.ListFormat`.
10637    #[wasm_bindgen]
10638    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10639    pub enum ListFormatStyle {
10640        /// "A, B, and C" (default).
10641        Long = "long",
10642        /// "A, B, C".
10643        Short = "short",
10644        /// "A B C".
10645        Narrow = "narrow",
10646    }
10647
10648    /// Part type for `Intl.ListFormat.formatToParts()`.
10649    #[wasm_bindgen]
10650    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10651    pub enum ListFormatPartType {
10652        /// A value from the list.
10653        Element = "element",
10654        /// A linguistic construct (e.g., ", ", " and ").
10655        Literal = "literal",
10656    }
10657
10658    /// Type for `Intl.Segmenter`.
10659    #[wasm_bindgen]
10660    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10661    pub enum SegmenterGranularity {
10662        /// Segment by grapheme clusters (user-perceived characters).
10663        Grapheme = "grapheme",
10664        /// Segment by words.
10665        Word = "word",
10666        /// Segment by sentences.
10667        Sentence = "sentence",
10668    }
10669
10670    /// Type for `Intl.DisplayNames`.
10671    #[wasm_bindgen]
10672    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10673    pub enum DisplayNamesType {
10674        /// Language display names.
10675        Language = "language",
10676        /// Region display names.
10677        Region = "region",
10678        /// Script display names.
10679        Script = "script",
10680        /// Currency display names.
10681        Currency = "currency",
10682        /// Calendar display names.
10683        Calendar = "calendar",
10684        /// Date/time field display names.
10685        DateTimeField = "dateTimeField",
10686    }
10687
10688    /// Style for `Intl.DisplayNames`.
10689    #[wasm_bindgen]
10690    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10691    pub enum DisplayNamesStyle {
10692        /// Full display name (default).
10693        Long = "long",
10694        /// Abbreviated display name.
10695        Short = "short",
10696        /// Minimal display name.
10697        Narrow = "narrow",
10698    }
10699
10700    /// Fallback for `Intl.DisplayNames`.
10701    #[wasm_bindgen]
10702    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10703    pub enum DisplayNamesFallback {
10704        /// Return the input code if no display name is available (default).
10705        Code = "code",
10706        /// Return undefined if no display name is available.
10707        None = "none",
10708    }
10709
10710    /// Language display for `Intl.DisplayNames`.
10711    #[wasm_bindgen]
10712    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10713    pub enum DisplayNamesLanguageDisplay {
10714        /// Use dialect names (e.g., "British English").
10715        Dialect = "dialect",
10716        /// Use standard names (e.g., "English (United Kingdom)").
10717        Standard = "standard",
10718    }
10719
10720    // Intl.RelativeTimeFormatOptions
10721    #[wasm_bindgen]
10722    extern "C" {
10723        /// Options for `Intl.RelativeTimeFormat` constructor.
10724        ///
10725        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/RelativeTimeFormat#options)
10726        #[wasm_bindgen(extends = Object)]
10727        #[derive(Clone, Debug)]
10728        pub type RelativeTimeFormatOptions;
10729
10730        #[wasm_bindgen(method, getter = localeMatcher)]
10731        pub fn get_locale_matcher(this: &RelativeTimeFormatOptions) -> Option<LocaleMatcher>;
10732        #[wasm_bindgen(method, setter = localeMatcher)]
10733        pub fn set_locale_matcher(this: &RelativeTimeFormatOptions, value: LocaleMatcher);
10734
10735        #[wasm_bindgen(method, getter = numeric)]
10736        pub fn get_numeric(this: &RelativeTimeFormatOptions) -> Option<RelativeTimeFormatNumeric>;
10737        #[wasm_bindgen(method, setter = numeric)]
10738        pub fn set_numeric(this: &RelativeTimeFormatOptions, value: RelativeTimeFormatNumeric);
10739
10740        #[wasm_bindgen(method, getter = style)]
10741        pub fn get_style(this: &RelativeTimeFormatOptions) -> Option<RelativeTimeFormatStyle>;
10742        #[wasm_bindgen(method, setter = style)]
10743        pub fn set_style(this: &RelativeTimeFormatOptions, value: RelativeTimeFormatStyle);
10744    }
10745
10746    impl RelativeTimeFormatOptions {
10747        pub fn new() -> RelativeTimeFormatOptions {
10748            JsCast::unchecked_into(Object::new())
10749        }
10750    }
10751
10752    impl Default for RelativeTimeFormatOptions {
10753        fn default() -> Self {
10754            RelativeTimeFormatOptions::new()
10755        }
10756    }
10757
10758    // Intl.ResolvedRelativeTimeFormatOptions
10759    #[wasm_bindgen]
10760    extern "C" {
10761        /// Resolved options returned by `Intl.RelativeTimeFormat.prototype.resolvedOptions()`.
10762        ///
10763        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/resolvedOptions)
10764        #[wasm_bindgen(extends = RelativeTimeFormatOptions)]
10765        #[derive(Clone, Debug)]
10766        pub type ResolvedRelativeTimeFormatOptions;
10767
10768        /// The resolved locale string.
10769        #[wasm_bindgen(method, getter = locale)]
10770        pub fn get_locale(this: &ResolvedRelativeTimeFormatOptions) -> JsString;
10771
10772        /// The numbering system used.
10773        #[wasm_bindgen(method, getter = numberingSystem)]
10774        pub fn get_numbering_system(this: &ResolvedRelativeTimeFormatOptions) -> JsString;
10775    }
10776
10777    // Intl.RelativeTimeFormatPart
10778    #[wasm_bindgen]
10779    extern "C" {
10780        /// A part of the formatted relative time returned by `formatToParts()`.
10781        ///
10782        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/formatToParts)
10783        #[wasm_bindgen(extends = Object)]
10784        #[derive(Clone, Debug)]
10785        pub type RelativeTimeFormatPart;
10786
10787        /// The type of this part.
10788        #[wasm_bindgen(method, getter = type)]
10789        pub fn type_(this: &RelativeTimeFormatPart) -> RelativeTimeFormatPartType;
10790
10791        /// The string value of this part.
10792        #[wasm_bindgen(method, getter = value)]
10793        pub fn value(this: &RelativeTimeFormatPart) -> JsString;
10794
10795        /// The unit used in this part (only for integer parts).
10796        #[wasm_bindgen(method, getter = unit)]
10797        pub fn unit(this: &RelativeTimeFormatPart) -> Option<JsString>;
10798    }
10799
10800    // Intl.LocaleMatcherOptions
10801    #[wasm_bindgen]
10802    extern "C" {
10803        /// Options for `supportedLocalesOf` methods.
10804        #[wasm_bindgen(extends = Object)]
10805        #[derive(Clone, Debug)]
10806        pub type LocaleMatcherOptions;
10807
10808        #[wasm_bindgen(method, getter = localeMatcher)]
10809        pub fn get_locale_matcher(this: &LocaleMatcherOptions) -> Option<LocaleMatcher>;
10810
10811        #[wasm_bindgen(method, setter = localeMatcher)]
10812        pub fn set_locale_matcher(this: &LocaleMatcherOptions, value: LocaleMatcher);
10813    }
10814
10815    impl LocaleMatcherOptions {
10816        pub fn new() -> LocaleMatcherOptions {
10817            JsCast::unchecked_into(Object::new())
10818        }
10819    }
10820
10821    impl Default for LocaleMatcherOptions {
10822        fn default() -> Self {
10823            LocaleMatcherOptions::new()
10824        }
10825    }
10826
10827    // Intl.Collator Options
10828    #[wasm_bindgen]
10829    extern "C" {
10830        /// Options for `Intl.Collator` and `String.prototype.localeCompare`.
10831        ///
10832        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Collator/Collator#options)
10833        #[wasm_bindgen(extends = Object)]
10834        #[derive(Clone, Debug)]
10835        pub type CollatorOptions;
10836
10837        #[wasm_bindgen(method, getter = localeMatcher)]
10838        pub fn get_locale_matcher(this: &CollatorOptions) -> Option<LocaleMatcher>;
10839        #[wasm_bindgen(method, setter = localeMatcher)]
10840        pub fn set_locale_matcher(this: &CollatorOptions, value: LocaleMatcher);
10841
10842        #[wasm_bindgen(method, getter = usage)]
10843        pub fn get_usage(this: &CollatorOptions) -> Option<CollatorUsage>;
10844        #[wasm_bindgen(method, setter = usage)]
10845        pub fn set_usage(this: &CollatorOptions, value: CollatorUsage);
10846
10847        #[wasm_bindgen(method, getter = sensitivity)]
10848        pub fn get_sensitivity(this: &CollatorOptions) -> Option<CollatorSensitivity>;
10849        #[wasm_bindgen(method, setter = sensitivity)]
10850        pub fn set_sensitivity(this: &CollatorOptions, value: CollatorSensitivity);
10851
10852        #[wasm_bindgen(method, getter = ignorePunctuation)]
10853        pub fn get_ignore_punctuation(this: &CollatorOptions) -> Option<bool>;
10854        #[wasm_bindgen(method, setter = ignorePunctuation)]
10855        pub fn set_ignore_punctuation(this: &CollatorOptions, value: bool);
10856
10857        #[wasm_bindgen(method, getter = numeric)]
10858        pub fn get_numeric(this: &CollatorOptions) -> Option<bool>;
10859        #[wasm_bindgen(method, setter = numeric)]
10860        pub fn set_numeric(this: &CollatorOptions, value: bool);
10861
10862        #[wasm_bindgen(method, getter = caseFirst)]
10863        pub fn get_case_first(this: &CollatorOptions) -> Option<CollatorCaseFirst>;
10864        #[wasm_bindgen(method, setter = caseFirst)]
10865        pub fn set_case_first(this: &CollatorOptions, value: CollatorCaseFirst);
10866    }
10867    impl CollatorOptions {
10868        pub fn new() -> CollatorOptions {
10869            JsCast::unchecked_into(Object::new())
10870        }
10871    }
10872    impl Default for CollatorOptions {
10873        fn default() -> Self {
10874            CollatorOptions::new()
10875        }
10876    }
10877
10878    // Intl.Collator ResolvedCollatorOptions
10879    #[wasm_bindgen]
10880    extern "C" {
10881        #[wasm_bindgen(extends = CollatorOptions)]
10882        #[derive(Clone, Debug)]
10883        pub type ResolvedCollatorOptions;
10884
10885        #[wasm_bindgen(method, getter = locale)]
10886        pub fn get_locale(this: &ResolvedCollatorOptions) -> JsString; // not Option, always present
10887        #[wasm_bindgen(method, getter = collation)]
10888        pub fn get_collation(this: &ResolvedCollatorOptions) -> JsString;
10889    }
10890
10891    // Intl.Collator
10892    #[wasm_bindgen]
10893    extern "C" {
10894        /// The `Intl.Collator` object is a constructor for collators, objects
10895        /// that enable language sensitive string comparison.
10896        ///
10897        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator)
10898        #[wasm_bindgen(extends = Object, js_namespace = Intl, typescript_type = "Intl.Collator")]
10899        #[derive(Clone, Debug)]
10900        pub type Collator;
10901
10902        /// The `Intl.Collator` object is a constructor for collators, objects
10903        /// that enable language sensitive string comparison.
10904        ///
10905        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator)
10906        #[cfg(not(js_sys_unstable_apis))]
10907        #[wasm_bindgen(constructor, js_namespace = Intl)]
10908        pub fn new(locales: &Array, options: &Object) -> Collator;
10909
10910        /// The `Intl.Collator` object is a constructor for collators, objects
10911        /// that enable language sensitive string comparison.
10912        ///
10913        /// Throws a `RangeError` if locales contain invalid values.
10914        ///
10915        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator)
10916        #[cfg(js_sys_unstable_apis)]
10917        #[wasm_bindgen(constructor, js_namespace = Intl, catch)]
10918        pub fn new(locales: &[JsString], options: &CollatorOptions) -> Result<Collator, JsValue>;
10919
10920        /// The Intl.Collator.prototype.compare property returns a function that
10921        /// compares two strings according to the sort order of this Collator
10922        /// object.
10923        ///
10924        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator/compare)
10925        #[cfg(not(js_sys_unstable_apis))]
10926        #[wasm_bindgen(method, getter, js_class = "Intl.Collator")]
10927        pub fn compare(this: &Collator) -> Function;
10928
10929        /// Compares two strings according to the sort order of this Collator.
10930        ///
10931        /// Returns a negative value if `a` comes before `b`, positive if `a` comes
10932        /// after `b`, and zero if they are equal.
10933        ///
10934        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Collator/compare)
10935        #[cfg(js_sys_unstable_apis)]
10936        #[wasm_bindgen(method, js_class = "Intl.Collator")]
10937        pub fn compare(this: &Collator, a: &str, b: &str) -> i32;
10938
10939        /// The `Intl.Collator.prototype.resolvedOptions()` method returns a new
10940        /// object with properties reflecting the locale and collation options
10941        /// computed during initialization of this Collator object.
10942        ///
10943        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator/resolvedOptions)
10944        #[cfg(not(js_sys_unstable_apis))]
10945        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
10946        pub fn resolved_options(this: &Collator) -> Object;
10947
10948        /// The `Intl.Collator.prototype.resolvedOptions()` method returns a new
10949        /// object with properties reflecting the locale and collation options
10950        /// computed during initialization of this Collator object.
10951        ///
10952        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator/resolvedOptions)
10953        #[cfg(js_sys_unstable_apis)]
10954        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
10955        pub fn resolved_options(this: &Collator) -> ResolvedCollatorOptions;
10956
10957        /// The `Intl.Collator.supportedLocalesOf()` method returns an array
10958        /// containing those of the provided locales that are supported in
10959        /// collation without having to fall back to the runtime's default
10960        /// locale.
10961        ///
10962        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator/supportedLocalesOf)
10963        #[cfg(not(js_sys_unstable_apis))]
10964        #[wasm_bindgen(static_method_of = Collator, js_namespace = Intl, js_name = supportedLocalesOf)]
10965        pub fn supported_locales_of(locales: &Array, options: &Object) -> Array;
10966
10967        /// The `Intl.Collator.supportedLocalesOf()` method returns an array
10968        /// containing those of the provided locales that are supported in
10969        /// collation without having to fall back to the runtime's default
10970        /// locale.
10971        ///
10972        /// Throws a `RangeError` if locales contain invalid values.
10973        ///
10974        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator/supportedLocalesOf)
10975        #[cfg(js_sys_unstable_apis)]
10976        #[wasm_bindgen(static_method_of = Collator, js_namespace = Intl, js_name = supportedLocalesOf, catch)]
10977        pub fn supported_locales_of(
10978            locales: &[JsString],
10979            options: &LocaleMatcherOptions,
10980        ) -> Result<Array<JsString>, JsValue>;
10981    }
10982
10983    #[cfg(not(js_sys_unstable_apis))]
10984    impl Default for Collator {
10985        fn default() -> Self {
10986            Self::new(
10987                &JsValue::UNDEFINED.unchecked_into(),
10988                &JsValue::UNDEFINED.unchecked_into(),
10989            )
10990        }
10991    }
10992
10993    #[cfg(js_sys_unstable_apis)]
10994    impl Default for Collator {
10995        fn default() -> Self {
10996            Self::new(&[], &Default::default()).unwrap()
10997        }
10998    }
10999
11000    // Intl.DateTimeFormatOptions
11001    #[wasm_bindgen]
11002    extern "C" {
11003        /// Options for `Intl.DateTimeFormat` constructor.
11004        ///
11005        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat#options)
11006        #[wasm_bindgen(extends = Object)]
11007        #[derive(Clone, Debug)]
11008        pub type DateTimeFormatOptions;
11009
11010        // Locale matching
11011        #[wasm_bindgen(method, getter = localeMatcher)]
11012        pub fn get_locale_matcher(this: &DateTimeFormatOptions) -> Option<LocaleMatcher>;
11013        #[wasm_bindgen(method, setter = localeMatcher)]
11014        pub fn set_locale_matcher(this: &DateTimeFormatOptions, value: LocaleMatcher);
11015
11016        // Calendar/numbering (free-form strings, no enum)
11017        #[wasm_bindgen(method, getter = calendar)]
11018        pub fn get_calendar(this: &DateTimeFormatOptions) -> Option<JsString>;
11019        #[wasm_bindgen(method, setter = calendar)]
11020        pub fn set_calendar(this: &DateTimeFormatOptions, value: &str);
11021
11022        #[wasm_bindgen(method, getter = numberingSystem)]
11023        pub fn get_numbering_system(this: &DateTimeFormatOptions) -> Option<JsString>;
11024        #[wasm_bindgen(method, setter = numberingSystem)]
11025        pub fn set_numbering_system(this: &DateTimeFormatOptions, value: &str);
11026
11027        // Timezone (free-form string)
11028        #[wasm_bindgen(method, getter = timeZone)]
11029        pub fn get_time_zone(this: &DateTimeFormatOptions) -> Option<JsString>;
11030        #[wasm_bindgen(method, setter = timeZone)]
11031        pub fn set_time_zone(this: &DateTimeFormatOptions, value: &str);
11032
11033        // Hour cycle
11034        #[wasm_bindgen(method, getter = hour12)]
11035        pub fn get_hour12(this: &DateTimeFormatOptions) -> Option<bool>;
11036        #[wasm_bindgen(method, setter = hour12)]
11037        pub fn set_hour12(this: &DateTimeFormatOptions, value: bool);
11038
11039        #[wasm_bindgen(method, getter = hourCycle)]
11040        pub fn get_hour_cycle(this: &DateTimeFormatOptions) -> Option<HourCycle>;
11041        #[wasm_bindgen(method, setter = hourCycle)]
11042        pub fn set_hour_cycle(this: &DateTimeFormatOptions, value: HourCycle);
11043
11044        // Style shortcuts
11045        #[wasm_bindgen(method, getter = dateStyle)]
11046        pub fn get_date_style(this: &DateTimeFormatOptions) -> Option<DateTimeStyle>;
11047        #[wasm_bindgen(method, setter = dateStyle)]
11048        pub fn set_date_style(this: &DateTimeFormatOptions, value: DateTimeStyle);
11049
11050        #[wasm_bindgen(method, getter = timeStyle)]
11051        pub fn get_time_style(this: &DateTimeFormatOptions) -> Option<DateTimeStyle>;
11052        #[wasm_bindgen(method, setter = timeStyle)]
11053        pub fn set_time_style(this: &DateTimeFormatOptions, value: DateTimeStyle);
11054
11055        // Component options
11056        #[wasm_bindgen(method, getter = weekday)]
11057        pub fn get_weekday(this: &DateTimeFormatOptions) -> Option<WeekdayFormat>;
11058        #[wasm_bindgen(method, setter = weekday)]
11059        pub fn set_weekday(this: &DateTimeFormatOptions, value: WeekdayFormat);
11060
11061        #[wasm_bindgen(method, getter = era)]
11062        pub fn get_era(this: &DateTimeFormatOptions) -> Option<EraFormat>;
11063        #[wasm_bindgen(method, setter = era)]
11064        pub fn set_era(this: &DateTimeFormatOptions, value: EraFormat);
11065
11066        #[wasm_bindgen(method, getter = year)]
11067        pub fn get_year(this: &DateTimeFormatOptions) -> Option<YearFormat>;
11068        #[wasm_bindgen(method, setter = year)]
11069        pub fn set_year(this: &DateTimeFormatOptions, value: YearFormat);
11070
11071        #[wasm_bindgen(method, getter = month)]
11072        pub fn get_month(this: &DateTimeFormatOptions) -> Option<MonthFormat>;
11073        #[wasm_bindgen(method, setter = month)]
11074        pub fn set_month(this: &DateTimeFormatOptions, value: MonthFormat);
11075
11076        #[wasm_bindgen(method, getter = day)]
11077        pub fn get_day(this: &DateTimeFormatOptions) -> Option<DayFormat>;
11078        #[wasm_bindgen(method, setter = day)]
11079        pub fn set_day(this: &DateTimeFormatOptions, value: DayFormat);
11080
11081        #[wasm_bindgen(method, getter = hour)]
11082        pub fn get_hour(this: &DateTimeFormatOptions) -> Option<NumericFormat>;
11083        #[wasm_bindgen(method, setter = hour)]
11084        pub fn set_hour(this: &DateTimeFormatOptions, value: NumericFormat);
11085
11086        #[wasm_bindgen(method, getter = minute)]
11087        pub fn get_minute(this: &DateTimeFormatOptions) -> Option<NumericFormat>;
11088        #[wasm_bindgen(method, setter = minute)]
11089        pub fn set_minute(this: &DateTimeFormatOptions, value: NumericFormat);
11090
11091        #[wasm_bindgen(method, getter = second)]
11092        pub fn get_second(this: &DateTimeFormatOptions) -> Option<NumericFormat>;
11093        #[wasm_bindgen(method, setter = second)]
11094        pub fn set_second(this: &DateTimeFormatOptions, value: NumericFormat);
11095
11096        #[wasm_bindgen(method, getter = fractionalSecondDigits)]
11097        pub fn get_fractional_second_digits(this: &DateTimeFormatOptions) -> Option<u8>;
11098        #[wasm_bindgen(method, setter = fractionalSecondDigits)]
11099        pub fn set_fractional_second_digits(this: &DateTimeFormatOptions, value: u8);
11100
11101        #[wasm_bindgen(method, getter = timeZoneName)]
11102        pub fn get_time_zone_name(this: &DateTimeFormatOptions) -> Option<TimeZoneNameFormat>;
11103        #[wasm_bindgen(method, setter = timeZoneName)]
11104        pub fn set_time_zone_name(this: &DateTimeFormatOptions, value: TimeZoneNameFormat);
11105
11106        #[wasm_bindgen(method, getter = dayPeriod)]
11107        pub fn get_day_period(this: &DateTimeFormatOptions) -> Option<DayPeriodFormat>;
11108        #[wasm_bindgen(method, setter = dayPeriod)]
11109        pub fn set_day_period(this: &DateTimeFormatOptions, value: DayPeriodFormat);
11110    }
11111
11112    impl DateTimeFormatOptions {
11113        pub fn new() -> DateTimeFormatOptions {
11114            JsCast::unchecked_into(Object::new())
11115        }
11116    }
11117
11118    impl Default for DateTimeFormatOptions {
11119        fn default() -> Self {
11120            DateTimeFormatOptions::new()
11121        }
11122    }
11123
11124    // Intl.ResolvedDateTimeFormatOptions
11125    #[wasm_bindgen]
11126    extern "C" {
11127        /// Resolved options returned by `Intl.DateTimeFormat.prototype.resolvedOptions()`.
11128        ///
11129        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/resolvedOptions)
11130        #[wasm_bindgen(extends = DateTimeFormatOptions)]
11131        #[derive(Clone, Debug)]
11132        pub type ResolvedDateTimeFormatOptions;
11133
11134        /// The resolved locale string.
11135        #[wasm_bindgen(method, getter = locale)]
11136        pub fn get_locale(this: &ResolvedDateTimeFormatOptions) -> JsString;
11137    }
11138
11139    // Intl.DateTimeFormatPart
11140    #[wasm_bindgen]
11141    extern "C" {
11142        /// A part of the formatted date returned by `formatToParts()`.
11143        ///
11144        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/formatToParts)
11145        #[wasm_bindgen(extends = Object)]
11146        #[derive(Clone, Debug)]
11147        pub type DateTimeFormatPart;
11148
11149        /// The type of the part (e.g., "day", "month", "year", "literal", etc.)
11150        #[wasm_bindgen(method, getter = type)]
11151        pub fn type_(this: &DateTimeFormatPart) -> DateTimeFormatPartType;
11152
11153        /// The value of the part.
11154        #[wasm_bindgen(method, getter)]
11155        pub fn value(this: &DateTimeFormatPart) -> JsString;
11156    }
11157
11158    // Intl.DateTimeRangeFormatPart
11159    #[wasm_bindgen]
11160    extern "C" {
11161        /// A part of the formatted date range returned by `formatRangeToParts()`.
11162        ///
11163        /// Extends `DateTimeFormatPart` with a `source` property indicating whether
11164        /// the part is from the start date, end date, or shared between them.
11165        ///
11166        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/formatRangeToParts)
11167        #[wasm_bindgen(extends = DateTimeFormatPart)]
11168        #[derive(Clone, Debug)]
11169        pub type DateTimeRangeFormatPart;
11170
11171        /// The source of the part: "startRange", "endRange", or "shared".
11172        #[wasm_bindgen(method, getter)]
11173        pub fn source(this: &DateTimeRangeFormatPart) -> RangeSource;
11174    }
11175
11176    // Intl.DateTimeFormat
11177    #[wasm_bindgen]
11178    extern "C" {
11179        /// The `Intl.DateTimeFormat` object is a constructor for objects
11180        /// that enable language-sensitive date and time formatting.
11181        ///
11182        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat)
11183        #[wasm_bindgen(extends = Object, js_namespace = Intl, typescript_type = "Intl.DateTimeFormat")]
11184        #[derive(Clone, Debug)]
11185        pub type DateTimeFormat;
11186
11187        /// The `Intl.DateTimeFormat` object is a constructor for objects
11188        /// that enable language-sensitive date and time formatting.
11189        ///
11190        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat)
11191        #[cfg(not(js_sys_unstable_apis))]
11192        #[wasm_bindgen(constructor, js_namespace = Intl)]
11193        pub fn new(locales: &Array, options: &Object) -> DateTimeFormat;
11194
11195        /// The `Intl.DateTimeFormat` object is a constructor for objects
11196        /// that enable language-sensitive date and time formatting.
11197        ///
11198        /// Throws a `RangeError` if locales contain invalid values.
11199        ///
11200        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat)
11201        #[cfg(js_sys_unstable_apis)]
11202        #[wasm_bindgen(constructor, js_namespace = Intl, catch)]
11203        pub fn new(
11204            locales: &[JsString],
11205            options: &DateTimeFormatOptions,
11206        ) -> Result<DateTimeFormat, JsValue>;
11207
11208        /// The Intl.DateTimeFormat.prototype.format property returns a getter function that
11209        /// formats a date according to the locale and formatting options of this
11210        /// Intl.DateTimeFormat object.
11211        ///
11212        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/format)
11213        #[cfg(not(js_sys_unstable_apis))]
11214        #[wasm_bindgen(method, getter, js_class = "Intl.DateTimeFormat")]
11215        pub fn format(this: &DateTimeFormat) -> Function;
11216
11217        /// Formats a date according to the locale and formatting options of this
11218        /// `Intl.DateTimeFormat` object.
11219        ///
11220        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/format)
11221        #[cfg(js_sys_unstable_apis)]
11222        #[wasm_bindgen(method, js_class = "Intl.DateTimeFormat")]
11223        pub fn format(this: &DateTimeFormat, date: &Date) -> JsString;
11224
11225        /// The `Intl.DateTimeFormat.prototype.formatToParts()` method allows locale-aware
11226        /// formatting of strings produced by DateTimeFormat formatters.
11227        ///
11228        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/formatToParts)
11229        #[cfg(not(js_sys_unstable_apis))]
11230        #[wasm_bindgen(method, js_class = "Intl.DateTimeFormat", js_name = formatToParts)]
11231        pub fn format_to_parts(this: &DateTimeFormat, date: &Date) -> Array;
11232
11233        /// The `Intl.DateTimeFormat.prototype.formatToParts()` method allows locale-aware
11234        /// formatting of strings produced by DateTimeFormat formatters.
11235        ///
11236        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/formatToParts)
11237        #[cfg(js_sys_unstable_apis)]
11238        #[wasm_bindgen(method, js_class = "Intl.DateTimeFormat", js_name = formatToParts)]
11239        pub fn format_to_parts(this: &DateTimeFormat, date: &Date) -> Array<DateTimeFormatPart>;
11240
11241        /// The `Intl.DateTimeFormat.prototype.formatRange()` method formats a date range
11242        /// in the most concise way based on the locales and options provided when
11243        /// instantiating this `Intl.DateTimeFormat` object.
11244        ///
11245        /// Throws a `TypeError` if the dates are invalid.
11246        ///
11247        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/formatRange)
11248        #[wasm_bindgen(method, js_class = "Intl.DateTimeFormat", js_name = formatRange, catch)]
11249        pub fn format_range(
11250            this: &DateTimeFormat,
11251            start_date: &Date,
11252            end_date: &Date,
11253        ) -> Result<JsString, JsValue>;
11254
11255        /// The `Intl.DateTimeFormat.prototype.formatRangeToParts()` method returns an array
11256        /// of locale-specific tokens representing each part of the formatted date range
11257        /// produced by `Intl.DateTimeFormat` formatters.
11258        ///
11259        /// Throws a `TypeError` if the dates are invalid.
11260        ///
11261        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/formatRangeToParts)
11262        #[wasm_bindgen(method, js_class = "Intl.DateTimeFormat", js_name = formatRangeToParts, catch)]
11263        pub fn format_range_to_parts(
11264            this: &DateTimeFormat,
11265            start_date: &Date,
11266            end_date: &Date,
11267        ) -> Result<Array<DateTimeRangeFormatPart>, JsValue>;
11268
11269        /// The `Intl.DateTimeFormat.prototype.resolvedOptions()` method returns a new
11270        /// object with properties reflecting the locale and date and time formatting
11271        /// options computed during initialization of this DateTimeFormat object.
11272        ///
11273        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/resolvedOptions)
11274        #[cfg(not(js_sys_unstable_apis))]
11275        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
11276        pub fn resolved_options(this: &DateTimeFormat) -> Object;
11277
11278        /// The `Intl.DateTimeFormat.prototype.resolvedOptions()` method returns a new
11279        /// object with properties reflecting the locale and date and time formatting
11280        /// options computed during initialization of this DateTimeFormat object.
11281        ///
11282        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/resolvedOptions)
11283        #[cfg(js_sys_unstable_apis)]
11284        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
11285        pub fn resolved_options(this: &DateTimeFormat) -> ResolvedDateTimeFormatOptions;
11286
11287        /// The `Intl.DateTimeFormat.supportedLocalesOf()` method returns an array
11288        /// containing those of the provided locales that are supported in date
11289        /// and time formatting without having to fall back to the runtime's default
11290        /// locale.
11291        ///
11292        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/supportedLocalesOf)
11293        #[cfg(not(js_sys_unstable_apis))]
11294        #[wasm_bindgen(static_method_of = DateTimeFormat, js_namespace = Intl, js_name = supportedLocalesOf)]
11295        pub fn supported_locales_of(locales: &Array, options: &Object) -> Array;
11296
11297        /// The `Intl.DateTimeFormat.supportedLocalesOf()` method returns an array
11298        /// containing those of the provided locales that are supported in date
11299        /// and time formatting without having to fall back to the runtime's default
11300        /// locale.
11301        ///
11302        /// Throws a `RangeError` if locales contain invalid values.
11303        ///
11304        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/supportedLocalesOf)
11305        #[cfg(js_sys_unstable_apis)]
11306        #[wasm_bindgen(static_method_of = DateTimeFormat, js_namespace = Intl, js_name = supportedLocalesOf, catch)]
11307        pub fn supported_locales_of(
11308            locales: &[JsString],
11309            options: &LocaleMatcherOptions,
11310        ) -> Result<Array<JsString>, JsValue>;
11311    }
11312
11313    #[cfg(not(js_sys_unstable_apis))]
11314    impl Default for DateTimeFormat {
11315        fn default() -> Self {
11316            Self::new(
11317                &JsValue::UNDEFINED.unchecked_into(),
11318                &JsValue::UNDEFINED.unchecked_into(),
11319            )
11320        }
11321    }
11322
11323    #[cfg(js_sys_unstable_apis)]
11324    impl Default for DateTimeFormat {
11325        fn default() -> Self {
11326            Self::new(&[], &Default::default()).unwrap()
11327        }
11328    }
11329
11330    // Intl.NumberFormatOptions
11331    #[wasm_bindgen]
11332    extern "C" {
11333        /// Options for `Intl.NumberFormat` constructor.
11334        ///
11335        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#options)
11336        #[wasm_bindgen(extends = Object)]
11337        #[derive(Clone, Debug)]
11338        pub type NumberFormatOptions;
11339
11340        // Locale matching
11341        #[wasm_bindgen(method, getter = localeMatcher)]
11342        pub fn get_locale_matcher(this: &NumberFormatOptions) -> Option<LocaleMatcher>;
11343        #[wasm_bindgen(method, setter = localeMatcher)]
11344        pub fn set_locale_matcher(this: &NumberFormatOptions, value: LocaleMatcher);
11345
11346        // Numbering system (free-form string)
11347        #[wasm_bindgen(method, getter = numberingSystem)]
11348        pub fn get_numbering_system(this: &NumberFormatOptions) -> Option<JsString>;
11349        #[wasm_bindgen(method, setter = numberingSystem)]
11350        pub fn set_numbering_system(this: &NumberFormatOptions, value: &str);
11351
11352        // Style
11353        #[wasm_bindgen(method, getter = style)]
11354        pub fn get_style(this: &NumberFormatOptions) -> Option<NumberFormatStyle>;
11355        #[wasm_bindgen(method, setter = style)]
11356        pub fn set_style(this: &NumberFormatOptions, value: NumberFormatStyle);
11357
11358        // Currency options (currency code is free-form ISO 4217 string)
11359        #[wasm_bindgen(method, getter = currency)]
11360        pub fn get_currency(this: &NumberFormatOptions) -> Option<JsString>;
11361        #[wasm_bindgen(method, setter = currency)]
11362        pub fn set_currency(this: &NumberFormatOptions, value: &str);
11363
11364        #[wasm_bindgen(method, getter = currencyDisplay)]
11365        pub fn get_currency_display(this: &NumberFormatOptions) -> Option<CurrencyDisplay>;
11366        #[wasm_bindgen(method, setter = currencyDisplay)]
11367        pub fn set_currency_display(this: &NumberFormatOptions, value: CurrencyDisplay);
11368
11369        #[wasm_bindgen(method, getter = currencySign)]
11370        pub fn get_currency_sign(this: &NumberFormatOptions) -> Option<CurrencySign>;
11371        #[wasm_bindgen(method, setter = currencySign)]
11372        pub fn set_currency_sign(this: &NumberFormatOptions, value: CurrencySign);
11373
11374        // Unit options (unit name is free-form string)
11375        #[wasm_bindgen(method, getter = unit)]
11376        pub fn get_unit(this: &NumberFormatOptions) -> Option<JsString>;
11377        #[wasm_bindgen(method, setter = unit)]
11378        pub fn set_unit(this: &NumberFormatOptions, value: &str);
11379
11380        #[wasm_bindgen(method, getter = unitDisplay)]
11381        pub fn get_unit_display(this: &NumberFormatOptions) -> Option<UnitDisplay>;
11382        #[wasm_bindgen(method, setter = unitDisplay)]
11383        pub fn set_unit_display(this: &NumberFormatOptions, value: UnitDisplay);
11384
11385        // Notation
11386        #[wasm_bindgen(method, getter = notation)]
11387        pub fn get_notation(this: &NumberFormatOptions) -> Option<NumberFormatNotation>;
11388        #[wasm_bindgen(method, setter = notation)]
11389        pub fn set_notation(this: &NumberFormatOptions, value: NumberFormatNotation);
11390
11391        #[wasm_bindgen(method, getter = compactDisplay)]
11392        pub fn get_compact_display(this: &NumberFormatOptions) -> Option<CompactDisplay>;
11393        #[wasm_bindgen(method, setter = compactDisplay)]
11394        pub fn set_compact_display(this: &NumberFormatOptions, value: CompactDisplay);
11395
11396        // Sign display
11397        #[wasm_bindgen(method, getter = signDisplay)]
11398        pub fn get_sign_display(this: &NumberFormatOptions) -> Option<SignDisplay>;
11399        #[wasm_bindgen(method, setter = signDisplay)]
11400        pub fn set_sign_display(this: &NumberFormatOptions, value: SignDisplay);
11401
11402        // Digit options
11403        #[wasm_bindgen(method, getter = minimumIntegerDigits)]
11404        pub fn get_minimum_integer_digits(this: &NumberFormatOptions) -> Option<u8>;
11405        #[wasm_bindgen(method, setter = minimumIntegerDigits)]
11406        pub fn set_minimum_integer_digits(this: &NumberFormatOptions, value: u8);
11407
11408        #[wasm_bindgen(method, getter = minimumFractionDigits)]
11409        pub fn get_minimum_fraction_digits(this: &NumberFormatOptions) -> Option<u8>;
11410        #[wasm_bindgen(method, setter = minimumFractionDigits)]
11411        pub fn set_minimum_fraction_digits(this: &NumberFormatOptions, value: u8);
11412
11413        #[wasm_bindgen(method, getter = maximumFractionDigits)]
11414        pub fn get_maximum_fraction_digits(this: &NumberFormatOptions) -> Option<u8>;
11415        #[wasm_bindgen(method, setter = maximumFractionDigits)]
11416        pub fn set_maximum_fraction_digits(this: &NumberFormatOptions, value: u8);
11417
11418        #[wasm_bindgen(method, getter = minimumSignificantDigits)]
11419        pub fn get_minimum_significant_digits(this: &NumberFormatOptions) -> Option<u8>;
11420        #[wasm_bindgen(method, setter = minimumSignificantDigits)]
11421        pub fn set_minimum_significant_digits(this: &NumberFormatOptions, value: u8);
11422
11423        #[wasm_bindgen(method, getter = maximumSignificantDigits)]
11424        pub fn get_maximum_significant_digits(this: &NumberFormatOptions) -> Option<u8>;
11425        #[wasm_bindgen(method, setter = maximumSignificantDigits)]
11426        pub fn set_maximum_significant_digits(this: &NumberFormatOptions, value: u8);
11427
11428        // Grouping
11429        #[wasm_bindgen(method, getter = useGrouping)]
11430        pub fn get_use_grouping(this: &NumberFormatOptions) -> Option<UseGrouping>;
11431        #[wasm_bindgen(method, setter = useGrouping)]
11432        pub fn set_use_grouping(this: &NumberFormatOptions, value: UseGrouping);
11433
11434        // Rounding
11435        #[wasm_bindgen(method, getter = roundingMode)]
11436        pub fn get_rounding_mode(this: &NumberFormatOptions) -> Option<RoundingMode>;
11437        #[wasm_bindgen(method, setter = roundingMode)]
11438        pub fn set_rounding_mode(this: &NumberFormatOptions, value: RoundingMode);
11439
11440        #[wasm_bindgen(method, getter = roundingPriority)]
11441        pub fn get_rounding_priority(this: &NumberFormatOptions) -> Option<RoundingPriority>;
11442        #[wasm_bindgen(method, setter = roundingPriority)]
11443        pub fn set_rounding_priority(this: &NumberFormatOptions, value: RoundingPriority);
11444
11445        #[wasm_bindgen(method, getter = roundingIncrement)]
11446        pub fn get_rounding_increment(this: &NumberFormatOptions) -> Option<u32>;
11447        #[wasm_bindgen(method, setter = roundingIncrement)]
11448        pub fn set_rounding_increment(this: &NumberFormatOptions, value: u32);
11449
11450        #[wasm_bindgen(method, getter = trailingZeroDisplay)]
11451        pub fn get_trailing_zero_display(this: &NumberFormatOptions)
11452            -> Option<TrailingZeroDisplay>;
11453        #[wasm_bindgen(method, setter = trailingZeroDisplay)]
11454        pub fn set_trailing_zero_display(this: &NumberFormatOptions, value: TrailingZeroDisplay);
11455    }
11456
11457    impl NumberFormatOptions {
11458        pub fn new() -> NumberFormatOptions {
11459            JsCast::unchecked_into(Object::new())
11460        }
11461    }
11462
11463    impl Default for NumberFormatOptions {
11464        fn default() -> Self {
11465            NumberFormatOptions::new()
11466        }
11467    }
11468
11469    // Intl.ResolvedNumberFormatOptions
11470    #[wasm_bindgen]
11471    extern "C" {
11472        /// Resolved options returned by `Intl.NumberFormat.prototype.resolvedOptions()`.
11473        ///
11474        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/resolvedOptions)
11475        #[wasm_bindgen(extends = NumberFormatOptions)]
11476        #[derive(Clone, Debug)]
11477        pub type ResolvedNumberFormatOptions;
11478
11479        /// The resolved locale string.
11480        #[wasm_bindgen(method, getter = locale)]
11481        pub fn get_locale(this: &ResolvedNumberFormatOptions) -> JsString;
11482    }
11483
11484    // Intl.NumberFormatPart
11485    #[wasm_bindgen]
11486    extern "C" {
11487        /// A part of the formatted number returned by `formatToParts()`.
11488        ///
11489        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/formatToParts)
11490        #[wasm_bindgen(extends = Object)]
11491        #[derive(Clone, Debug)]
11492        pub type NumberFormatPart;
11493
11494        /// The type of the part (e.g., "integer", "decimal", "fraction", "currency", etc.)
11495        #[wasm_bindgen(method, getter = type)]
11496        pub fn type_(this: &NumberFormatPart) -> NumberFormatPartType;
11497
11498        /// The value of the part.
11499        #[wasm_bindgen(method, getter)]
11500        pub fn value(this: &NumberFormatPart) -> JsString;
11501    }
11502
11503    // Intl.NumberRangeFormatPart
11504    #[wasm_bindgen]
11505    extern "C" {
11506        /// A part of the formatted number range returned by `formatRangeToParts()`.
11507        ///
11508        /// Extends `NumberFormatPart` with a `source` property indicating whether
11509        /// the part is from the start number, end number, or shared between them.
11510        ///
11511        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/formatRangeToParts)
11512        #[wasm_bindgen(extends = NumberFormatPart)]
11513        #[derive(Clone, Debug)]
11514        pub type NumberRangeFormatPart;
11515
11516        /// The source of the part: "startRange", "endRange", or "shared".
11517        #[wasm_bindgen(method, getter)]
11518        pub fn source(this: &NumberRangeFormatPart) -> RangeSource;
11519    }
11520
11521    // Intl.NumberFormat
11522    #[wasm_bindgen]
11523    extern "C" {
11524        /// The `Intl.NumberFormat` object is a constructor for objects
11525        /// that enable language sensitive number formatting.
11526        ///
11527        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat)
11528        #[wasm_bindgen(extends = Object, js_namespace = Intl, typescript_type = "Intl.NumberFormat")]
11529        #[derive(Clone, Debug)]
11530        pub type NumberFormat;
11531
11532        /// The `Intl.NumberFormat` object is a constructor for objects
11533        /// that enable language sensitive number formatting.
11534        ///
11535        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat)
11536        #[cfg(not(js_sys_unstable_apis))]
11537        #[wasm_bindgen(constructor, js_namespace = Intl)]
11538        pub fn new(locales: &Array, options: &Object) -> NumberFormat;
11539
11540        /// The `Intl.NumberFormat` object is a constructor for objects
11541        /// that enable language sensitive number formatting.
11542        ///
11543        /// Throws a `RangeError` if locales contain invalid values.
11544        ///
11545        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat)
11546        #[cfg(js_sys_unstable_apis)]
11547        #[wasm_bindgen(constructor, js_namespace = Intl, catch)]
11548        pub fn new(
11549            locales: &[JsString],
11550            options: &NumberFormatOptions,
11551        ) -> Result<NumberFormat, JsValue>;
11552
11553        /// The Intl.NumberFormat.prototype.format property returns a getter function that
11554        /// formats a number according to the locale and formatting options of this
11555        /// NumberFormat object.
11556        ///
11557        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/format)
11558        #[cfg(not(js_sys_unstable_apis))]
11559        #[wasm_bindgen(method, getter, js_class = "Intl.NumberFormat")]
11560        pub fn format(this: &NumberFormat) -> Function;
11561
11562        /// Formats a number according to the locale and formatting options of this
11563        /// `Intl.NumberFormat` object.
11564        ///
11565        /// Accepts numeric strings for BigInt/arbitrary precision (e.g., `"123n"` → `"123"`,
11566        /// or use E notation: `"1000000E-6"` → `"1"`).
11567        ///
11568        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/format)
11569        #[cfg(js_sys_unstable_apis)]
11570        #[wasm_bindgen(method, js_class = "Intl.NumberFormat")]
11571        pub fn format(this: &NumberFormat, value: &JsString) -> JsString;
11572
11573        /// The `Intl.Numberformat.prototype.formatToParts()` method allows locale-aware
11574        /// formatting of strings produced by NumberTimeFormat formatters.
11575        ///
11576        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/formatToParts)
11577        #[cfg(not(js_sys_unstable_apis))]
11578        #[wasm_bindgen(method, js_class = "Intl.NumberFormat", js_name = formatToParts)]
11579        pub fn format_to_parts(this: &NumberFormat, number: f64) -> Array;
11580
11581        /// The `Intl.NumberFormat.prototype.formatToParts()` method allows locale-aware
11582        /// formatting of strings produced by `Intl.NumberFormat` formatters.
11583        ///
11584        /// Accepts numeric strings for BigInt/arbitrary precision (e.g., `"123n"` → `"123"`,
11585        /// or use E notation: `"1000000E-6"` → `"1"`).
11586        ///
11587        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/formatToParts)
11588        #[cfg(js_sys_unstable_apis)]
11589        #[wasm_bindgen(method, js_class = "Intl.NumberFormat", js_name = formatToParts)]
11590        pub fn format_to_parts(this: &NumberFormat, value: &JsString) -> Array<NumberFormatPart>;
11591
11592        /// Formats a range of numbers according to the locale and formatting options
11593        /// of this `Intl.NumberFormat` object.
11594        ///
11595        /// Accepts numeric strings for BigInt/arbitrary precision (e.g., `"123n"` → `"123"`,
11596        /// or use E notation: `"1000000E-6"` → `"1"`).
11597        ///
11598        /// Throws a `TypeError` if the values are invalid.
11599        ///
11600        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/formatRange)
11601        #[wasm_bindgen(method, js_class = "Intl.NumberFormat", js_name = formatRange, catch)]
11602        pub fn format_range(
11603            this: &NumberFormat,
11604            start: &JsString,
11605            end: &JsString,
11606        ) -> Result<JsString, JsValue>;
11607
11608        /// Returns an array of locale-specific tokens representing each part of
11609        /// the formatted number range.
11610        ///
11611        /// Accepts numeric strings for BigInt/arbitrary precision (e.g., `"123n"` → `"123"`,
11612        /// or use E notation: `"1000000E-6"` → `"1"`).
11613        ///
11614        /// Throws a `TypeError` if the values are invalid.
11615        ///
11616        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/formatRangeToParts)
11617        #[wasm_bindgen(method, js_class = "Intl.NumberFormat", js_name = formatRangeToParts, catch)]
11618        pub fn format_range_to_parts(
11619            this: &NumberFormat,
11620            start: &JsString,
11621            end: &JsString,
11622        ) -> Result<Array<NumberRangeFormatPart>, JsValue>;
11623
11624        /// The `Intl.NumberFormat.prototype.resolvedOptions()` method returns a new
11625        /// object with properties reflecting the locale and number formatting
11626        /// options computed during initialization of this NumberFormat object.
11627        ///
11628        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/resolvedOptions)
11629        #[cfg(not(js_sys_unstable_apis))]
11630        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
11631        pub fn resolved_options(this: &NumberFormat) -> Object;
11632
11633        /// The `Intl.NumberFormat.prototype.resolvedOptions()` method returns a new
11634        /// object with properties reflecting the locale and number formatting
11635        /// options computed during initialization of this NumberFormat object.
11636        ///
11637        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/resolvedOptions)
11638        #[cfg(js_sys_unstable_apis)]
11639        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
11640        pub fn resolved_options(this: &NumberFormat) -> ResolvedNumberFormatOptions;
11641
11642        /// The `Intl.NumberFormat.supportedLocalesOf()` method returns an array
11643        /// containing those of the provided locales that are supported in number
11644        /// formatting without having to fall back to the runtime's default locale.
11645        ///
11646        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/supportedLocalesOf)
11647        #[cfg(not(js_sys_unstable_apis))]
11648        #[wasm_bindgen(static_method_of = NumberFormat, js_namespace = Intl, js_name = supportedLocalesOf)]
11649        pub fn supported_locales_of(locales: &Array, options: &Object) -> Array;
11650
11651        /// The `Intl.NumberFormat.supportedLocalesOf()` method returns an array
11652        /// containing those of the provided locales that are supported in number
11653        /// formatting without having to fall back to the runtime's default locale.
11654        ///
11655        /// Throws a `RangeError` if locales contain invalid values.
11656        ///
11657        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/supportedLocalesOf)
11658        #[cfg(js_sys_unstable_apis)]
11659        #[wasm_bindgen(static_method_of = NumberFormat, js_namespace = Intl, js_name = supportedLocalesOf, catch)]
11660        pub fn supported_locales_of(
11661            locales: &[JsString],
11662            options: &LocaleMatcherOptions,
11663        ) -> Result<Array<JsString>, JsValue>;
11664    }
11665
11666    #[cfg(not(js_sys_unstable_apis))]
11667    impl Default for NumberFormat {
11668        fn default() -> Self {
11669            Self::new(
11670                &JsValue::UNDEFINED.unchecked_into(),
11671                &JsValue::UNDEFINED.unchecked_into(),
11672            )
11673        }
11674    }
11675
11676    #[cfg(js_sys_unstable_apis)]
11677    impl Default for NumberFormat {
11678        fn default() -> Self {
11679            Self::new(&[], &Default::default()).unwrap()
11680        }
11681    }
11682
11683    // Intl.PluralRulesOptions
11684    #[wasm_bindgen]
11685    extern "C" {
11686        /// Options for `Intl.PluralRules` constructor.
11687        ///
11688        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/PluralRules/PluralRules#options)
11689        #[wasm_bindgen(extends = Object)]
11690        #[derive(Clone, Debug)]
11691        pub type PluralRulesOptions;
11692
11693        #[wasm_bindgen(method, getter = localeMatcher)]
11694        pub fn get_locale_matcher(this: &PluralRulesOptions) -> Option<LocaleMatcher>;
11695        #[wasm_bindgen(method, setter = localeMatcher)]
11696        pub fn set_locale_matcher(this: &PluralRulesOptions, value: LocaleMatcher);
11697
11698        #[wasm_bindgen(method, getter = type)]
11699        pub fn get_type(this: &PluralRulesOptions) -> Option<PluralRulesType>;
11700        #[wasm_bindgen(method, setter = type)]
11701        pub fn set_type(this: &PluralRulesOptions, value: PluralRulesType);
11702
11703        #[wasm_bindgen(method, getter = minimumIntegerDigits)]
11704        pub fn get_minimum_integer_digits(this: &PluralRulesOptions) -> Option<u8>;
11705        #[wasm_bindgen(method, setter = minimumIntegerDigits)]
11706        pub fn set_minimum_integer_digits(this: &PluralRulesOptions, value: u8);
11707
11708        #[wasm_bindgen(method, getter = minimumFractionDigits)]
11709        pub fn get_minimum_fraction_digits(this: &PluralRulesOptions) -> Option<u8>;
11710        #[wasm_bindgen(method, setter = minimumFractionDigits)]
11711        pub fn set_minimum_fraction_digits(this: &PluralRulesOptions, value: u8);
11712
11713        #[wasm_bindgen(method, getter = maximumFractionDigits)]
11714        pub fn get_maximum_fraction_digits(this: &PluralRulesOptions) -> Option<u8>;
11715        #[wasm_bindgen(method, setter = maximumFractionDigits)]
11716        pub fn set_maximum_fraction_digits(this: &PluralRulesOptions, value: u8);
11717
11718        #[wasm_bindgen(method, getter = minimumSignificantDigits)]
11719        pub fn get_minimum_significant_digits(this: &PluralRulesOptions) -> Option<u8>;
11720        #[wasm_bindgen(method, setter = minimumSignificantDigits)]
11721        pub fn set_minimum_significant_digits(this: &PluralRulesOptions, value: u8);
11722
11723        #[wasm_bindgen(method, getter = maximumSignificantDigits)]
11724        pub fn get_maximum_significant_digits(this: &PluralRulesOptions) -> Option<u8>;
11725        #[wasm_bindgen(method, setter = maximumSignificantDigits)]
11726        pub fn set_maximum_significant_digits(this: &PluralRulesOptions, value: u8);
11727
11728        #[wasm_bindgen(method, getter = roundingPriority)]
11729        pub fn get_rounding_priority(this: &PluralRulesOptions) -> Option<RoundingPriority>;
11730        #[wasm_bindgen(method, setter = roundingPriority)]
11731        pub fn set_rounding_priority(this: &PluralRulesOptions, value: RoundingPriority);
11732
11733        #[wasm_bindgen(method, getter = roundingIncrement)]
11734        pub fn get_rounding_increment(this: &PluralRulesOptions) -> Option<u32>;
11735        #[wasm_bindgen(method, setter = roundingIncrement)]
11736        pub fn set_rounding_increment(this: &PluralRulesOptions, value: u32);
11737
11738        #[wasm_bindgen(method, getter = roundingMode)]
11739        pub fn get_rounding_mode(this: &PluralRulesOptions) -> Option<RoundingMode>;
11740        #[wasm_bindgen(method, setter = roundingMode)]
11741        pub fn set_rounding_mode(this: &PluralRulesOptions, value: RoundingMode);
11742
11743        #[wasm_bindgen(method, getter = trailingZeroDisplay)]
11744        pub fn get_trailing_zero_display(this: &PluralRulesOptions) -> Option<TrailingZeroDisplay>;
11745        #[wasm_bindgen(method, setter = trailingZeroDisplay)]
11746        pub fn set_trailing_zero_display(this: &PluralRulesOptions, value: TrailingZeroDisplay);
11747    }
11748
11749    impl PluralRulesOptions {
11750        pub fn new() -> PluralRulesOptions {
11751            JsCast::unchecked_into(Object::new())
11752        }
11753    }
11754
11755    impl Default for PluralRulesOptions {
11756        fn default() -> Self {
11757            PluralRulesOptions::new()
11758        }
11759    }
11760
11761    // Intl.ResolvedPluralRulesOptions
11762    #[wasm_bindgen]
11763    extern "C" {
11764        /// Resolved options returned by `Intl.PluralRules.prototype.resolvedOptions()`.
11765        ///
11766        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/PluralRules/resolvedOptions)
11767        #[wasm_bindgen(extends = PluralRulesOptions)]
11768        #[derive(Clone, Debug)]
11769        pub type ResolvedPluralRulesOptions;
11770
11771        /// The resolved locale string.
11772        #[wasm_bindgen(method, getter = locale)]
11773        pub fn get_locale(this: &ResolvedPluralRulesOptions) -> JsString;
11774
11775        /// The plural categories used by the locale.
11776        #[wasm_bindgen(method, getter = pluralCategories)]
11777        pub fn get_plural_categories(this: &ResolvedPluralRulesOptions) -> Array<JsString>;
11778    }
11779
11780    // Intl.PluralRules
11781    #[wasm_bindgen]
11782    extern "C" {
11783        /// The `Intl.PluralRules` object is a constructor for objects
11784        /// that enable plural sensitive formatting and plural language rules.
11785        ///
11786        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules)
11787        #[wasm_bindgen(extends = Object, js_namespace = Intl, typescript_type = "Intl.PluralRules")]
11788        #[derive(Clone, Debug)]
11789        pub type PluralRules;
11790
11791        /// The `Intl.PluralRules` object is a constructor for objects
11792        /// that enable plural sensitive formatting and plural language rules.
11793        ///
11794        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules)
11795        #[cfg(not(js_sys_unstable_apis))]
11796        #[wasm_bindgen(constructor, js_namespace = Intl)]
11797        pub fn new(locales: &Array, options: &Object) -> PluralRules;
11798
11799        /// The `Intl.PluralRules` object is a constructor for objects
11800        /// that enable plural sensitive formatting and plural language rules.
11801        ///
11802        /// Throws a `RangeError` if locales contain invalid values.
11803        ///
11804        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules)
11805        #[cfg(js_sys_unstable_apis)]
11806        #[wasm_bindgen(constructor, js_namespace = Intl, catch)]
11807        pub fn new(
11808            locales: &[JsString],
11809            options: &PluralRulesOptions,
11810        ) -> Result<PluralRules, JsValue>;
11811
11812        /// The `Intl.PluralRules.prototype.resolvedOptions()` method returns a new
11813        /// object with properties reflecting the locale and plural formatting
11814        /// options computed during initialization of this PluralRules object.
11815        ///
11816        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules/resolvedOptions)
11817        #[cfg(not(js_sys_unstable_apis))]
11818        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
11819        pub fn resolved_options(this: &PluralRules) -> Object;
11820
11821        /// The `Intl.PluralRules.prototype.resolvedOptions()` method returns a new
11822        /// object with properties reflecting the locale and plural formatting
11823        /// options computed during initialization of this PluralRules object.
11824        ///
11825        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules/resolvedOptions)
11826        #[cfg(js_sys_unstable_apis)]
11827        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
11828        pub fn resolved_options(this: &PluralRules) -> ResolvedPluralRulesOptions;
11829
11830        /// The `Intl.PluralRules.prototype.select()` method returns a String indicating
11831        /// which plural rule to use for locale-aware formatting.
11832        ///
11833        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules/select)
11834        #[cfg(not(js_sys_unstable_apis))]
11835        #[wasm_bindgen(method, js_namespace = Intl)]
11836        pub fn select(this: &PluralRules, number: f64) -> JsString;
11837
11838        /// The `Intl.PluralRules.prototype.select()` method returns a String indicating
11839        /// which plural rule to use for locale-aware formatting.
11840        ///
11841        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules/select)
11842        #[cfg(js_sys_unstable_apis)]
11843        #[wasm_bindgen(method, js_namespace = Intl)]
11844        pub fn select(this: &PluralRules, number: f64) -> PluralCategory;
11845
11846        /// The `Intl.PluralRules.prototype.selectRange()` method returns a string indicating
11847        /// which plural rule to use for locale-aware formatting of a range of numbers.
11848        ///
11849        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/PluralRules/selectRange)
11850        #[cfg(not(js_sys_unstable_apis))]
11851        #[wasm_bindgen(method, js_namespace = Intl, js_name = selectRange)]
11852        pub fn select_range(this: &PluralRules, start: f64, end: f64) -> JsString;
11853
11854        /// The `Intl.PluralRules.prototype.selectRange()` method returns a string indicating
11855        /// which plural rule to use for locale-aware formatting of a range of numbers.
11856        ///
11857        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/PluralRules/selectRange)
11858        #[cfg(js_sys_unstable_apis)]
11859        #[wasm_bindgen(method, js_namespace = Intl, js_name = selectRange)]
11860        pub fn select_range(this: &PluralRules, start: f64, end: f64) -> PluralCategory;
11861
11862        /// The `Intl.PluralRules.supportedLocalesOf()` method returns an array
11863        /// containing those of the provided locales that are supported in plural
11864        /// formatting without having to fall back to the runtime's default locale.
11865        ///
11866        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules/supportedLocalesOf)
11867        #[cfg(not(js_sys_unstable_apis))]
11868        #[wasm_bindgen(static_method_of = PluralRules, js_namespace = Intl, js_name = supportedLocalesOf)]
11869        pub fn supported_locales_of(locales: &Array, options: &Object) -> Array;
11870
11871        /// The `Intl.PluralRules.supportedLocalesOf()` method returns an array
11872        /// containing those of the provided locales that are supported in plural
11873        /// formatting without having to fall back to the runtime's default locale.
11874        ///
11875        /// Throws a `RangeError` if locales contain invalid values.
11876        ///
11877        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules/supportedLocalesOf)
11878        #[cfg(js_sys_unstable_apis)]
11879        #[wasm_bindgen(static_method_of = PluralRules, js_namespace = Intl, js_name = supportedLocalesOf, catch)]
11880        pub fn supported_locales_of(
11881            locales: &[JsString],
11882            options: &LocaleMatcherOptions,
11883        ) -> Result<Array<JsString>, JsValue>;
11884    }
11885
11886    #[cfg(not(js_sys_unstable_apis))]
11887    impl Default for PluralRules {
11888        fn default() -> Self {
11889            Self::new(
11890                &JsValue::UNDEFINED.unchecked_into(),
11891                &JsValue::UNDEFINED.unchecked_into(),
11892            )
11893        }
11894    }
11895
11896    #[cfg(js_sys_unstable_apis)]
11897    impl Default for PluralRules {
11898        fn default() -> Self {
11899            Self::new(&[], &Default::default()).unwrap()
11900        }
11901    }
11902
11903    // Intl.RelativeTimeFormat
11904    #[wasm_bindgen]
11905    extern "C" {
11906        /// The `Intl.RelativeTimeFormat` object is a constructor for objects
11907        /// that enable language-sensitive relative time formatting.
11908        ///
11909        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat)
11910        #[wasm_bindgen(extends = Object, js_namespace = Intl, typescript_type = "Intl.RelativeTimeFormat")]
11911        #[derive(Clone, Debug)]
11912        pub type RelativeTimeFormat;
11913
11914        /// The `Intl.RelativeTimeFormat` object is a constructor for objects
11915        /// that enable language-sensitive relative time formatting.
11916        ///
11917        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat)
11918        #[cfg(not(js_sys_unstable_apis))]
11919        #[wasm_bindgen(constructor, js_namespace = Intl)]
11920        pub fn new(locales: &Array, options: &Object) -> RelativeTimeFormat;
11921
11922        /// The `Intl.RelativeTimeFormat` object is a constructor for objects
11923        /// that enable language-sensitive relative time formatting.
11924        ///
11925        /// Throws a `RangeError` if locales contain invalid values.
11926        ///
11927        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat)
11928        #[cfg(js_sys_unstable_apis)]
11929        #[wasm_bindgen(constructor, js_namespace = Intl, catch)]
11930        pub fn new(locales: &[JsString]) -> Result<RelativeTimeFormat, JsValue>;
11931
11932        /// The `Intl.RelativeTimeFormat` object is a constructor for objects
11933        /// that enable language-sensitive relative time formatting.
11934        ///
11935        /// Throws a `RangeError` if locales or options contain invalid values.
11936        ///
11937        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat)
11938        #[cfg(js_sys_unstable_apis)]
11939        #[wasm_bindgen(constructor, js_namespace = Intl, catch)]
11940        pub fn new_with_options(
11941            locales: &[JsString],
11942            options: &RelativeTimeFormatOptions,
11943        ) -> Result<RelativeTimeFormat, JsValue>;
11944
11945        /// The `Intl.RelativeTimeFormat.prototype.format` method formats a `value` and `unit`
11946        /// according to the locale and formatting options of this Intl.RelativeTimeFormat object.
11947        ///
11948        /// Throws a `RangeError` if unit is invalid.
11949        ///
11950        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/format)
11951        #[cfg(not(js_sys_unstable_apis))]
11952        #[wasm_bindgen(method, js_class = "Intl.RelativeTimeFormat")]
11953        pub fn format(this: &RelativeTimeFormat, value: f64, unit: &str) -> JsString;
11954
11955        /// The `Intl.RelativeTimeFormat.prototype.format` method formats a `value` and `unit`
11956        /// according to the locale and formatting options of this Intl.RelativeTimeFormat object.
11957        ///
11958        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/format)
11959        #[cfg(js_sys_unstable_apis)]
11960        #[wasm_bindgen(method, js_class = "Intl.RelativeTimeFormat")]
11961        pub fn format(
11962            this: &RelativeTimeFormat,
11963            value: f64,
11964            unit: RelativeTimeFormatUnit,
11965        ) -> JsString;
11966
11967        /// The `Intl.RelativeTimeFormat.prototype.formatToParts()` method returns an array of
11968        /// objects representing the relative time format in parts that can be used for custom locale-aware formatting.
11969        ///
11970        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/formatToParts)
11971        #[cfg(not(js_sys_unstable_apis))]
11972        #[wasm_bindgen(method, js_class = "Intl.RelativeTimeFormat", js_name = formatToParts)]
11973        pub fn format_to_parts(this: &RelativeTimeFormat, value: f64, unit: &str) -> Array;
11974
11975        /// The `Intl.RelativeTimeFormat.prototype.formatToParts()` method returns an array of
11976        /// objects representing the relative time format in parts that can be used for custom locale-aware formatting.
11977        ///
11978        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/formatToParts)
11979        #[cfg(js_sys_unstable_apis)]
11980        #[wasm_bindgen(method, js_class = "Intl.RelativeTimeFormat", js_name = formatToParts)]
11981        pub fn format_to_parts(
11982            this: &RelativeTimeFormat,
11983            value: f64,
11984            unit: RelativeTimeFormatUnit,
11985        ) -> Array<RelativeTimeFormatPart>;
11986
11987        /// The `Intl.RelativeTimeFormat.prototype.resolvedOptions()` method returns a new
11988        /// object with properties reflecting the locale and relative time formatting
11989        /// options computed during initialization of this RelativeTimeFormat object.
11990        ///
11991        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/resolvedOptions)
11992        #[cfg(not(js_sys_unstable_apis))]
11993        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
11994        pub fn resolved_options(this: &RelativeTimeFormat) -> Object;
11995
11996        /// The `Intl.RelativeTimeFormat.prototype.resolvedOptions()` method returns a new
11997        /// object with properties reflecting the locale and relative time formatting
11998        /// options computed during initialization of this RelativeTimeFormat object.
11999        ///
12000        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/resolvedOptions)
12001        #[cfg(js_sys_unstable_apis)]
12002        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
12003        pub fn resolved_options(this: &RelativeTimeFormat) -> ResolvedRelativeTimeFormatOptions;
12004
12005        /// The `Intl.RelativeTimeFormat.supportedLocalesOf()` method returns an array
12006        /// containing those of the provided locales that are supported in date and time
12007        /// formatting without having to fall back to the runtime's default locale.
12008        ///
12009        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RelativeTimeFormat/supportedLocalesOf)
12010        #[cfg(not(js_sys_unstable_apis))]
12011        #[wasm_bindgen(static_method_of = RelativeTimeFormat, js_namespace = Intl, js_name = supportedLocalesOf)]
12012        pub fn supported_locales_of(locales: &Array, options: &Object) -> Array;
12013
12014        /// The `Intl.RelativeTimeFormat.supportedLocalesOf()` method returns an array
12015        /// containing those of the provided locales that are supported in date and time
12016        /// formatting without having to fall back to the runtime's default locale.
12017        ///
12018        /// Throws a `RangeError` if locales contain invalid values.
12019        ///
12020        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RelativeTimeFormat/supportedLocalesOf)
12021        #[cfg(js_sys_unstable_apis)]
12022        #[wasm_bindgen(static_method_of = RelativeTimeFormat, js_namespace = Intl, js_name = supportedLocalesOf, catch)]
12023        pub fn supported_locales_of(
12024            locales: &[JsString],
12025            options: &LocaleMatcherOptions,
12026        ) -> Result<Array<JsString>, JsValue>;
12027    }
12028
12029    #[cfg(not(js_sys_unstable_apis))]
12030    impl Default for RelativeTimeFormat {
12031        fn default() -> Self {
12032            Self::new(
12033                &JsValue::UNDEFINED.unchecked_into(),
12034                &JsValue::UNDEFINED.unchecked_into(),
12035            )
12036        }
12037    }
12038
12039    #[cfg(js_sys_unstable_apis)]
12040    impl Default for RelativeTimeFormat {
12041        fn default() -> Self {
12042            Self::new(&[]).unwrap()
12043        }
12044    }
12045
12046    // Intl.ListFormatOptions
12047    #[wasm_bindgen]
12048    extern "C" {
12049        /// Options for `Intl.ListFormat` constructor.
12050        ///
12051        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/ListFormat#options)
12052        #[wasm_bindgen(extends = Object)]
12053        #[derive(Clone, Debug)]
12054        pub type ListFormatOptions;
12055
12056        #[wasm_bindgen(method, getter = localeMatcher)]
12057        pub fn get_locale_matcher(this: &ListFormatOptions) -> Option<LocaleMatcher>;
12058        #[wasm_bindgen(method, setter = localeMatcher)]
12059        pub fn set_locale_matcher(this: &ListFormatOptions, value: LocaleMatcher);
12060
12061        #[wasm_bindgen(method, getter = type)]
12062        pub fn get_type(this: &ListFormatOptions) -> Option<ListFormatType>;
12063        #[wasm_bindgen(method, setter = type)]
12064        pub fn set_type(this: &ListFormatOptions, value: ListFormatType);
12065
12066        #[wasm_bindgen(method, getter = style)]
12067        pub fn get_style(this: &ListFormatOptions) -> Option<ListFormatStyle>;
12068        #[wasm_bindgen(method, setter = style)]
12069        pub fn set_style(this: &ListFormatOptions, value: ListFormatStyle);
12070    }
12071
12072    impl ListFormatOptions {
12073        pub fn new() -> ListFormatOptions {
12074            JsCast::unchecked_into(Object::new())
12075        }
12076    }
12077
12078    impl Default for ListFormatOptions {
12079        fn default() -> Self {
12080            ListFormatOptions::new()
12081        }
12082    }
12083
12084    // Intl.ResolvedListFormatOptions
12085    #[wasm_bindgen]
12086    extern "C" {
12087        /// Resolved options returned by `Intl.ListFormat.prototype.resolvedOptions()`.
12088        ///
12089        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/resolvedOptions)
12090        #[wasm_bindgen(extends = ListFormatOptions)]
12091        #[derive(Clone, Debug)]
12092        pub type ResolvedListFormatOptions;
12093
12094        /// The resolved locale string.
12095        #[wasm_bindgen(method, getter = locale)]
12096        pub fn get_locale(this: &ResolvedListFormatOptions) -> JsString;
12097    }
12098
12099    // Intl.ListFormatPart
12100    #[wasm_bindgen]
12101    extern "C" {
12102        /// A part of the formatted list returned by `formatToParts()`.
12103        ///
12104        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/formatToParts)
12105        #[wasm_bindgen(extends = Object)]
12106        #[derive(Clone, Debug)]
12107        pub type ListFormatPart;
12108
12109        /// The type of the part ("element" or "literal").
12110        #[wasm_bindgen(method, getter = type)]
12111        pub fn type_(this: &ListFormatPart) -> ListFormatPartType;
12112
12113        /// The value of the part.
12114        #[wasm_bindgen(method, getter)]
12115        pub fn value(this: &ListFormatPart) -> JsString;
12116    }
12117
12118    // Intl.ListFormat
12119    #[wasm_bindgen]
12120    extern "C" {
12121        /// The `Intl.ListFormat` object enables language-sensitive list formatting.
12122        ///
12123        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat)
12124        #[wasm_bindgen(extends = Object, js_namespace = Intl, typescript_type = "Intl.ListFormat")]
12125        #[derive(Clone, Debug)]
12126        pub type ListFormat;
12127
12128        /// Creates a new `Intl.ListFormat` object.
12129        ///
12130        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/ListFormat)
12131        #[cfg(not(js_sys_unstable_apis))]
12132        #[wasm_bindgen(constructor, js_namespace = Intl)]
12133        pub fn new(locales: &Array, options: &Object) -> ListFormat;
12134
12135        /// Creates a new `Intl.ListFormat` object.
12136        ///
12137        /// Throws a `RangeError` if locales or options contain invalid values.
12138        ///
12139        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/ListFormat)
12140        #[cfg(js_sys_unstable_apis)]
12141        #[wasm_bindgen(constructor, js_namespace = Intl, catch)]
12142        pub fn new(
12143            locales: &[JsString],
12144            options: &ListFormatOptions,
12145        ) -> Result<ListFormat, JsValue>;
12146
12147        /// Formats a list of strings according to the locale and options.
12148        ///
12149        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/format)
12150        #[cfg(not(js_sys_unstable_apis))]
12151        #[wasm_bindgen(method, js_class = "Intl.ListFormat")]
12152        pub fn format(this: &ListFormat, list: &Array) -> JsString;
12153
12154        /// Formats a list of strings according to the locale and options.
12155        ///
12156        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/format)
12157        #[cfg(js_sys_unstable_apis)]
12158        #[wasm_bindgen(method, js_class = "Intl.ListFormat")]
12159        pub fn format(this: &ListFormat, list: &[JsString]) -> JsString;
12160
12161        /// Returns an array of objects representing the list in parts.
12162        ///
12163        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/formatToParts)
12164        #[cfg(not(js_sys_unstable_apis))]
12165        #[wasm_bindgen(method, js_class = "Intl.ListFormat", js_name = formatToParts)]
12166        pub fn format_to_parts(this: &ListFormat, list: &Array) -> Array;
12167
12168        /// Returns an array of objects representing the list in parts.
12169        ///
12170        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/formatToParts)
12171        #[cfg(js_sys_unstable_apis)]
12172        #[wasm_bindgen(method, js_class = "Intl.ListFormat", js_name = formatToParts)]
12173        pub fn format_to_parts(this: &ListFormat, list: &[JsString]) -> Array<ListFormatPart>;
12174
12175        /// Returns an object with properties reflecting the options used.
12176        ///
12177        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/resolvedOptions)
12178        #[cfg(not(js_sys_unstable_apis))]
12179        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
12180        pub fn resolved_options(this: &ListFormat) -> Object;
12181
12182        /// Returns an object with properties reflecting the options used.
12183        ///
12184        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/resolvedOptions)
12185        #[cfg(js_sys_unstable_apis)]
12186        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
12187        pub fn resolved_options(this: &ListFormat) -> ResolvedListFormatOptions;
12188
12189        /// Returns an array of supported locales.
12190        ///
12191        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/supportedLocalesOf)
12192        #[cfg(not(js_sys_unstable_apis))]
12193        #[wasm_bindgen(static_method_of = ListFormat, js_namespace = Intl, js_name = supportedLocalesOf)]
12194        pub fn supported_locales_of(locales: &Array, options: &Object) -> Array;
12195
12196        /// Returns an array of supported locales.
12197        ///
12198        /// Throws a `RangeError` if locales contain invalid values.
12199        ///
12200        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/supportedLocalesOf)
12201        #[cfg(js_sys_unstable_apis)]
12202        #[wasm_bindgen(static_method_of = ListFormat, js_namespace = Intl, js_name = supportedLocalesOf, catch)]
12203        pub fn supported_locales_of(
12204            locales: &[JsString],
12205            options: &LocaleMatcherOptions,
12206        ) -> Result<Array<JsString>, JsValue>;
12207    }
12208
12209    #[cfg(not(js_sys_unstable_apis))]
12210    impl Default for ListFormat {
12211        fn default() -> Self {
12212            Self::new(
12213                &JsValue::UNDEFINED.unchecked_into(),
12214                &JsValue::UNDEFINED.unchecked_into(),
12215            )
12216        }
12217    }
12218
12219    #[cfg(js_sys_unstable_apis)]
12220    impl Default for ListFormat {
12221        fn default() -> Self {
12222            Self::new(&[], &Default::default()).unwrap()
12223        }
12224    }
12225
12226    // Intl.SegmenterOptions
12227    #[wasm_bindgen]
12228    extern "C" {
12229        /// Options for `Intl.Segmenter` constructor.
12230        ///
12231        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/Segmenter#options)
12232        #[wasm_bindgen(extends = Object)]
12233        #[derive(Clone, Debug)]
12234        pub type SegmenterOptions;
12235
12236        #[wasm_bindgen(method, getter = localeMatcher)]
12237        pub fn get_locale_matcher(this: &SegmenterOptions) -> Option<LocaleMatcher>;
12238        #[wasm_bindgen(method, setter = localeMatcher)]
12239        pub fn set_locale_matcher(this: &SegmenterOptions, value: LocaleMatcher);
12240
12241        #[wasm_bindgen(method, getter = granularity)]
12242        pub fn get_granularity(this: &SegmenterOptions) -> Option<SegmenterGranularity>;
12243        #[wasm_bindgen(method, setter = granularity)]
12244        pub fn set_granularity(this: &SegmenterOptions, value: SegmenterGranularity);
12245    }
12246
12247    impl SegmenterOptions {
12248        pub fn new() -> SegmenterOptions {
12249            JsCast::unchecked_into(Object::new())
12250        }
12251    }
12252
12253    impl Default for SegmenterOptions {
12254        fn default() -> Self {
12255            SegmenterOptions::new()
12256        }
12257    }
12258
12259    // Intl.ResolvedSegmenterOptions
12260    #[wasm_bindgen]
12261    extern "C" {
12262        /// Resolved options returned by `Intl.Segmenter.prototype.resolvedOptions()`.
12263        ///
12264        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/resolvedOptions)
12265        #[wasm_bindgen(extends = SegmenterOptions)]
12266        #[derive(Clone, Debug)]
12267        pub type ResolvedSegmenterOptions;
12268
12269        /// The resolved locale string.
12270        #[wasm_bindgen(method, getter = locale)]
12271        pub fn get_locale(this: &ResolvedSegmenterOptions) -> JsString;
12272    }
12273
12274    // Intl.SegmentData
12275    #[wasm_bindgen]
12276    extern "C" {
12277        /// Data about a segment returned by the Segments iterator.
12278        ///
12279        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/segment/Segments#segment_data)
12280        #[wasm_bindgen(extends = Object)]
12281        #[derive(Clone, Debug)]
12282        pub type SegmentData;
12283
12284        /// The segment string.
12285        #[wasm_bindgen(method, getter)]
12286        pub fn segment(this: &SegmentData) -> JsString;
12287
12288        /// The index of the segment in the original string.
12289        #[wasm_bindgen(method, getter)]
12290        pub fn index(this: &SegmentData) -> u32;
12291
12292        /// The original input string.
12293        #[wasm_bindgen(method, getter)]
12294        pub fn input(this: &SegmentData) -> JsString;
12295
12296        /// Whether the segment is word-like (only for word granularity).
12297        #[wasm_bindgen(method, getter = isWordLike)]
12298        pub fn is_word_like(this: &SegmentData) -> Option<bool>;
12299    }
12300
12301    // Intl.Segments
12302    #[wasm_bindgen]
12303    extern "C" {
12304        /// The Segments object is an iterable collection of segments of a string.
12305        ///
12306        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/segment/Segments)
12307        #[wasm_bindgen(extends = Object)]
12308        #[derive(Clone, Debug)]
12309        pub type Segments;
12310
12311        /// Returns segment data for the segment containing the character at the given index.
12312        ///
12313        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/segment/Segments/containing)
12314        #[wasm_bindgen(method)]
12315        pub fn containing(this: &Segments, index: u32) -> Option<SegmentData>;
12316    }
12317
12318    // Intl.Segmenter
12319    #[wasm_bindgen]
12320    extern "C" {
12321        /// The `Intl.Segmenter` object enables locale-sensitive text segmentation.
12322        ///
12323        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter)
12324        #[wasm_bindgen(extends = Object, js_namespace = Intl, typescript_type = "Intl.Segmenter")]
12325        #[derive(Clone, Debug)]
12326        pub type Segmenter;
12327
12328        /// Creates a new `Intl.Segmenter` object.
12329        ///
12330        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/Segmenter)
12331        #[cfg(not(js_sys_unstable_apis))]
12332        #[wasm_bindgen(constructor, js_namespace = Intl)]
12333        pub fn new(locales: &Array, options: &Object) -> Segmenter;
12334
12335        /// Creates a new `Intl.Segmenter` object.
12336        ///
12337        /// Throws a `RangeError` if locales or options contain invalid values.
12338        ///
12339        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/Segmenter)
12340        #[cfg(js_sys_unstable_apis)]
12341        #[wasm_bindgen(constructor, js_namespace = Intl, catch)]
12342        pub fn new(locales: &[JsString], options: &SegmenterOptions) -> Result<Segmenter, JsValue>;
12343
12344        /// Returns a Segments object containing the segments of the input string.
12345        ///
12346        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/segment)
12347        #[wasm_bindgen(method, js_class = "Intl.Segmenter")]
12348        pub fn segment(this: &Segmenter, input: &str) -> Segments;
12349
12350        /// Returns an object with properties reflecting the options used.
12351        ///
12352        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/resolvedOptions)
12353        #[cfg(not(js_sys_unstable_apis))]
12354        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
12355        pub fn resolved_options(this: &Segmenter) -> Object;
12356
12357        /// Returns an object with properties reflecting the options used.
12358        ///
12359        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/resolvedOptions)
12360        #[cfg(js_sys_unstable_apis)]
12361        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
12362        pub fn resolved_options(this: &Segmenter) -> ResolvedSegmenterOptions;
12363
12364        /// Returns an array of supported locales.
12365        ///
12366        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/supportedLocalesOf)
12367        #[cfg(not(js_sys_unstable_apis))]
12368        #[wasm_bindgen(static_method_of = Segmenter, js_namespace = Intl, js_name = supportedLocalesOf)]
12369        pub fn supported_locales_of(locales: &Array, options: &Object) -> Array;
12370
12371        /// Returns an array of supported locales.
12372        ///
12373        /// Throws a `RangeError` if locales contain invalid values.
12374        ///
12375        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/supportedLocalesOf)
12376        #[cfg(js_sys_unstable_apis)]
12377        #[wasm_bindgen(static_method_of = Segmenter, js_namespace = Intl, js_name = supportedLocalesOf, catch)]
12378        pub fn supported_locales_of(
12379            locales: &[JsString],
12380            options: &LocaleMatcherOptions,
12381        ) -> Result<Array<JsString>, JsValue>;
12382    }
12383
12384    #[cfg(not(js_sys_unstable_apis))]
12385    impl Default for Segmenter {
12386        fn default() -> Self {
12387            Self::new(
12388                &JsValue::UNDEFINED.unchecked_into(),
12389                &JsValue::UNDEFINED.unchecked_into(),
12390            )
12391        }
12392    }
12393
12394    #[cfg(js_sys_unstable_apis)]
12395    impl Default for Segmenter {
12396        fn default() -> Self {
12397            Self::new(&[], &Default::default()).unwrap()
12398        }
12399    }
12400
12401    // Intl.DisplayNamesOptions
12402    #[wasm_bindgen]
12403    extern "C" {
12404        /// Options for `Intl.DisplayNames` constructor.
12405        ///
12406        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/DisplayNames#options)
12407        #[wasm_bindgen(extends = Object)]
12408        #[derive(Clone, Debug)]
12409        pub type DisplayNamesOptions;
12410
12411        #[wasm_bindgen(method, getter = localeMatcher)]
12412        pub fn get_locale_matcher(this: &DisplayNamesOptions) -> Option<LocaleMatcher>;
12413        #[wasm_bindgen(method, setter = localeMatcher)]
12414        pub fn set_locale_matcher(this: &DisplayNamesOptions, value: LocaleMatcher);
12415
12416        #[wasm_bindgen(method, getter = type)]
12417        pub fn get_type(this: &DisplayNamesOptions) -> Option<DisplayNamesType>;
12418        #[wasm_bindgen(method, setter = type)]
12419        pub fn set_type(this: &DisplayNamesOptions, value: DisplayNamesType);
12420
12421        #[wasm_bindgen(method, getter = style)]
12422        pub fn get_style(this: &DisplayNamesOptions) -> Option<DisplayNamesStyle>;
12423        #[wasm_bindgen(method, setter = style)]
12424        pub fn set_style(this: &DisplayNamesOptions, value: DisplayNamesStyle);
12425
12426        #[wasm_bindgen(method, getter = fallback)]
12427        pub fn get_fallback(this: &DisplayNamesOptions) -> Option<DisplayNamesFallback>;
12428        #[wasm_bindgen(method, setter = fallback)]
12429        pub fn set_fallback(this: &DisplayNamesOptions, value: DisplayNamesFallback);
12430
12431        #[wasm_bindgen(method, getter = languageDisplay)]
12432        pub fn get_language_display(
12433            this: &DisplayNamesOptions,
12434        ) -> Option<DisplayNamesLanguageDisplay>;
12435        #[wasm_bindgen(method, setter = languageDisplay)]
12436        pub fn set_language_display(this: &DisplayNamesOptions, value: DisplayNamesLanguageDisplay);
12437    }
12438
12439    impl DisplayNamesOptions {
12440        pub fn new() -> DisplayNamesOptions {
12441            JsCast::unchecked_into(Object::new())
12442        }
12443    }
12444
12445    impl Default for DisplayNamesOptions {
12446        fn default() -> Self {
12447            DisplayNamesOptions::new()
12448        }
12449    }
12450
12451    // Intl.ResolvedDisplayNamesOptions
12452    #[wasm_bindgen]
12453    extern "C" {
12454        /// Resolved options returned by `Intl.DisplayNames.prototype.resolvedOptions()`.
12455        ///
12456        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/resolvedOptions)
12457        #[wasm_bindgen(extends = DisplayNamesOptions)]
12458        #[derive(Clone, Debug)]
12459        pub type ResolvedDisplayNamesOptions;
12460
12461        /// The resolved locale string.
12462        #[wasm_bindgen(method, getter = locale)]
12463        pub fn get_locale(this: &ResolvedDisplayNamesOptions) -> JsString;
12464    }
12465
12466    // Intl.DisplayNames
12467    #[wasm_bindgen]
12468    extern "C" {
12469        /// The `Intl.DisplayNames` object enables the consistent translation of
12470        /// language, region, and script display names.
12471        ///
12472        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames)
12473        #[wasm_bindgen(extends = Object, js_namespace = Intl, typescript_type = "Intl.DisplayNames")]
12474        #[derive(Clone, Debug)]
12475        pub type DisplayNames;
12476
12477        /// Creates a new `Intl.DisplayNames` object.
12478        ///
12479        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/DisplayNames)
12480        #[cfg(not(js_sys_unstable_apis))]
12481        #[wasm_bindgen(constructor, js_namespace = Intl)]
12482        pub fn new(locales: &Array, options: &Object) -> DisplayNames;
12483
12484        /// Creates a new `Intl.DisplayNames` object.
12485        ///
12486        /// Throws a `RangeError` if locales or options contain invalid values.
12487        ///
12488        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/DisplayNames)
12489        #[cfg(js_sys_unstable_apis)]
12490        #[wasm_bindgen(constructor, js_namespace = Intl, catch)]
12491        pub fn new(
12492            locales: &[JsString],
12493            options: &DisplayNamesOptions,
12494        ) -> Result<DisplayNames, JsValue>;
12495
12496        /// Returns the display name for the given code.
12497        ///
12498        /// Returns `undefined` if fallback is "none" and no name is available.
12499        ///
12500        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/of)
12501        #[wasm_bindgen(method, js_class = "Intl.DisplayNames")]
12502        pub fn of(this: &DisplayNames, code: &str) -> Option<JsString>;
12503
12504        /// Returns an object with properties reflecting the options used.
12505        ///
12506        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/resolvedOptions)
12507        #[cfg(not(js_sys_unstable_apis))]
12508        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
12509        pub fn resolved_options(this: &DisplayNames) -> Object;
12510
12511        /// Returns an object with properties reflecting the options used.
12512        ///
12513        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/resolvedOptions)
12514        #[cfg(js_sys_unstable_apis)]
12515        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
12516        pub fn resolved_options(this: &DisplayNames) -> ResolvedDisplayNamesOptions;
12517
12518        /// Returns an array of supported locales.
12519        ///
12520        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/supportedLocalesOf)
12521        #[cfg(not(js_sys_unstable_apis))]
12522        #[wasm_bindgen(static_method_of = DisplayNames, js_namespace = Intl, js_name = supportedLocalesOf)]
12523        pub fn supported_locales_of(locales: &Array, options: &Object) -> Array;
12524
12525        /// Returns an array of supported locales.
12526        ///
12527        /// Throws a `RangeError` if locales contain invalid values.
12528        ///
12529        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/supportedLocalesOf)
12530        #[cfg(js_sys_unstable_apis)]
12531        #[wasm_bindgen(static_method_of = DisplayNames, js_namespace = Intl, js_name = supportedLocalesOf, catch)]
12532        pub fn supported_locales_of(
12533            locales: &[JsString],
12534            options: &LocaleMatcherOptions,
12535        ) -> Result<Array<JsString>, JsValue>;
12536    }
12537
12538    // Intl.Locale
12539    #[wasm_bindgen]
12540    extern "C" {
12541        /// The `Intl.Locale` object is a standard built-in property of the Intl object
12542        /// that represents a Unicode locale identifier.
12543        ///
12544        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale)
12545        #[wasm_bindgen(extends = Object, js_namespace = Intl, typescript_type = "Intl.Locale")]
12546        #[derive(Clone, Debug)]
12547        pub type Locale;
12548
12549        /// Creates a new `Intl.Locale` object.
12550        ///
12551        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/Locale)
12552        #[wasm_bindgen(constructor, js_namespace = Intl, catch)]
12553        pub fn new(tag: &str) -> Result<Locale, JsValue>;
12554
12555        /// Creates a new `Intl.Locale` object with options.
12556        ///
12557        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/Locale)
12558        #[wasm_bindgen(constructor, js_namespace = Intl, catch)]
12559        pub fn new_with_options(tag: &str, options: &Object) -> Result<Locale, JsValue>;
12560
12561        /// The base name of the locale (language + region + script).
12562        ///
12563        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/baseName)
12564        #[wasm_bindgen(method, getter = baseName)]
12565        pub fn base_name(this: &Locale) -> JsString;
12566
12567        /// The calendar type for the locale.
12568        ///
12569        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/calendar)
12570        #[wasm_bindgen(method, getter)]
12571        pub fn calendar(this: &Locale) -> Option<JsString>;
12572
12573        /// The case first sorting option.
12574        ///
12575        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/caseFirst)
12576        #[wasm_bindgen(method, getter = caseFirst)]
12577        pub fn case_first(this: &Locale) -> Option<JsString>;
12578
12579        /// The collation type for the locale.
12580        ///
12581        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/collation)
12582        #[wasm_bindgen(method, getter)]
12583        pub fn collation(this: &Locale) -> Option<JsString>;
12584
12585        /// The hour cycle for the locale.
12586        ///
12587        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/hourCycle)
12588        #[wasm_bindgen(method, getter = hourCycle)]
12589        pub fn hour_cycle(this: &Locale) -> Option<JsString>;
12590
12591        /// The language code for the locale.
12592        ///
12593        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/language)
12594        #[wasm_bindgen(method, getter)]
12595        pub fn language(this: &Locale) -> JsString;
12596
12597        /// The numbering system for the locale.
12598        ///
12599        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/numberingSystem)
12600        #[wasm_bindgen(method, getter = numberingSystem)]
12601        pub fn numbering_system(this: &Locale) -> Option<JsString>;
12602
12603        /// Whether the locale uses numeric collation.
12604        ///
12605        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/numeric)
12606        #[wasm_bindgen(method, getter)]
12607        pub fn numeric(this: &Locale) -> bool;
12608
12609        /// The region code for the locale.
12610        ///
12611        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/region)
12612        #[wasm_bindgen(method, getter)]
12613        pub fn region(this: &Locale) -> Option<JsString>;
12614
12615        /// The script code for the locale.
12616        ///
12617        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/script)
12618        #[wasm_bindgen(method, getter)]
12619        pub fn script(this: &Locale) -> Option<JsString>;
12620
12621        /// Returns an array of available calendars for the locale.
12622        ///
12623        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getCalendars)
12624        #[wasm_bindgen(method, js_class = "Intl.Locale", js_name = getCalendars)]
12625        pub fn get_calendars(this: &Locale) -> Array<JsString>;
12626
12627        /// Returns an array of available collations for the locale.
12628        ///
12629        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getCollations)
12630        #[wasm_bindgen(method, js_class = "Intl.Locale", js_name = getCollations)]
12631        pub fn get_collations(this: &Locale) -> Array<JsString>;
12632
12633        /// Returns an array of available hour cycles for the locale.
12634        ///
12635        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getHourCycles)
12636        #[wasm_bindgen(method, js_class = "Intl.Locale", js_name = getHourCycles)]
12637        pub fn get_hour_cycles(this: &Locale) -> Array<JsString>;
12638
12639        /// Returns an array of available numbering systems for the locale.
12640        ///
12641        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getNumberingSystems)
12642        #[wasm_bindgen(method, js_class = "Intl.Locale", js_name = getNumberingSystems)]
12643        pub fn get_numbering_systems(this: &Locale) -> Array<JsString>;
12644
12645        /// Returns an array of available time zones for the locale's region.
12646        ///
12647        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getTimeZones)
12648        #[wasm_bindgen(method, js_class = "Intl.Locale", js_name = getTimeZones)]
12649        pub fn get_time_zones(this: &Locale) -> Option<Array<JsString>>;
12650
12651        /// Returns week information for the locale.
12652        ///
12653        /// May not be available in all environments.
12654        ///
12655        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getWeekInfo)
12656        #[wasm_bindgen(method, js_class = "Intl.Locale", js_name = getWeekInfo, catch)]
12657        pub fn get_week_info(this: &Locale) -> Result<WeekInfo, JsValue>;
12658
12659        /// Returns text layout information for the locale.
12660        ///
12661        /// May not be available in all environments.
12662        ///
12663        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getTextInfo)
12664        #[wasm_bindgen(method, js_class = "Intl.Locale", js_name = getTextInfo, catch)]
12665        pub fn get_text_info(this: &Locale) -> Result<TextInfo, JsValue>;
12666
12667        /// Returns a new Locale with the specified calendar.
12668        ///
12669        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/maximize)
12670        #[wasm_bindgen(method, js_class = "Intl.Locale")]
12671        pub fn maximize(this: &Locale) -> Locale;
12672
12673        /// Returns a new Locale with the minimal subtags.
12674        ///
12675        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/minimize)
12676        #[wasm_bindgen(method, js_class = "Intl.Locale")]
12677        pub fn minimize(this: &Locale) -> Locale;
12678    }
12679
12680    // Intl.Locale WeekInfo
12681    #[wasm_bindgen]
12682    extern "C" {
12683        /// Week information for a locale.
12684        ///
12685        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getWeekInfo)
12686        #[wasm_bindgen(extends = Object)]
12687        #[derive(Clone, Debug)]
12688        pub type WeekInfo;
12689
12690        /// The first day of the week (1 = Monday, 7 = Sunday).
12691        #[wasm_bindgen(method, getter = firstDay)]
12692        pub fn first_day(this: &WeekInfo) -> u8;
12693
12694        /// Array of weekend days.
12695        #[wasm_bindgen(method, getter)]
12696        pub fn weekend(this: &WeekInfo) -> Array<Number>;
12697
12698        /// Minimal days in the first week of the year.
12699        #[wasm_bindgen(method, getter = minimalDays)]
12700        pub fn minimal_days(this: &WeekInfo) -> u8;
12701    }
12702
12703    // Intl.Locale TextInfo
12704    #[wasm_bindgen]
12705    extern "C" {
12706        /// Text layout information for a locale.
12707        ///
12708        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getTextInfo)
12709        #[wasm_bindgen(extends = Object)]
12710        #[derive(Clone, Debug)]
12711        pub type TextInfo;
12712
12713        /// The text direction ("ltr" or "rtl").
12714        #[wasm_bindgen(method, getter)]
12715        pub fn direction(this: &TextInfo) -> JsString;
12716    }
12717
12718    // Intl.DurationFormat enums
12719
12720    /// The style for duration formatting.
12721    ///
12722    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/DurationFormat#style)
12723    #[wasm_bindgen]
12724    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
12725    pub enum DurationFormatStyle {
12726        Long = "long",
12727        Short = "short",
12728        Narrow = "narrow",
12729        Digital = "digital",
12730    }
12731
12732    /// The display style for individual duration units.
12733    ///
12734    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/DurationFormat#years)
12735    #[wasm_bindgen]
12736    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
12737    pub enum DurationUnitStyle {
12738        Long = "long",
12739        Short = "short",
12740        Narrow = "narrow",
12741    }
12742
12743    /// The display style for time duration units (hours, minutes, seconds).
12744    ///
12745    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/DurationFormat#hours)
12746    #[wasm_bindgen]
12747    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
12748    pub enum DurationTimeUnitStyle {
12749        Long = "long",
12750        Short = "short",
12751        Narrow = "narrow",
12752        Numeric = "numeric",
12753        #[wasm_bindgen(js_name = "2-digit")]
12754        TwoDigit = "2-digit",
12755    }
12756
12757    /// The display option for duration units.
12758    ///
12759    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/DurationFormat#yearsdisplay)
12760    #[wasm_bindgen]
12761    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
12762    pub enum DurationUnitDisplay {
12763        Auto = "auto",
12764        Always = "always",
12765    }
12766
12767    /// The type of a duration format part.
12768    ///
12769    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/formatToParts#type)
12770    #[wasm_bindgen]
12771    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
12772    pub enum DurationFormatPartType {
12773        Years = "years",
12774        Months = "months",
12775        Weeks = "weeks",
12776        Days = "days",
12777        Hours = "hours",
12778        Minutes = "minutes",
12779        Seconds = "seconds",
12780        Milliseconds = "milliseconds",
12781        Microseconds = "microseconds",
12782        Nanoseconds = "nanoseconds",
12783        Literal = "literal",
12784        Integer = "integer",
12785        Decimal = "decimal",
12786        Fraction = "fraction",
12787    }
12788
12789    // Intl.DurationFormatOptions
12790    #[wasm_bindgen]
12791    extern "C" {
12792        /// Options for `Intl.DurationFormat` constructor.
12793        ///
12794        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/DurationFormat#options)
12795        #[wasm_bindgen(extends = Object)]
12796        #[derive(Clone, Debug)]
12797        pub type DurationFormatOptions;
12798
12799        #[wasm_bindgen(method, getter = localeMatcher)]
12800        pub fn get_locale_matcher(this: &DurationFormatOptions) -> Option<LocaleMatcher>;
12801        #[wasm_bindgen(method, setter = localeMatcher)]
12802        pub fn set_locale_matcher(this: &DurationFormatOptions, value: LocaleMatcher);
12803
12804        #[wasm_bindgen(method, getter = style)]
12805        pub fn get_style(this: &DurationFormatOptions) -> Option<DurationFormatStyle>;
12806        #[wasm_bindgen(method, setter = style)]
12807        pub fn set_style(this: &DurationFormatOptions, value: DurationFormatStyle);
12808
12809        #[wasm_bindgen(method, getter = years)]
12810        pub fn get_years(this: &DurationFormatOptions) -> Option<DurationUnitStyle>;
12811        #[wasm_bindgen(method, setter = years)]
12812        pub fn set_years(this: &DurationFormatOptions, value: DurationUnitStyle);
12813
12814        #[wasm_bindgen(method, getter = yearsDisplay)]
12815        pub fn get_years_display(this: &DurationFormatOptions) -> Option<DurationUnitDisplay>;
12816        #[wasm_bindgen(method, setter = yearsDisplay)]
12817        pub fn set_years_display(this: &DurationFormatOptions, value: DurationUnitDisplay);
12818
12819        #[wasm_bindgen(method, getter = months)]
12820        pub fn get_months(this: &DurationFormatOptions) -> Option<DurationUnitStyle>;
12821        #[wasm_bindgen(method, setter = months)]
12822        pub fn set_months(this: &DurationFormatOptions, value: DurationUnitStyle);
12823
12824        #[wasm_bindgen(method, getter = monthsDisplay)]
12825        pub fn get_months_display(this: &DurationFormatOptions) -> Option<DurationUnitDisplay>;
12826        #[wasm_bindgen(method, setter = monthsDisplay)]
12827        pub fn set_months_display(this: &DurationFormatOptions, value: DurationUnitDisplay);
12828
12829        #[wasm_bindgen(method, getter = weeks)]
12830        pub fn get_weeks(this: &DurationFormatOptions) -> Option<DurationUnitStyle>;
12831        #[wasm_bindgen(method, setter = weeks)]
12832        pub fn set_weeks(this: &DurationFormatOptions, value: DurationUnitStyle);
12833
12834        #[wasm_bindgen(method, getter = weeksDisplay)]
12835        pub fn get_weeks_display(this: &DurationFormatOptions) -> Option<DurationUnitDisplay>;
12836        #[wasm_bindgen(method, setter = weeksDisplay)]
12837        pub fn set_weeks_display(this: &DurationFormatOptions, value: DurationUnitDisplay);
12838
12839        #[wasm_bindgen(method, getter = days)]
12840        pub fn get_days(this: &DurationFormatOptions) -> Option<DurationUnitStyle>;
12841        #[wasm_bindgen(method, setter = days)]
12842        pub fn set_days(this: &DurationFormatOptions, value: DurationUnitStyle);
12843
12844        #[wasm_bindgen(method, getter = daysDisplay)]
12845        pub fn get_days_display(this: &DurationFormatOptions) -> Option<DurationUnitDisplay>;
12846        #[wasm_bindgen(method, setter = daysDisplay)]
12847        pub fn set_days_display(this: &DurationFormatOptions, value: DurationUnitDisplay);
12848
12849        #[wasm_bindgen(method, getter = hours)]
12850        pub fn get_hours(this: &DurationFormatOptions) -> Option<DurationTimeUnitStyle>;
12851        #[wasm_bindgen(method, setter = hours)]
12852        pub fn set_hours(this: &DurationFormatOptions, value: DurationTimeUnitStyle);
12853
12854        #[wasm_bindgen(method, getter = hoursDisplay)]
12855        pub fn get_hours_display(this: &DurationFormatOptions) -> Option<DurationUnitDisplay>;
12856        #[wasm_bindgen(method, setter = hoursDisplay)]
12857        pub fn set_hours_display(this: &DurationFormatOptions, value: DurationUnitDisplay);
12858
12859        #[wasm_bindgen(method, getter = minutes)]
12860        pub fn get_minutes(this: &DurationFormatOptions) -> Option<DurationTimeUnitStyle>;
12861        #[wasm_bindgen(method, setter = minutes)]
12862        pub fn set_minutes(this: &DurationFormatOptions, value: DurationTimeUnitStyle);
12863
12864        #[wasm_bindgen(method, getter = minutesDisplay)]
12865        pub fn get_minutes_display(this: &DurationFormatOptions) -> Option<DurationUnitDisplay>;
12866        #[wasm_bindgen(method, setter = minutesDisplay)]
12867        pub fn set_minutes_display(this: &DurationFormatOptions, value: DurationUnitDisplay);
12868
12869        #[wasm_bindgen(method, getter = seconds)]
12870        pub fn get_seconds(this: &DurationFormatOptions) -> Option<DurationTimeUnitStyle>;
12871        #[wasm_bindgen(method, setter = seconds)]
12872        pub fn set_seconds(this: &DurationFormatOptions, value: DurationTimeUnitStyle);
12873
12874        #[wasm_bindgen(method, getter = secondsDisplay)]
12875        pub fn get_seconds_display(this: &DurationFormatOptions) -> Option<DurationUnitDisplay>;
12876        #[wasm_bindgen(method, setter = secondsDisplay)]
12877        pub fn set_seconds_display(this: &DurationFormatOptions, value: DurationUnitDisplay);
12878
12879        #[wasm_bindgen(method, getter = milliseconds)]
12880        pub fn get_milliseconds(this: &DurationFormatOptions) -> Option<DurationUnitStyle>;
12881        #[wasm_bindgen(method, setter = milliseconds)]
12882        pub fn set_milliseconds(this: &DurationFormatOptions, value: DurationUnitStyle);
12883
12884        #[wasm_bindgen(method, getter = millisecondsDisplay)]
12885        pub fn get_milliseconds_display(
12886            this: &DurationFormatOptions,
12887        ) -> Option<DurationUnitDisplay>;
12888        #[wasm_bindgen(method, setter = millisecondsDisplay)]
12889        pub fn set_milliseconds_display(this: &DurationFormatOptions, value: DurationUnitDisplay);
12890
12891        #[wasm_bindgen(method, getter = microseconds)]
12892        pub fn get_microseconds(this: &DurationFormatOptions) -> Option<DurationUnitStyle>;
12893        #[wasm_bindgen(method, setter = microseconds)]
12894        pub fn set_microseconds(this: &DurationFormatOptions, value: DurationUnitStyle);
12895
12896        #[wasm_bindgen(method, getter = microsecondsDisplay)]
12897        pub fn get_microseconds_display(
12898            this: &DurationFormatOptions,
12899        ) -> Option<DurationUnitDisplay>;
12900        #[wasm_bindgen(method, setter = microsecondsDisplay)]
12901        pub fn set_microseconds_display(this: &DurationFormatOptions, value: DurationUnitDisplay);
12902
12903        #[wasm_bindgen(method, getter = nanoseconds)]
12904        pub fn get_nanoseconds(this: &DurationFormatOptions) -> Option<DurationUnitStyle>;
12905        #[wasm_bindgen(method, setter = nanoseconds)]
12906        pub fn set_nanoseconds(this: &DurationFormatOptions, value: DurationUnitStyle);
12907
12908        #[wasm_bindgen(method, getter = nanosecondsDisplay)]
12909        pub fn get_nanoseconds_display(this: &DurationFormatOptions)
12910            -> Option<DurationUnitDisplay>;
12911        #[wasm_bindgen(method, setter = nanosecondsDisplay)]
12912        pub fn set_nanoseconds_display(this: &DurationFormatOptions, value: DurationUnitDisplay);
12913
12914        #[wasm_bindgen(method, getter = fractionalDigits)]
12915        pub fn get_fractional_digits(this: &DurationFormatOptions) -> Option<u8>;
12916        #[wasm_bindgen(method, setter = fractionalDigits)]
12917        pub fn set_fractional_digits(this: &DurationFormatOptions, value: u8);
12918    }
12919
12920    impl DurationFormatOptions {
12921        pub fn new() -> DurationFormatOptions {
12922            JsCast::unchecked_into(Object::new())
12923        }
12924    }
12925
12926    impl Default for DurationFormatOptions {
12927        fn default() -> Self {
12928            DurationFormatOptions::new()
12929        }
12930    }
12931
12932    // Intl.ResolvedDurationFormatOptions
12933    #[wasm_bindgen]
12934    extern "C" {
12935        /// Resolved options returned by `Intl.DurationFormat.prototype.resolvedOptions()`.
12936        ///
12937        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/resolvedOptions)
12938        #[wasm_bindgen(extends = DurationFormatOptions)]
12939        #[derive(Clone, Debug)]
12940        pub type ResolvedDurationFormatOptions;
12941
12942        /// The resolved locale string.
12943        #[wasm_bindgen(method, getter = locale)]
12944        pub fn get_locale(this: &ResolvedDurationFormatOptions) -> JsString;
12945
12946        /// The resolved numbering system.
12947        #[wasm_bindgen(method, getter = numberingSystem)]
12948        pub fn get_numbering_system(this: &ResolvedDurationFormatOptions) -> JsString;
12949    }
12950
12951    // Intl.Duration (input object for DurationFormat)
12952    #[wasm_bindgen]
12953    extern "C" {
12954        /// A duration object used as input to `Intl.DurationFormat.format()`.
12955        ///
12956        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/format#duration)
12957        #[wasm_bindgen(extends = Object)]
12958        #[derive(Clone, Debug)]
12959        pub type Duration;
12960
12961        #[wasm_bindgen(method, getter)]
12962        pub fn years(this: &Duration) -> Option<f64>;
12963        #[wasm_bindgen(method, setter)]
12964        pub fn set_years(this: &Duration, value: f64);
12965
12966        #[wasm_bindgen(method, getter)]
12967        pub fn months(this: &Duration) -> Option<f64>;
12968        #[wasm_bindgen(method, setter)]
12969        pub fn set_months(this: &Duration, value: f64);
12970
12971        #[wasm_bindgen(method, getter)]
12972        pub fn weeks(this: &Duration) -> Option<f64>;
12973        #[wasm_bindgen(method, setter)]
12974        pub fn set_weeks(this: &Duration, value: f64);
12975
12976        #[wasm_bindgen(method, getter)]
12977        pub fn days(this: &Duration) -> Option<f64>;
12978        #[wasm_bindgen(method, setter)]
12979        pub fn set_days(this: &Duration, value: f64);
12980
12981        #[wasm_bindgen(method, getter)]
12982        pub fn hours(this: &Duration) -> Option<f64>;
12983        #[wasm_bindgen(method, setter)]
12984        pub fn set_hours(this: &Duration, value: f64);
12985
12986        #[wasm_bindgen(method, getter)]
12987        pub fn minutes(this: &Duration) -> Option<f64>;
12988        #[wasm_bindgen(method, setter)]
12989        pub fn set_minutes(this: &Duration, value: f64);
12990
12991        #[wasm_bindgen(method, getter)]
12992        pub fn seconds(this: &Duration) -> Option<f64>;
12993        #[wasm_bindgen(method, setter)]
12994        pub fn set_seconds(this: &Duration, value: f64);
12995
12996        #[wasm_bindgen(method, getter)]
12997        pub fn milliseconds(this: &Duration) -> Option<f64>;
12998        #[wasm_bindgen(method, setter)]
12999        pub fn set_milliseconds(this: &Duration, value: f64);
13000
13001        #[wasm_bindgen(method, getter)]
13002        pub fn microseconds(this: &Duration) -> Option<f64>;
13003        #[wasm_bindgen(method, setter)]
13004        pub fn set_microseconds(this: &Duration, value: f64);
13005
13006        #[wasm_bindgen(method, getter)]
13007        pub fn nanoseconds(this: &Duration) -> Option<f64>;
13008        #[wasm_bindgen(method, setter)]
13009        pub fn set_nanoseconds(this: &Duration, value: f64);
13010    }
13011
13012    impl Duration {
13013        pub fn new() -> Duration {
13014            JsCast::unchecked_into(Object::new())
13015        }
13016    }
13017
13018    impl Default for Duration {
13019        fn default() -> Self {
13020            Duration::new()
13021        }
13022    }
13023
13024    // Intl.DurationFormatPart
13025    #[wasm_bindgen]
13026    extern "C" {
13027        /// A part of the formatted duration returned by `formatToParts()`.
13028        ///
13029        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/formatToParts)
13030        #[wasm_bindgen(extends = Object)]
13031        #[derive(Clone, Debug)]
13032        pub type DurationFormatPart;
13033
13034        /// The type of the part.
13035        #[wasm_bindgen(method, getter = type)]
13036        pub fn type_(this: &DurationFormatPart) -> DurationFormatPartType;
13037
13038        /// The value of the part.
13039        #[wasm_bindgen(method, getter)]
13040        pub fn value(this: &DurationFormatPart) -> JsString;
13041
13042        /// The unit this part represents (if applicable).
13043        #[wasm_bindgen(method, getter)]
13044        pub fn unit(this: &DurationFormatPart) -> Option<JsString>;
13045    }
13046
13047    // Intl.DurationFormat
13048    #[wasm_bindgen]
13049    extern "C" {
13050        /// The `Intl.DurationFormat` object enables language-sensitive duration formatting.
13051        ///
13052        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat)
13053        #[wasm_bindgen(extends = Object, js_namespace = Intl, typescript_type = "Intl.DurationFormat")]
13054        #[derive(Clone, Debug)]
13055        pub type DurationFormat;
13056
13057        /// Creates a new `Intl.DurationFormat` object.
13058        ///
13059        /// Throws a `RangeError` if locales or options contain invalid values.
13060        ///
13061        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/DurationFormat)
13062        #[wasm_bindgen(constructor, js_namespace = Intl, catch)]
13063        pub fn new(
13064            locales: &[JsString],
13065            options: &DurationFormatOptions,
13066        ) -> Result<DurationFormat, JsValue>;
13067
13068        /// Formats a duration according to the locale and formatting options.
13069        ///
13070        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/format)
13071        #[wasm_bindgen(method, js_class = "Intl.DurationFormat")]
13072        pub fn format(this: &DurationFormat, duration: &Duration) -> JsString;
13073
13074        /// Returns an array of objects representing the formatted duration in parts.
13075        ///
13076        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/formatToParts)
13077        #[wasm_bindgen(method, js_class = "Intl.DurationFormat", js_name = formatToParts)]
13078        pub fn format_to_parts(
13079            this: &DurationFormat,
13080            duration: &Duration,
13081        ) -> Array<DurationFormatPart>;
13082
13083        /// Returns an object with properties reflecting the options used.
13084        ///
13085        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/resolvedOptions)
13086        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
13087        pub fn resolved_options(this: &DurationFormat) -> ResolvedDurationFormatOptions;
13088
13089        /// Returns an array of supported locales.
13090        ///
13091        /// Throws a `RangeError` if locales contain invalid values.
13092        ///
13093        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/supportedLocalesOf)
13094        #[wasm_bindgen(static_method_of = DurationFormat, js_namespace = Intl, js_name = supportedLocalesOf, catch)]
13095        pub fn supported_locales_of(
13096            locales: &[JsString],
13097            options: &LocaleMatcherOptions,
13098        ) -> Result<Array<JsString>, JsValue>;
13099    }
13100
13101    impl Default for DurationFormat {
13102        fn default() -> Self {
13103            Self::new(&[], &Default::default()).unwrap()
13104        }
13105    }
13106}
13107
13108#[wasm_bindgen]
13109extern "C" {
13110    /// The `PromiseState` object represents the the status of the promise,
13111    /// as used in `allSettled`.
13112    ///
13113    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/allSettled)
13114    #[must_use]
13115    #[wasm_bindgen(extends = Object, typescript_type = "any")]
13116    #[derive(Clone, Debug)]
13117    pub type PromiseState<T = JsValue>;
13118
13119    /// A string, either "fulfilled" or "rejected", indicating the eventual state of the promise.
13120    #[wasm_bindgen(method, getter = status)]
13121    pub fn get_status<T>(this: &PromiseState<T>) -> String;
13122
13123    /// Only present if status is "fulfilled". The value that the promise was fulfilled with.
13124    #[wasm_bindgen(method, getter = value)]
13125    pub fn get_value<T>(this: &PromiseState<T>) -> Option<T>;
13126
13127    /// Only present if status is "rejected". The reason that the promise was rejected with.
13128    #[wasm_bindgen(method, getter = reason)]
13129    pub fn get_reason<T>(this: &PromiseState<T>) -> Option<JsValue>;
13130}
13131
13132impl<T> PromiseState<T> {
13133    pub fn is_fulfilled(&self) -> bool {
13134        self.get_status() == "fulfilled"
13135    }
13136
13137    pub fn is_rejected(&self) -> bool {
13138        self.get_status() == "rejected"
13139    }
13140}
13141
13142/// Converts a `PromiseState<T>` into a `Result<T, JsValue>`, matching the
13143/// spec invariant that exactly one of the fulfilled value or the rejection
13144/// reason is populated per slot.
13145impl<T: JsGeneric + FromWasmAbi> From<PromiseState<T>> for Result<T, JsValue> {
13146    fn from(state: PromiseState<T>) -> Result<T, JsValue> {
13147        if state.is_fulfilled() {
13148            Ok(state.get_value().unwrap())
13149        } else {
13150            Err(state.get_reason().unwrap())
13151        }
13152    }
13153}
13154
13155// Promise
13156#[wasm_bindgen]
13157extern "C" {
13158    /// The `Promise` object represents the eventual completion (or failure) of
13159    /// an asynchronous operation, and its resulting value.
13160    ///
13161    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
13162    #[must_use]
13163    #[wasm_bindgen(extends = Object, typescript_type = "Promise<any>", no_promising)]
13164    #[derive(Clone, Debug)]
13165    pub type Promise<T = JsValue>;
13166
13167    /// Creates a new `Promise` with the provided executor `cb`
13168    ///
13169    /// The `cb` is a function that is passed with the arguments `resolve` and
13170    /// `reject`. The `cb` function is executed immediately by the `Promise`
13171    /// implementation, passing `resolve` and `reject` functions (the executor
13172    /// is called before the `Promise` constructor even returns the created
13173    /// object). The `resolve` and `reject` functions, when called, resolve or
13174    /// reject the promise, respectively. The executor normally initiates
13175    /// some asynchronous work, and then, once that completes, either calls
13176    /// the `resolve` function to resolve the promise or else rejects it if an
13177    /// error occurred.
13178    ///
13179    /// If an error is thrown in the executor function, the promise is rejected.
13180    /// The return value of the executor is ignored.
13181    ///
13182    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
13183    #[cfg(not(js_sys_unstable_apis))]
13184    #[wasm_bindgen(constructor)]
13185    pub fn new(cb: &mut dyn FnMut(Function, Function)) -> Promise;
13186
13187    /// Creates a new `Promise` with the provided executor `cb`
13188    ///
13189    /// The `cb` is a function that is passed with the arguments `resolve` and
13190    /// `reject`. The `cb` function is executed immediately by the `Promise`
13191    /// implementation, passing `resolve` and `reject` functions (the executor
13192    /// is called before the `Promise` constructor even returns the created
13193    /// object). The `resolve` and `reject` functions, when called, resolve or
13194    /// reject the promise, respectively. The executor normally initiates
13195    /// some asynchronous work, and then, once that completes, either calls
13196    /// the `resolve` function to resolve the promise or else rejects it if an
13197    /// error occurred.
13198    ///
13199    /// If an error is thrown in the executor function, the promise is rejected.
13200    /// The return value of the executor is ignored.
13201    ///
13202    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
13203    #[cfg(js_sys_unstable_apis)]
13204    #[wasm_bindgen(constructor)]
13205    pub fn new<T: JsGeneric>(
13206        cb: &mut dyn FnMut(Function<fn(T) -> Undefined>, Function<fn(JsValue) -> Undefined>),
13207    ) -> Promise<T>;
13208
13209    // Next major: deprecate
13210    /// Creates a new `Promise` with the provided executor `cb`
13211    ///
13212    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
13213    #[wasm_bindgen(constructor)]
13214    pub fn new_typed<T: Promising + JsGeneric>(
13215        cb: &mut dyn FnMut(Function<fn(T) -> Undefined>, Function<fn(JsValue) -> Undefined>),
13216    ) -> Promise<<T as Promising>::Resolution>;
13217
13218    /// The `Promise.all(iterable)` method returns a single `Promise` that
13219    /// resolves when all of the promises in the iterable argument have resolved
13220    /// or when the iterable argument contains no promises. It rejects with the
13221    /// reason of the first promise that rejects.
13222    ///
13223    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all)
13224    #[cfg(not(js_sys_unstable_apis))]
13225    #[wasm_bindgen(static_method_of = Promise)]
13226    pub fn all(obj: &JsValue) -> Promise;
13227
13228    /// The `Promise.all(iterable)` method returns a single `Promise` that
13229    /// resolves when all of the promises in the iterable argument have resolved
13230    /// or when the iterable argument contains no promises. It rejects with the
13231    /// reason of the first promise that rejects.
13232    ///
13233    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all)
13234    #[cfg(js_sys_unstable_apis)]
13235    #[wasm_bindgen(static_method_of = Promise, js_name = all)]
13236    pub fn all<I: Iterable>(obj: &I) -> Promise<Array<<I::Item as Promising>::Resolution>>
13237    where
13238        I::Item: Promising;
13239
13240    // Next major: deprecate
13241    /// The `Promise.all(iterable)` method returns a single `Promise` that
13242    /// resolves when all of the promises in the iterable argument have resolved
13243    /// or when the iterable argument contains no promises. It rejects with the
13244    /// reason of the first promise that rejects.
13245    ///
13246    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all)
13247    #[wasm_bindgen(static_method_of = Promise, js_name = all)]
13248    pub fn all_iterable<I: Iterable>(obj: &I) -> Promise<Array<<I::Item as Promising>::Resolution>>
13249    where
13250        I::Item: Promising;
13251
13252    /// The `Promise.allSettled(iterable)` method returns a single `Promise` that
13253    /// resolves when all of the promises in the iterable argument have either
13254    /// fulfilled or rejected or when the iterable argument contains no promises.
13255    ///
13256    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/allSettled)
13257    #[cfg(not(js_sys_unstable_apis))]
13258    #[wasm_bindgen(static_method_of = Promise, js_name = allSettled)]
13259    pub fn all_settled(obj: &JsValue) -> Promise;
13260
13261    /// The `Promise.allSettled(iterable)` method returns a single `Promise` that
13262    /// resolves when all of the promises in the iterable argument have either
13263    /// fulfilled or rejected or when the iterable argument contains no promises.
13264    ///
13265    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/allSettled)
13266    #[cfg(js_sys_unstable_apis)]
13267    #[wasm_bindgen(static_method_of = Promise, js_name = allSettled)]
13268    pub fn all_settled<I: Iterable>(
13269        obj: &I,
13270    ) -> Promise<Array<PromiseState<<I::Item as Promising>::Resolution>>>
13271    where
13272        I::Item: Promising;
13273
13274    // Next major: deprecate
13275    /// The `Promise.allSettled(iterable)` method returns a single `Promise` that
13276    /// resolves when all of the promises in the iterable argument have either
13277    /// fulfilled or rejected or when the iterable argument contains no promises.
13278    ///
13279    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/allSettled)
13280    #[wasm_bindgen(static_method_of = Promise, js_name = allSettled)]
13281    pub fn all_settled_iterable<I: Iterable>(
13282        obj: &I,
13283    ) -> Promise<Array<PromiseState<<I::Item as Promising>::Resolution>>>
13284    where
13285        I::Item: Promising;
13286
13287    /// The `Promise.any(iterable)` method returns a single `Promise` that
13288    /// resolves when any of the promises in the iterable argument have resolved
13289    /// or when the iterable argument contains no promises. It rejects with an
13290    /// `AggregateError` if all promises in the iterable rejected.
13291    ///
13292    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/any)
13293    #[cfg(not(js_sys_unstable_apis))]
13294    #[wasm_bindgen(static_method_of = Promise)]
13295    pub fn any(obj: &JsValue) -> Promise;
13296
13297    /// The `Promise.any(iterable)` method returns a single `Promise` that
13298    /// resolves when any of the promises in the iterable argument have resolved
13299    /// or when the iterable argument contains no promises. It rejects with an
13300    /// `AggregateError` if all promises in the iterable rejected.
13301    ///
13302    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/any)
13303    #[cfg(js_sys_unstable_apis)]
13304    #[wasm_bindgen(static_method_of = Promise, js_name = any)]
13305    pub fn any<I: Iterable>(obj: &I) -> Promise<<I::Item as Promising>::Resolution>
13306    where
13307        I::Item: Promising;
13308
13309    // Next major: deprecate
13310    /// The `Promise.any(iterable)` method returns a single `Promise` that
13311    /// resolves when any of the promises in the iterable argument have resolved
13312    /// or when the iterable argument contains no promises. It rejects with an
13313    /// `AggregateError` if all promises in the iterable rejected.
13314    ///
13315    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/any)
13316    #[wasm_bindgen(static_method_of = Promise, js_name = any)]
13317    pub fn any_iterable<I: Iterable>(obj: &I) -> Promise<<I::Item as Promising>::Resolution>
13318    where
13319        I::Item: Promising;
13320
13321    /// The `Promise.race(iterable)` method returns a promise that resolves or
13322    /// rejects as soon as one of the promises in the iterable resolves or
13323    /// rejects, with the value or reason from that promise.
13324    ///
13325    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/race)
13326    #[cfg(not(js_sys_unstable_apis))]
13327    #[wasm_bindgen(static_method_of = Promise)]
13328    pub fn race(obj: &JsValue) -> Promise;
13329
13330    /// The `Promise.race(iterable)` method returns a promise that resolves or
13331    /// rejects as soon as one of the promises in the iterable resolves or
13332    /// rejects, with the value or reason from that promise.
13333    ///
13334    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/race)
13335    #[cfg(js_sys_unstable_apis)]
13336    #[wasm_bindgen(static_method_of = Promise, js_name = race)]
13337    pub fn race<I: Iterable>(obj: &I) -> Promise<<I::Item as Promising>::Resolution>
13338    where
13339        I::Item: Promising;
13340
13341    // Next major: deprecate
13342    /// The `Promise.race(iterable)` method returns a promise that resolves or
13343    /// rejects as soon as one of the promises in the iterable resolves or
13344    /// rejects, with the value or reason from that promise.
13345    ///
13346    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/race)
13347    #[wasm_bindgen(static_method_of = Promise, js_name = race)]
13348    pub fn race_iterable<I: Iterable>(obj: &I) -> Promise<<I::Item as Promising>::Resolution>
13349    where
13350        I::Item: Promising;
13351
13352    /// The `Promise.reject(reason)` method returns a `Promise` object that is
13353    /// rejected with the given reason.
13354    ///
13355    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/reject)
13356    #[cfg(not(js_sys_unstable_apis))]
13357    #[wasm_bindgen(static_method_of = Promise)]
13358    pub fn reject(obj: &JsValue) -> Promise;
13359
13360    /// The `Promise.reject(reason)` method returns a `Promise` object that is
13361    /// rejected with the given reason.
13362    ///
13363    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/reject)
13364    #[cfg(js_sys_unstable_apis)]
13365    #[wasm_bindgen(static_method_of = Promise, js_name = reject)]
13366    pub fn reject<T>(obj: &JsValue) -> Promise<T>;
13367
13368    // Next major: deprecate
13369    /// The `Promise.reject(reason)` method returns a `Promise` object that is
13370    /// rejected with the given reason.
13371    ///
13372    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/reject)
13373    #[wasm_bindgen(static_method_of = Promise, js_name = reject)]
13374    pub fn reject_typed<T>(obj: &JsValue) -> Promise<T>;
13375
13376    /// The `Promise.resolve(value)` method returns a `Promise` object that is
13377    /// resolved with the given value. If the value is a promise, that promise
13378    /// is returned; if the value is a thenable (i.e. has a "then" method), the
13379    /// returned promise will "follow" that thenable, adopting its eventual
13380    /// state; otherwise the returned promise will be fulfilled with the value.
13381    ///
13382    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/resolve)
13383    #[wasm_bindgen(static_method_of = Promise, js_name = resolve)]
13384    pub fn resolve<U: Promising>(obj: &U) -> Promise<U::Resolution>;
13385
13386    /// The `catch()` method returns a `Promise` and deals with rejected cases
13387    /// only.  It behaves the same as calling `Promise.prototype.then(undefined,
13388    /// onRejected)` (in fact, calling `obj.catch(onRejected)` internally calls
13389    /// `obj.then(undefined, onRejected)`).
13390    ///
13391    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/catch)
13392    #[cfg(not(js_sys_unstable_apis))]
13393    #[wasm_bindgen(method)]
13394    pub fn catch<T>(this: &Promise<T>, cb: &ScopedClosure<dyn FnMut(JsValue)>) -> Promise<JsValue>;
13395
13396    /// The `catch()` method returns a `Promise` and deals with rejected cases
13397    /// only.  It behaves the same as calling `Promise.prototype.then(undefined,
13398    /// onRejected)` (in fact, calling `obj.catch(onRejected)` internally calls
13399    /// `obj.then(undefined, onRejected)`).
13400    ///
13401    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/catch)
13402    #[cfg(js_sys_unstable_apis)]
13403    #[wasm_bindgen(method, js_name = catch)]
13404    pub fn catch<'a, T, R: Promising>(
13405        this: &Promise<T>,
13406        cb: &ScopedClosure<'a, dyn FnMut(T) -> Result<R, JsError>>,
13407    ) -> Promise<R::Resolution>;
13408
13409    // Next major: deprecate
13410    /// Same as `catch`, but returning a result to become the new Promise value.
13411    #[wasm_bindgen(method, js_name = catch)]
13412    pub fn catch_map<'a, T, R: Promising>(
13413        this: &Promise<T>,
13414        cb: &ScopedClosure<'a, dyn FnMut(T) -> Result<R, JsError>>,
13415    ) -> Promise<R::Resolution>;
13416
13417    /// The `then()` method returns a `Promise`. It takes up to two arguments:
13418    /// callback functions for the success and failure cases of the `Promise`.
13419    ///
13420    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then)
13421    #[cfg(not(js_sys_unstable_apis))]
13422    #[wasm_bindgen(method)]
13423    pub fn then<'a, T>(this: &Promise<T>, cb: &ScopedClosure<'a, dyn FnMut(T)>)
13424        -> Promise<JsValue>;
13425
13426    /// The `then()` method returns a `Promise`. It takes up to two arguments:
13427    /// callback functions for the success and failure cases of the `Promise`.
13428    ///
13429    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then)
13430    #[cfg(js_sys_unstable_apis)]
13431    #[wasm_bindgen(method, js_name = then)]
13432    pub fn then<'a, T, R: Promising>(
13433        this: &Promise<T>,
13434        cb: &ScopedClosure<'a, dyn FnMut(T) -> Result<R, JsError>>,
13435    ) -> Promise<R::Resolution>;
13436
13437    /// The `then()` method returns a `Promise`. It takes up to two arguments:
13438    /// callback functions for the success and failure cases of the `Promise`.
13439    ///
13440    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then)
13441    #[wasm_bindgen(method, js_name = then)]
13442    pub fn then_with_reject<'a, T, R: Promising>(
13443        this: &Promise<T>,
13444        resolve: &ScopedClosure<'a, dyn FnMut(T) -> Result<R, JsError>>,
13445        reject: &ScopedClosure<'a, dyn FnMut(JsValue) -> Result<R, JsError>>,
13446    ) -> Promise<R::Resolution>;
13447
13448    // Next major: deprecate
13449    /// Alias for `then()` with a return value.
13450    /// The `then()` method returns a `Promise`. It takes up to two arguments:
13451    /// callback functions for the success and failure cases of the `Promise`.
13452    ///
13453    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then)
13454    #[wasm_bindgen(method, js_name = then)]
13455    pub fn then_map<'a, T, R: Promising>(
13456        this: &Promise<T>,
13457        cb: &ScopedClosure<'a, dyn FnMut(T) -> Result<R, JsError>>,
13458    ) -> Promise<R::Resolution>;
13459
13460    /// Same as `then`, only with both arguments provided.
13461    ///
13462    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then)
13463    #[wasm_bindgen(method, js_name = then)]
13464    pub fn then2(
13465        this: &Promise,
13466        resolve: &ScopedClosure<dyn FnMut(JsValue)>,
13467        reject: &ScopedClosure<dyn FnMut(JsValue)>,
13468    ) -> Promise;
13469
13470    /// The `finally()` method returns a `Promise`. When the promise is settled,
13471    /// whether fulfilled or rejected, the specified callback function is
13472    /// executed. This provides a way for code that must be executed once the
13473    /// `Promise` has been dealt with to be run whether the promise was
13474    /// fulfilled successfully or rejected.
13475    ///
13476    /// This lets you avoid duplicating code in both the promise's `then()` and
13477    /// `catch()` handlers.
13478    ///
13479    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/finally)
13480    #[wasm_bindgen(method)]
13481    pub fn finally<T>(this: &Promise<T>, cb: &ScopedClosure<dyn FnMut()>) -> Promise<JsValue>;
13482}
13483
13484impl<T: JsGeneric> Promising for Promise<T> {
13485    type Resolution = T;
13486}
13487
13488/// Internal: maps a tuple of `Promise<T_i>` to the result shapes of
13489/// [`Promise::all_tuple`] and [`Promise::all_settled_tuple`].
13490///
13491/// Implemented for every tuple arity 1..=8 of `Promise<T: JsGeneric>`. The
13492/// associated `Joined` / `Settled` types pin down the [`ArrayTuple`] shape
13493/// of the result so the one [`JsCast::unchecked_into`] needed to reinterpret
13494/// the [`Array<JsValue>`] returned by `Promise.all` / `Promise.allSettled`
13495/// is encapsulated inside each impl — the caller sees a fully-typed
13496/// `Promise<ArrayTuple<...>>`.
13497///
13498/// The soundness of the `unchecked_into`s here rests on `Promise.all` and
13499/// `Promise.allSettled` preserving input order and arity, which they do by
13500/// spec.
13501///
13502/// You normally call [`Promise::all_tuple`] / [`Promise::all_settled_tuple`]
13503/// rather than using this trait directly.
13504#[doc(hidden)]
13505pub trait PromiseTuple {
13506    /// The typed `ArrayTuple` shape the joined promise resolves to.
13507    ///
13508    /// For a tuple `(Promise<T1>, Promise<T2>, ...)` this is
13509    /// `ArrayTuple<(T1, T2, ...)>`.
13510    type Joined: JsGeneric;
13511
13512    /// The typed `ArrayTuple` shape the all-settled promise resolves to.
13513    ///
13514    /// For a tuple `(Promise<T1>, Promise<T2>, ...)` this is
13515    /// `ArrayTuple<(PromiseState<T1>, PromiseState<T2>, ...)>`.
13516    type Settled: JsGeneric;
13517
13518    /// Join via `Promise.all`, returning a typed `Promise`.
13519    fn all(self) -> Promise<Self::Joined>;
13520
13521    /// Settle via `Promise.allSettled`, returning a typed `Promise`.
13522    fn all_settled(self) -> Promise<Self::Settled>;
13523}
13524
13525macro_rules! impl_promise_tuple {
13526    ([$($T:ident)+] [$($idx:tt)+]) => {
13527        // Rust tuple of `Promise<T_i>`. Builds the heterogeneous
13528        // `ArrayTuple` of promises via the existing `From<(...)>` impl
13529        // (each element upcasts through `JsGeneric`), then delegates to
13530        // the `ArrayTuple` impl below.
13531        impl<$($T: JsGeneric),+> PromiseTuple for ($(Promise<$T>,)+) {
13532            type Joined = ArrayTuple<($($T,)+)>;
13533            type Settled = ArrayTuple<($(PromiseState<$T>,)+)>;
13534
13535            fn all(self) -> Promise<Self::Joined> {
13536                let tuple: ArrayTuple<($(Promise<$T>,)+)> = ($(self.$idx,)+).into();
13537                tuple.all()
13538            }
13539
13540            fn all_settled(self) -> Promise<Self::Settled> {
13541                let tuple: ArrayTuple<($(Promise<$T>,)+)> = ($(self.$idx,)+).into();
13542                tuple.all_settled()
13543            }
13544        }
13545
13546        // `ArrayTuple<(Promise<T_1>, ..., Promise<T_n>)>` — callers who
13547        // already have an `ArrayTuple` (e.g. from a binding that returns
13548        // one, or built via `.into()` earlier in a pipeline) can pass it
13549        // directly without unpacking into a Rust tuple.
13550        //
13551        // Hands the `ArrayTuple` straight to `Promise.all_iterable` /
13552        // `Promise.allSettled_iterable` and reinterprets the result
13553        // `Array<JsValue>` as the intended typed `ArrayTuple`. Safe because
13554        // `Promise.all` / `Promise.allSettled` preserve input order and
13555        // arity by spec.
13556        impl<$($T: JsGeneric),+> PromiseTuple for ArrayTuple<($(Promise<$T>,)+)> {
13557            type Joined = ArrayTuple<($($T,)+)>;
13558            type Settled = ArrayTuple<($(PromiseState<$T>,)+)>;
13559
13560            fn all(self) -> Promise<Self::Joined> {
13561                use wasm_bindgen::JsCast;
13562                Promise::all_iterable(&self).unchecked_into()
13563            }
13564
13565            fn all_settled(self) -> Promise<Self::Settled> {
13566                use wasm_bindgen::JsCast;
13567                Promise::all_settled_iterable(&self).unchecked_into()
13568            }
13569        }
13570    };
13571}
13572
13573impl_promise_tuple!([T1][0]);
13574impl_promise_tuple!([T1 T2] [0 1]);
13575impl_promise_tuple!([T1 T2 T3] [0 1 2]);
13576impl_promise_tuple!([T1 T2 T3 T4] [0 1 2 3]);
13577impl_promise_tuple!([T1 T2 T3 T4 T5] [0 1 2 3 4]);
13578impl_promise_tuple!([T1 T2 T3 T4 T5 T6] [0 1 2 3 4 5]);
13579impl_promise_tuple!([T1 T2 T3 T4 T5 T6 T7] [0 1 2 3 4 5 6]);
13580impl_promise_tuple!([T1 T2 T3 T4 T5 T6 T7 T8] [0 1 2 3 4 5 6 7]);
13581
13582impl Promise {
13583    /// Heterogeneous counterpart to [`Promise::all_iterable`]: accepts a Rust
13584    /// tuple of `Promise<T_i>` and returns a single [`Promise`] resolving to a
13585    /// typed [`ArrayTuple<(T_1, T_2, ..., T_n)>`].
13586    ///
13587    /// Destructure the awaited result via [`ArrayTuple::into_tuple`] to get
13588    /// the individual values back as a native Rust tuple. Implemented for
13589    /// arity 1..=8.
13590    ///
13591    /// Rejects with the first rejection, matching `Promise.all` semantics.
13592    ///
13593    /// # Example
13594    ///
13595    /// ```ignore
13596    /// use js_sys::Promise;
13597    ///
13598    /// let (response, buffer) = Promise::all_tuple((fetch_promise, buffer_promise))
13599    ///     .await?
13600    ///     .into_tuple();
13601    /// ```
13602    #[inline]
13603    pub fn all_tuple<T: PromiseTuple>(promises: T) -> Promise<T::Joined> {
13604        promises.all()
13605    }
13606
13607    /// Heterogeneous counterpart to [`Promise::all_settled_iterable`]: accepts
13608    /// a Rust tuple of `Promise<T_i>` and returns a single [`Promise`]
13609    /// resolving to a typed
13610    /// `ArrayTuple<(PromiseState<T_1>, ..., PromiseState<T_n>)>`.
13611    ///
13612    /// Unlike [`Promise::all_tuple`], this never rejects early: every input
13613    /// settles (fulfills or rejects) and is reflected by its [`PromiseState`]
13614    /// slot in the result tuple. Implemented for arity 1..=8.
13615    ///
13616    /// # Example
13617    ///
13618    /// ```ignore
13619    /// use js_sys::Promise;
13620    ///
13621    /// let results = Promise::all_settled_tuple((fetch_promise, buffer_promise)).await?;
13622    /// let (response_state, buffer_state) = results.into_tuple();
13623    /// ```
13624    #[inline]
13625    pub fn all_settled_tuple<T: PromiseTuple>(promises: T) -> Promise<T::Settled> {
13626        promises.all_settled()
13627    }
13628}
13629
13630/// Returns a handle to the global scope object.
13631///
13632/// This allows access to the global properties and global names by accessing
13633/// the `Object` returned.
13634pub fn global() -> Object {
13635    use wasm_bindgen::__rt::LazyCell;
13636
13637    #[cfg_attr(target_feature = "atomics", thread_local)]
13638    static GLOBAL: LazyCell<Object> = LazyCell::new(get_global_object);
13639
13640    return GLOBAL.clone();
13641
13642    fn get_global_object() -> Object {
13643        // Accessing the global object is not an easy thing to do, and what we
13644        // basically want is `globalThis` but we can't rely on that existing
13645        // everywhere. In the meantime we've got the fallbacks mentioned in:
13646        //
13647        // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis
13648        //
13649        // Note that this is pretty heavy code-size wise but it at least gets
13650        // the job largely done for now and avoids the `Function` constructor at
13651        // the end which triggers CSP errors.
13652        #[wasm_bindgen]
13653        extern "C" {
13654            #[derive(Clone, Debug)]
13655            type Global;
13656
13657            #[wasm_bindgen(thread_local_v2, js_name = globalThis)]
13658            static GLOBAL_THIS: Option<Object>;
13659
13660            #[wasm_bindgen(thread_local_v2, js_name = self)]
13661            static SELF: Option<Object>;
13662
13663            #[wasm_bindgen(thread_local_v2, js_name = window)]
13664            static WINDOW: Option<Object>;
13665
13666            #[wasm_bindgen(thread_local_v2, js_name = global)]
13667            static GLOBAL: Option<Object>;
13668        }
13669
13670        // The order is important: in Firefox Extension Content Scripts `globalThis`
13671        // is a Sandbox (not Window), so `globalThis` must be checked after `window`.
13672        let static_object = SELF
13673            .with(Option::clone)
13674            .or_else(|| WINDOW.with(Option::clone))
13675            .or_else(|| GLOBAL_THIS.with(Option::clone))
13676            .or_else(|| GLOBAL.with(Option::clone));
13677        if let Some(obj) = static_object {
13678            if !obj.is_undefined() {
13679                return obj;
13680            }
13681        }
13682
13683        // Global object not found
13684        JsValue::undefined().unchecked_into()
13685    }
13686}
13687
13688// Float16Array
13689//
13690// Rust does not yet have a stable builtin `f16`, so the raw JS bindings live
13691// here and any Rust-side helper APIs use explicit `u16` / `f32` naming. The
13692// unsuffixed float APIs are reserved for a future native `f16` binding.
13693#[wasm_bindgen]
13694extern "C" {
13695    #[wasm_bindgen(extends = Object, typescript_type = "Float16Array")]
13696    #[derive(Clone, Debug)]
13697    pub type Float16Array;
13698
13699    /// The `Float16Array()` constructor creates a new array.
13700    ///
13701    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float16Array)
13702    #[wasm_bindgen(constructor)]
13703    pub fn new(constructor_arg: &JsValue) -> Float16Array;
13704
13705    /// The `Float16Array()` constructor creates an array with an internal
13706    /// buffer large enough for `length` elements.
13707    ///
13708    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float16Array)
13709    #[wasm_bindgen(constructor)]
13710    pub fn new_with_length(length: u32) -> Float16Array;
13711
13712    /// The `Float16Array()` constructor creates an array with the given
13713    /// buffer but is a view starting at `byte_offset`.
13714    ///
13715    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float16Array)
13716    #[wasm_bindgen(constructor)]
13717    pub fn new_with_byte_offset(buffer: &JsValue, byte_offset: u32) -> Float16Array;
13718
13719    /// The `Float16Array()` constructor creates an array with the given
13720    /// buffer but is a view starting at `byte_offset` for `length` elements.
13721    ///
13722    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float16Array)
13723    #[wasm_bindgen(constructor)]
13724    pub fn new_with_byte_offset_and_length(
13725        buffer: &JsValue,
13726        byte_offset: u32,
13727        length: u32,
13728    ) -> Float16Array;
13729
13730    /// The `fill()` method fills all elements from a start index to an end
13731    /// index with a static `f32` value.
13732    ///
13733    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/fill)
13734    #[wasm_bindgen(method, js_name = fill)]
13735    pub fn fill_with_f32(this: &Float16Array, value: f32, start: u32, end: u32) -> Float16Array;
13736
13737    /// The buffer accessor property represents the `ArrayBuffer` referenced
13738    /// by a `TypedArray` at construction time.
13739    #[wasm_bindgen(getter, method)]
13740    pub fn buffer(this: &Float16Array) -> ArrayBuffer;
13741
13742    /// The `subarray()` method returns a new `TypedArray` on the same
13743    /// `ArrayBuffer` store and with the same element types as this array.
13744    #[wasm_bindgen(method)]
13745    pub fn subarray(this: &Float16Array, begin: u32, end: u32) -> Float16Array;
13746
13747    /// The `slice()` method returns a shallow copy of a portion of a typed
13748    /// array into a new typed array object.
13749    #[wasm_bindgen(method)]
13750    pub fn slice(this: &Float16Array, begin: u32, end: u32) -> Float16Array;
13751
13752    /// The `forEach()` method executes a provided function once per array
13753    /// element, passing values as `f32`.
13754    #[wasm_bindgen(method, js_name = forEach)]
13755    pub fn for_each_as_f32(this: &Float16Array, callback: &mut dyn FnMut(f32, u32, Float16Array));
13756
13757    /// The `forEach()` method executes a provided function once per array
13758    /// element, passing values as `f32`.
13759    #[wasm_bindgen(method, js_name = forEach, catch)]
13760    pub fn try_for_each_as_f32(
13761        this: &Float16Array,
13762        callback: &mut dyn FnMut(f32, u32, Float16Array) -> Result<(), JsError>,
13763    ) -> Result<(), JsValue>;
13764
13765    /// The length accessor property represents the length (in elements) of a
13766    /// typed array.
13767    #[wasm_bindgen(method, getter)]
13768    pub fn length(this: &Float16Array) -> u32;
13769
13770    /// The byteLength accessor property represents the length (in bytes) of a
13771    /// typed array.
13772    #[wasm_bindgen(method, getter, js_name = byteLength)]
13773    pub fn byte_length(this: &Float16Array) -> u32;
13774
13775    /// The byteOffset accessor property represents the offset (in bytes) of a
13776    /// typed array from the start of its `ArrayBuffer`.
13777    #[wasm_bindgen(method, getter, js_name = byteOffset)]
13778    pub fn byte_offset(this: &Float16Array) -> u32;
13779
13780    /// The `set()` method stores multiple values in the typed array, reading
13781    /// input values from a specified array.
13782    #[wasm_bindgen(method)]
13783    pub fn set(this: &Float16Array, src: &JsValue, offset: u32);
13784
13785    /// Gets the value at `idx` as an `f32`, counting from the end if negative.
13786    #[wasm_bindgen(method, js_name = at)]
13787    pub fn at_as_f32(this: &Float16Array, idx: i32) -> Option<f32>;
13788
13789    /// The `copyWithin()` method shallow copies part of a typed array to another
13790    /// location in the same typed array and returns it, without modifying its size.
13791    ///
13792    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/copyWithin)
13793    #[wasm_bindgen(method, js_name = copyWithin)]
13794    pub fn copy_within(this: &Float16Array, target: i32, start: i32, end: i32) -> Float16Array;
13795
13796    /// Gets the value at `idx` as an `f32`, equivalent to JavaScript
13797    /// `arr[idx]`.
13798    #[wasm_bindgen(method, indexing_getter)]
13799    pub fn get_index_as_f32(this: &Float16Array, idx: u32) -> f32;
13800
13801    /// Sets the value at `idx` from an `f32`, equivalent to JavaScript
13802    /// `arr[idx] = value`.
13803    #[wasm_bindgen(method, indexing_setter)]
13804    pub fn set_index_from_f32(this: &Float16Array, idx: u32, value: f32);
13805}
13806
13807impl Default for Float16Array {
13808    fn default() -> Self {
13809        Self::new(&JsValue::UNDEFINED.unchecked_into())
13810    }
13811}
13812
13813impl TypedArray for Float16Array {}
13814
13815impl Float16Array {
13816    fn as_uint16_view(&self) -> Uint16Array {
13817        let buffer = self.buffer();
13818        Uint16Array::new_with_byte_offset_and_length(
13819            buffer.as_ref(),
13820            self.byte_offset(),
13821            self.length(),
13822        )
13823    }
13824
13825    /// Creates an array from raw IEEE 754 binary16 bit patterns.
13826    ///
13827    /// This pairs naturally with the optional `half` crate:
13828    ///
13829    /// ```rust
13830    /// use half::f16;
13831    /// use js_sys::Float16Array;
13832    ///
13833    /// let values = [f16::from_f32(1.0), f16::from_f32(-2.0)];
13834    /// let bits = values.map(f16::to_bits);
13835    /// let array = Float16Array::new_from_u16_slice(&bits);
13836    /// ```
13837    pub fn new_from_u16_slice(slice: &[u16]) -> Float16Array {
13838        let array = Float16Array::new_with_length(slice.len() as u32);
13839        array.copy_from_u16_slice(slice);
13840        array
13841    }
13842
13843    /// Copy the raw IEEE 754 binary16 bit patterns from this JS typed array
13844    /// into the destination Rust slice.
13845    ///
13846    /// # Panics
13847    ///
13848    /// This function will panic if this typed array's length is different than
13849    /// the length of the provided `dst` array.
13850    ///
13851    /// Values copied into `dst` can be converted back into `half::f16` with
13852    /// `half::f16::from_bits`.
13853    pub fn copy_to_u16_slice(&self, dst: &mut [u16]) {
13854        self.as_uint16_view().copy_to(dst);
13855    }
13856
13857    /// Copy raw IEEE 754 binary16 bit patterns from the source Rust slice into
13858    /// this JS typed array.
13859    ///
13860    /// # Panics
13861    ///
13862    /// This function will panic if this typed array's length is different than
13863    /// the length of the provided `src` array.
13864    ///
13865    /// When using the optional `half` crate, populate `src` with
13866    /// `half::f16::to_bits()`.
13867    pub fn copy_from_u16_slice(&self, src: &[u16]) {
13868        self.as_uint16_view().copy_from(src);
13869    }
13870
13871    /// Efficiently copies the contents of this JS typed array into a new Vec of
13872    /// raw IEEE 754 binary16 bit patterns.
13873    ///
13874    /// This makes it easy to round-trip through the optional `half` crate:
13875    ///
13876    /// ```rust
13877    /// use half::f16;
13878    ///
13879    /// let bits = array.to_u16_vec();
13880    /// let values: Vec<f16> = bits.into_iter().map(f16::from_bits).collect();
13881    /// ```
13882    pub fn to_u16_vec(&self) -> Vec<u16> {
13883        self.as_uint16_view().to_vec()
13884    }
13885}
13886
13887macro_rules! arrays {
13888    ($(#[doc = $ctor:literal] #[doc = $mdn:literal] $name:ident: $ty:ident,)*) => ($(
13889        #[wasm_bindgen]
13890        extern "C" {
13891            #[wasm_bindgen(extends = Object, typescript_type = $name)]
13892            #[derive(Clone, Debug)]
13893            pub type $name;
13894
13895            /// The
13896            #[doc = $ctor]
13897            /// constructor creates a new array.
13898            ///
13899            /// [MDN documentation](
13900            #[doc = $mdn]
13901            /// )
13902            #[wasm_bindgen(constructor)]
13903            pub fn new(constructor_arg: &JsValue) -> $name;
13904
13905            /// An
13906            #[doc = $ctor]
13907            /// which creates an array with an internal buffer large
13908            /// enough for `length` elements.
13909            ///
13910            /// [MDN documentation](
13911            #[doc = $mdn]
13912            /// )
13913            #[wasm_bindgen(constructor)]
13914            pub fn new_with_length(length: u32) -> $name;
13915
13916            /// An
13917            #[doc = $ctor]
13918            /// which creates an array from a Rust slice.
13919            ///
13920            /// [MDN documentation](
13921            #[doc = $mdn]
13922            /// )
13923            #[wasm_bindgen(constructor)]
13924            pub fn new_from_slice(slice: &[$ty]) -> $name;
13925
13926            /// An
13927            #[doc = $ctor]
13928            /// which creates an array with the given buffer but is a
13929            /// view starting at `byte_offset`.
13930            ///
13931            /// [MDN documentation](
13932            #[doc = $mdn]
13933            /// )
13934            #[wasm_bindgen(constructor)]
13935            pub fn new_with_byte_offset(buffer: &JsValue, byte_offset: u32) -> $name;
13936
13937            /// An
13938            #[doc = $ctor]
13939            /// which creates an array with the given buffer but is a
13940            /// view starting at `byte_offset` for `length` elements.
13941            ///
13942            /// [MDN documentation](
13943            #[doc = $mdn]
13944            /// )
13945            #[wasm_bindgen(constructor)]
13946            pub fn new_with_byte_offset_and_length(
13947                buffer: &JsValue,
13948                byte_offset: u32,
13949                length: u32,
13950            ) -> $name;
13951
13952            /// The `fill()` method fills all the elements of an array from a start index
13953            /// to an end index with a static value. The end index is not included.
13954            ///
13955            /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/fill)
13956            #[wasm_bindgen(method)]
13957            pub fn fill(this: &$name, value: $ty, start: u32, end: u32) -> $name;
13958
13959            /// The buffer accessor property represents the `ArrayBuffer` referenced
13960            /// by a `TypedArray` at construction time.
13961            #[wasm_bindgen(getter, method)]
13962            pub fn buffer(this: &$name) -> ArrayBuffer;
13963
13964            /// The `subarray()` method returns a new `TypedArray` on the same
13965            /// `ArrayBuffer` store and with the same element types as for this
13966            /// `TypedArray` object.
13967            #[wasm_bindgen(method)]
13968            pub fn subarray(this: &$name, begin: u32, end: u32) -> $name;
13969
13970            /// The `slice()` method returns a shallow copy of a portion of a typed
13971            /// array into a new typed array object. This method has the same algorithm
13972            /// as `Array.prototype.slice()`.
13973            #[wasm_bindgen(method)]
13974            pub fn slice(this: &$name, begin: u32, end: u32) -> $name;
13975
13976            /// The `forEach()` method executes a provided function once per array
13977            /// element. This method has the same algorithm as
13978            /// `Array.prototype.forEach()`. `TypedArray` is one of the typed array
13979            /// types here.
13980            #[wasm_bindgen(method, js_name = forEach)]
13981            pub fn for_each(this: &$name, callback: &mut dyn FnMut($ty, u32, $name));
13982
13983            /// The `forEach()` method executes a provided function once per array
13984            /// element. This method has the same algorithm as
13985            /// `Array.prototype.forEach()`. `TypedArray` is one of the typed array
13986            /// types here.
13987            #[wasm_bindgen(method, js_name = forEach, catch)]
13988            pub fn try_for_each(this: &$name, callback: &mut dyn FnMut($ty, u32, $name) -> Result<(), JsError>) -> Result<(), JsValue>;
13989
13990            /// The length accessor property represents the length (in elements) of a
13991            /// typed array.
13992            #[wasm_bindgen(method, getter)]
13993            pub fn length(this: &$name) -> u32;
13994
13995            /// The byteLength accessor property represents the length (in bytes) of a
13996            /// typed array.
13997            #[wasm_bindgen(method, getter, js_name = byteLength)]
13998            pub fn byte_length(this: &$name) -> u32;
13999
14000            /// The byteOffset accessor property represents the offset (in bytes) of a
14001            /// typed array from the start of its `ArrayBuffer`.
14002            #[wasm_bindgen(method, getter, js_name = byteOffset)]
14003            pub fn byte_offset(this: &$name) -> u32;
14004
14005            /// The `set()` method stores multiple values in the typed array, reading
14006            /// input values from a specified array.
14007            #[wasm_bindgen(method)]
14008            pub fn set(this: &$name, src: &JsValue, offset: u32);
14009
14010            /// Gets the value at `idx`, counting from the end if negative.
14011            #[wasm_bindgen(method)]
14012            pub fn at(this: &$name, idx: i32) -> Option<$ty>;
14013
14014            /// The `copyWithin()` method shallow copies part of a typed array to another
14015            /// location in the same typed array and returns it, without modifying its size.
14016            ///
14017            /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/copyWithin)
14018            #[wasm_bindgen(method, js_name = copyWithin)]
14019            pub fn copy_within(this: &$name, target: i32, start: i32, end: i32) -> $name;
14020
14021            /// Gets the value at `idx`, equivalent to the javascript `my_var = arr[idx]`.
14022            #[wasm_bindgen(method, indexing_getter)]
14023            pub fn get_index(this: &$name, idx: u32) -> $ty;
14024
14025            /// Sets the value at `idx`, equivalent to the javascript `arr[idx] = value`.
14026            #[wasm_bindgen(method, indexing_setter)]
14027            pub fn set_index(this: &$name, idx: u32, value: $ty);
14028
14029            /// Copies the Rust slice's data to self.
14030            ///
14031            /// This method is not expected to be public. It requires the length of the
14032            /// TypedArray to be the same as the slice, use `self.copy_from(slice)` instead.
14033            #[wasm_bindgen(method, js_name = set)]
14034            fn copy_from_slice(this: &$name, slice: &[$ty]);
14035
14036            /// Copies this TypedArray's data to Rust slice;
14037            ///
14038            /// This method is not expected to be public. It requires the length of the
14039            /// TypedArray to be the same as the slice, use `self.copy_to(slice)` instead.
14040            ///
14041            /// # Workaround
14042            ///
14043            /// We actually need `slice.set(typed_array)` here, but since slice cannot be treated as
14044            /// `Uint8Array` on the Rust side, we use `Uint8Array.prototype.set.call`, which allows
14045            /// us to specify the `this` value inside the function.
14046            ///
14047            /// Therefore, `Uint8Array.prototype.set.call(slice, typed_array)` is equivalent to
14048            /// `slice.set(typed_array)`.
14049            #[wasm_bindgen(js_namespace = $name, js_name = "prototype.set.call")]
14050            fn copy_to_slice(slice: &mut [$ty], this: &$name);
14051        }
14052
14053        impl $name {
14054            /// Creates a JS typed array which is a view into wasm's linear
14055            /// memory at the slice specified.
14056            ///
14057            /// This function returns a new typed array which is a view into
14058            /// wasm's memory. This view does not copy the underlying data.
14059            ///
14060            /// # Safety
14061            ///
14062            /// Views into WebAssembly memory are only valid so long as the
14063            /// backing buffer isn't resized in JS. Once this function is called
14064            /// any future calls to `Box::new` (or malloc of any form) may cause
14065            /// the returned value here to be invalidated. Use with caution!
14066            ///
14067            /// Additionally the returned object can be safely mutated but the
14068            /// input slice isn't guaranteed to be mutable.
14069            ///
14070            /// Finally, the returned object is disconnected from the input
14071            /// slice's lifetime, so there's no guarantee that the data is read
14072            /// at the right time.
14073            pub unsafe fn view(rust: &[$ty]) -> $name {
14074                wasm_bindgen::__rt::wbg_cast(rust)
14075            }
14076
14077            /// Creates a JS typed array which is a view into wasm's linear
14078            /// memory at the specified pointer with specified length.
14079            ///
14080            /// This function returns a new typed array which is a view into
14081            /// wasm's memory. This view does not copy the underlying data.
14082            ///
14083            /// # Safety
14084            ///
14085            /// Views into WebAssembly memory are only valid so long as the
14086            /// backing buffer isn't resized in JS. Once this function is called
14087            /// any future calls to `Box::new` (or malloc of any form) may cause
14088            /// the returned value here to be invalidated. Use with caution!
14089            ///
14090            /// Additionally the returned object can be safely mutated,
14091            /// the changes are guaranteed to be reflected in the input array.
14092            pub unsafe fn view_mut_raw(ptr: *mut $ty, length: usize) -> $name {
14093                let slice = core::slice::from_raw_parts_mut(ptr, length);
14094                Self::view(slice)
14095            }
14096
14097            /// Copy the contents of this JS typed array into the destination
14098            /// Rust pointer.
14099            ///
14100            /// This function will efficiently copy the memory from a typed
14101            /// array into this Wasm module's own linear memory, initializing
14102            /// the memory destination provided.
14103            ///
14104            /// # Safety
14105            ///
14106            /// This function requires `dst` to point to a buffer
14107            /// large enough to fit this array's contents.
14108            pub unsafe fn raw_copy_to_ptr(&self, dst: *mut $ty) {
14109                let slice = core::slice::from_raw_parts_mut(dst, self.length() as usize);
14110                self.copy_to(slice);
14111            }
14112
14113            /// Copy the contents of this JS typed array into the destination
14114            /// Rust slice.
14115            ///
14116            /// This function will efficiently copy the memory from a typed
14117            /// array into this Wasm module's own linear memory, initializing
14118            /// the memory destination provided.
14119            ///
14120            /// # Panics
14121            ///
14122            /// This function will panic if this typed array's length is
14123            /// different than the length of the provided `dst` array.
14124            pub fn copy_to(&self, dst: &mut [$ty]) {
14125                core::assert_eq!(self.length() as usize, dst.len());
14126                $name::copy_to_slice(dst, self);
14127            }
14128
14129            /// Copy the contents of this JS typed array into the destination
14130            /// Rust slice.
14131            ///
14132            /// This function will efficiently copy the memory from a typed
14133            /// array into this Wasm module's own linear memory, initializing
14134            /// the memory destination provided.
14135            ///
14136            /// # Panics
14137            ///
14138            /// This function will panic if this typed array's length is
14139            /// different than the length of the provided `dst` array.
14140            pub fn copy_to_uninit<'dst>(&self, dst: &'dst mut [MaybeUninit<$ty>]) -> &'dst mut [$ty] {
14141                core::assert_eq!(self.length() as usize, dst.len());
14142                let dst = unsafe { &mut *(dst as *mut [MaybeUninit<$ty>] as *mut [$ty]) };
14143                self.copy_to(dst);
14144                dst
14145            }
14146
14147            /// Copy the contents of the source Rust slice into this
14148            /// JS typed array.
14149            ///
14150            /// This function will efficiently copy the memory from within
14151            /// the Wasm module's own linear memory to this typed array.
14152            ///
14153            /// # Panics
14154            ///
14155            /// This function will panic if this typed array's length is
14156            /// different than the length of the provided `src` array.
14157            pub fn copy_from(&self, src: &[$ty]) {
14158                core::assert_eq!(self.length() as usize, src.len());
14159                self.copy_from_slice(src);
14160            }
14161
14162            /// Efficiently copies the contents of this JS typed array into a new Vec.
14163            pub fn to_vec(&self) -> Vec<$ty> {
14164                let len = self.length() as usize;
14165                let mut output = Vec::with_capacity(len);
14166                // Safety: the capacity has been set
14167                unsafe {
14168                    self.raw_copy_to_ptr(output.as_mut_ptr());
14169                    output.set_len(len);
14170                }
14171                output
14172            }
14173        }
14174
14175        impl<'a> From<&'a [$ty]> for $name {
14176            #[inline]
14177            fn from(slice: &'a [$ty]) -> $name {
14178                // This is safe because the `new` function makes a copy if its argument is a TypedArray
14179                $name::new_from_slice(slice)
14180            }
14181        }
14182
14183        impl Default for $name {
14184            fn default() -> Self {
14185                Self::new(&JsValue::UNDEFINED.unchecked_into())
14186            }
14187        }
14188
14189        impl TypedArray for $name {}
14190
14191
14192    )*);
14193}
14194
14195arrays! {
14196    /// `Int8Array()`
14197    /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int8Array
14198    Int8Array: i8,
14199
14200    /// `Int16Array()`
14201    /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int16Array
14202    Int16Array: i16,
14203
14204    /// `Int32Array()`
14205    /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int32Array
14206    Int32Array: i32,
14207
14208    /// `Uint8Array()`
14209    /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array
14210    Uint8Array: u8,
14211
14212    /// `Uint8ClampedArray()`
14213    /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8ClampedArray
14214    Uint8ClampedArray: u8,
14215
14216    /// `Uint16Array()`
14217    /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint16Array
14218    Uint16Array: u16,
14219
14220    /// `Uint32Array()`
14221    /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint32Array
14222    Uint32Array: u32,
14223
14224    /// `Float32Array()`
14225    /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float32Array
14226    Float32Array: f32,
14227
14228    /// `Float64Array()`
14229    /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float64Array
14230    Float64Array: f64,
14231
14232    /// `BigInt64Array()`
14233    /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt64Array
14234    BigInt64Array: i64,
14235
14236    /// `BigUint64Array()`
14237    /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigUint64Array
14238    BigUint64Array: u64,
14239}
14240
14241/// Bridging between JavaScript `Promise`s and Rust `Future`s.
14242///
14243/// Enables `promise.await` directly on any [`Promise`].
14244/// This module is also re-exported by `wasm-bindgen-futures` for backwards compatibility.
14245pub mod futures;