Skip to main content

js_sys/
lib.rs

1//! Bindings to JavaScript's standard, built-in objects, including their methods
2//! and properties.
3//!
4//! This does *not* include any Web, Node, or any other JS environment
5//! APIs. Only the things that are guaranteed to exist in the global scope by
6//! the ECMAScript standard.
7//!
8//! <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects>
9//!
10//! ## A Note About `camelCase`, `snake_case`, and Naming Conventions
11//!
12//! JavaScript's global objects use `camelCase` naming conventions for functions
13//! and methods, but Rust style is to use `snake_case`. These bindings expose
14//! the Rust style `snake_case` name. Additionally, acronyms within a method
15//! name are all lower case, where as in JavaScript they are all upper case. For
16//! example, `decodeURI` in JavaScript is exposed as `decode_uri` in these
17//! bindings.
18//!
19//! ## A Note About `toString` and `to_js_string`
20//!
21//! JavaScript's `toString()` method is exposed as `to_js_string()` in these
22//! bindings to avoid confusion with Rust's [`ToString`] trait and its
23//! `to_string()` method. This allows types to implement both the Rust
24//! [`Display`](core::fmt::Display) trait (which provides `to_string()` via
25//! [`ToString`]) and still expose the JavaScript `toString()` functionality.
26
27#![doc(html_root_url = "https://docs.rs/js-sys/0.2")]
28#![cfg_attr(not(feature = "std"), no_std)]
29#![cfg_attr(target_feature = "atomics", feature(thread_local))]
30#![cfg_attr(target_feature = "atomics", feature(stdarch_wasm_atomic_wait))]
31
32extern crate alloc;
33
34use alloc::string::String;
35use alloc::vec::Vec;
36use core::cmp::Ordering;
37#[cfg(not(js_sys_unstable_apis))]
38use core::convert::Infallible;
39use core::convert::{self, TryFrom};
40use core::f64;
41use core::fmt;
42use core::iter::{self, Product, Sum};
43use core::marker::PhantomData;
44use core::mem::MaybeUninit;
45use core::ops::{Add, BitAnd, BitOr, BitXor, Div, Mul, Neg, Not, Rem, Shl, Shr, Sub};
46use core::str;
47use core::str::FromStr;
48pub use wasm_bindgen;
49use wasm_bindgen::closure::{ScopedClosure, WasmClosure};
50use wasm_bindgen::convert::{FromWasmAbi, IntoWasmAbi, Upcast, UpcastFrom};
51use wasm_bindgen::prelude::*;
52use wasm_bindgen::JsError;
53
54// Re-export sys types as js-sys types
55pub use wasm_bindgen::sys::{JsOption, Null, Promising, Undefined};
56pub use wasm_bindgen::{IntoJsGeneric, JsGeneric};
57
58// When adding new imports:
59//
60// * Keep imports in alphabetical order.
61//
62// * Rename imports with `js_name = ...` according to the note about `camelCase`
63//   and `snake_case` in the module's documentation above.
64//
65// * Include the one sentence summary of the import from the MDN link in the
66//   module's documentation above, and the MDN link itself.
67//
68// * If a function or method can throw an exception, make it catchable by adding
69//   `#[wasm_bindgen(catch)]`.
70//
71// * Add a new `#[test]` into the appropriate file in the
72//   `crates/js-sys/tests/wasm/` directory. If the imported function or method
73//   can throw an exception, make sure to also add test coverage for that case.
74//
75// * Arguments that are `JsValue`s or imported JavaScript types should be taken
76//   by reference.
77//
78// * Name JavaScript's `toString()` method as `to_js_string()` to avoid conflict
79//   with Rust's `ToString` trait.
80
81macro_rules! forward_deref_unop {
82    (impl $imp:ident, $method:ident for $t:ty) => {
83        impl $imp for $t {
84            type Output = <&'static $t as $imp>::Output;
85
86            #[inline]
87            fn $method(self) -> Self::Output {
88                $imp::$method(&self)
89            }
90        }
91    };
92    (impl<$($gen:ident),+> $imp:ident, $method:ident for $t:ty) => {
93        impl<$($gen),+> $imp for $t {
94            type Output = <&'static $t as $imp>::Output;
95
96            #[inline]
97            fn $method(self) -> Self::Output {
98                $imp::$method(&self)
99            }
100        }
101    };
102}
103
104macro_rules! forward_deref_binop {
105    (impl $imp:ident, $method:ident for $t:ty) => {
106        impl<'a> $imp<$t> for &'a $t {
107            type Output = <&'static $t as $imp<&'static $t>>::Output;
108
109            #[inline]
110            fn $method(self, other: $t) -> Self::Output {
111                $imp::$method(self, &other)
112            }
113        }
114
115        impl $imp<&$t> for $t {
116            type Output = <&'static $t as $imp<&'static $t>>::Output;
117
118            #[inline]
119            fn $method(self, other: &$t) -> Self::Output {
120                $imp::$method(&self, other)
121            }
122        }
123
124        impl $imp<$t> for $t {
125            type Output = <&'static $t as $imp<&'static $t>>::Output;
126
127            #[inline]
128            fn $method(self, other: $t) -> Self::Output {
129                $imp::$method(&self, &other)
130            }
131        }
132    };
133    (impl<$($gen:ident),+> $imp:ident, $method:ident for $t:ty) => {
134        impl<'a, $($gen),+> $imp<$t> for &'a $t {
135            type Output = <&'static $t as $imp<&'static $t>>::Output;
136
137            #[inline]
138            fn $method(self, other: $t) -> Self::Output {
139                $imp::$method(self, &other)
140            }
141        }
142
143        impl<$($gen),+> $imp<&$t> for $t {
144            type Output = <&'static $t as $imp<&'static $t>>::Output;
145
146            #[inline]
147            fn $method(self, other: &$t) -> Self::Output {
148                $imp::$method(&self, other)
149            }
150        }
151
152        impl<$($gen),+> $imp<$t> for $t {
153            type Output = <&'static $t as $imp<&'static $t>>::Output;
154
155            #[inline]
156            fn $method(self, other: $t) -> Self::Output {
157                $imp::$method(&self, &other)
158            }
159        }
160    };
161}
162
163macro_rules! forward_js_unop {
164    (impl $imp:ident, $method:ident for $t:ty) => {
165        impl $imp for &$t {
166            type Output = $t;
167
168            #[inline]
169            fn $method(self) -> Self::Output {
170                $imp::$method(JsValue::as_ref(self)).unchecked_into()
171            }
172        }
173
174        forward_deref_unop!(impl $imp, $method for $t);
175    };
176    (impl<$($gen:ident),+> $imp:ident, $method:ident for $t:ty) => {
177        impl<$($gen),+> $imp for &$t {
178            type Output = $t;
179
180            #[inline]
181            fn $method(self) -> Self::Output {
182                $imp::$method(JsValue::as_ref(self)).unchecked_into()
183            }
184        }
185
186        forward_deref_unop!(impl<$($gen),+> $imp, $method for $t);
187    };
188}
189
190macro_rules! forward_js_binop {
191    (impl $imp:ident, $method:ident for $t:ty) => {
192        impl $imp<&$t> for &$t {
193            type Output = $t;
194
195            #[inline]
196            fn $method(self, other: &$t) -> Self::Output {
197                $imp::$method(JsValue::as_ref(self), JsValue::as_ref(other)).unchecked_into()
198            }
199        }
200
201        forward_deref_binop!(impl $imp, $method for $t);
202    };
203    (impl<$($gen:ident),+> $imp:ident, $method:ident for $t:ty) => {
204        impl<$($gen),+> $imp<&$t> for &$t {
205            type Output = $t;
206
207            #[inline]
208            fn $method(self, other: &$t) -> Self::Output {
209                $imp::$method(JsValue::as_ref(self), JsValue::as_ref(other)).unchecked_into()
210            }
211        }
212
213        forward_deref_binop!(impl<$($gen),+> $imp, $method for $t);
214    };
215}
216
217macro_rules! sum_product {
218    ($($a:ident)*) => ($(
219        impl Sum for $a {
220            #[inline]
221            fn sum<I: iter::Iterator<Item=Self>>(iter: I) -> Self {
222                iter.fold(
223                    $a::from(0),
224                    |a, b| a + b,
225                )
226            }
227        }
228
229        impl Product for $a {
230            #[inline]
231            fn product<I: iter::Iterator<Item=Self>>(iter: I) -> Self {
232                iter.fold(
233                    $a::from(1),
234                    |a, b| a * b,
235                )
236            }
237        }
238
239        impl<'a> Sum<&'a $a> for $a {
240            fn sum<I: iter::Iterator<Item=&'a Self>>(iter: I) -> Self {
241                iter.fold(
242                    $a::from(0),
243                    |a, b| a + b,
244                )
245            }
246        }
247
248        impl<'a> Product<&'a $a> for $a {
249            #[inline]
250            fn product<I: iter::Iterator<Item=&'a Self>>(iter: I) -> Self {
251                iter.fold(
252                    $a::from(1),
253                    |a, b| a * b,
254                )
255            }
256        }
257    )*);
258    // Generic variant: impl<T> for Type<T>
259    (impl<$gen:ident> $a:ident<$g2:ident>) => {
260        impl<$gen> Sum for $a<$g2>
261        where
262            $a<$g2>: From<$gen>,
263            $g2: From<u32>
264        {
265            #[inline]
266            fn sum<I: iter::Iterator<Item=Self>>(iter: I) -> Self {
267                iter.fold(
268                    $a::from($g2::from(0)),
269                    |a, b| a + b,
270                )
271            }
272        }
273
274        impl<$gen> Product for $a<$g2>
275        where
276            $a<$g2>: From<$gen>,
277            $g2: From<u32>
278        {
279            #[inline]
280            fn product<I: iter::Iterator<Item=Self>>(iter: I) -> Self {
281                iter.fold(
282                    $a::from($g2::from(1)),
283                    |a, b| a * b,
284                )
285            }
286        }
287
288        impl<'a, $gen> Sum<&'a $a<$g2>> for $a<$g2>
289        where
290            $a<$g2>: From<$gen>,
291            $g2: From<u32>
292        {
293            fn sum<I: iter::Iterator<Item=&'a Self>>(iter: I) -> Self {
294                iter.fold(
295                    $a::from($g2::from(0)),
296                    |a, b| a + b,
297                )
298            }
299        }
300
301        impl<'a, $gen> Product<&'a $a<$g2>> for $a<$g2>
302        where
303            $a<$g2>: From<$gen>,
304            $g2: From<u32>
305        {
306            #[inline]
307            fn product<I: iter::Iterator<Item=&'a Self>>(iter: I) -> Self {
308                iter.fold(
309                    $a::from($g2::from(1)),
310                    |a, b| a * b,
311                )
312            }
313        }
314    };
315}
316
317macro_rules! partialord_ord {
318    ($t:ident) => {
319        impl PartialOrd for $t {
320            #[inline]
321            fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
322                Some(self.cmp(other))
323            }
324
325            #[inline]
326            fn lt(&self, other: &Self) -> bool {
327                JsValue::as_ref(self).lt(JsValue::as_ref(other))
328            }
329
330            #[inline]
331            fn le(&self, other: &Self) -> bool {
332                JsValue::as_ref(self).le(JsValue::as_ref(other))
333            }
334
335            #[inline]
336            fn ge(&self, other: &Self) -> bool {
337                JsValue::as_ref(self).ge(JsValue::as_ref(other))
338            }
339
340            #[inline]
341            fn gt(&self, other: &Self) -> bool {
342                JsValue::as_ref(self).gt(JsValue::as_ref(other))
343            }
344        }
345
346        impl Ord for $t {
347            #[inline]
348            fn cmp(&self, other: &Self) -> Ordering {
349                if self == other {
350                    Ordering::Equal
351                } else if self.lt(other) {
352                    Ordering::Less
353                } else {
354                    Ordering::Greater
355                }
356            }
357        }
358    };
359}
360
361#[wasm_bindgen]
362extern "C" {
363    /// The `decodeURI()` function decodes a Uniform Resource Identifier (URI)
364    /// previously created by `encodeURI` or by a similar routine.
365    ///
366    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURI)
367    #[wasm_bindgen(catch, js_name = decodeURI)]
368    pub fn decode_uri(encoded: &str) -> Result<JsString, JsValue>;
369
370    /// The `decodeURIComponent()` function decodes a Uniform Resource Identifier (URI) component
371    /// previously created by `encodeURIComponent` or by a similar routine.
372    ///
373    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent)
374    #[wasm_bindgen(catch, js_name = decodeURIComponent)]
375    pub fn decode_uri_component(encoded: &str) -> Result<JsString, JsValue>;
376
377    /// The `encodeURI()` function encodes a Uniform Resource Identifier (URI)
378    /// by replacing each instance of certain characters by one, two, three, or
379    /// four escape sequences representing the UTF-8 encoding of the character
380    /// (will only be four escape sequences for characters composed of two
381    /// "surrogate" characters).
382    ///
383    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI)
384    #[wasm_bindgen(js_name = encodeURI)]
385    pub fn encode_uri(decoded: &str) -> JsString;
386
387    /// The `encodeURIComponent()` function encodes a Uniform Resource Identifier (URI) component
388    /// by replacing each instance of certain characters by one, two, three, or four escape sequences
389    /// representing the UTF-8 encoding of the character
390    /// (will only be four escape sequences for characters composed of two "surrogate" characters).
391    ///
392    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent)
393    #[wasm_bindgen(js_name = encodeURIComponent)]
394    pub fn encode_uri_component(decoded: &str) -> JsString;
395
396    /// The `eval()` function evaluates JavaScript code represented as a string.
397    ///
398    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval)
399    #[cfg(feature = "unsafe-eval")]
400    #[wasm_bindgen(catch)]
401    pub fn eval(js_source_text: &str) -> Result<JsValue, JsValue>;
402
403    /// The global `isFinite()` function determines whether the passed value is a finite number.
404    /// If needed, the parameter is first converted to a number.
405    ///
406    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/isFinite)
407    #[wasm_bindgen(js_name = isFinite)]
408    pub fn is_finite(value: &JsValue) -> bool;
409
410    /// The `parseInt()` function parses a string argument and returns an integer
411    /// of the specified radix (the base in mathematical numeral systems), or NaN on error.
412    ///
413    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt)
414    #[wasm_bindgen(js_name = parseInt)]
415    pub fn parse_int(text: &str, radix: u8) -> f64;
416
417    /// The `parseFloat()` function parses an argument and returns a floating point number,
418    /// or NaN on error.
419    ///
420    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseFloat)
421    #[wasm_bindgen(js_name = parseFloat)]
422    pub fn parse_float(text: &str) -> f64;
423
424    /// The `escape()` function computes a new string in which certain characters have been
425    /// replaced by a hexadecimal escape sequence.
426    ///
427    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/escape)
428    #[wasm_bindgen]
429    pub fn escape(string: &str) -> JsString;
430
431    /// The `unescape()` function computes a new string in which hexadecimal escape
432    /// sequences are replaced with the character that it represents. The escape sequences might
433    /// be introduced by a function like `escape`. Usually, `decodeURI` or `decodeURIComponent`
434    /// are preferred over `unescape`.
435    ///
436    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/unescape)
437    #[wasm_bindgen]
438    pub fn unescape(string: &str) -> JsString;
439}
440
441// AggregateError
442#[wasm_bindgen]
443extern "C" {
444    /// The `AggregateError` object represents an error when several errors need
445    /// to be wrapped in a single error. It is thrown when multiple errors need
446    /// to be reported by an operation, for example by [`Promise::any`], when
447    /// all promises passed to it reject.
448    ///
449    /// `AggregateError` is a subclass of [`Error`].
450    ///
451    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AggregateError)
452    #[wasm_bindgen(extends = Error, extends = Object, typescript_type = "AggregateError")]
453    #[derive(Clone, Debug, PartialEq, Eq)]
454    pub type AggregateError;
455
456    /// Creates a new `AggregateError` from the given iterable of errors.
457    ///
458    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AggregateError/AggregateError)
459    #[wasm_bindgen(constructor)]
460    pub fn new(errors: &[JsValue]) -> AggregateError;
461
462    /// Creates a new `AggregateError` from the given iterable of errors with a
463    /// human-readable description of the aggregate error.
464    ///
465    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AggregateError/AggregateError)
466    #[wasm_bindgen(constructor)]
467    pub fn new_with_message(errors: &[JsValue], message: &str) -> AggregateError;
468
469    /// Creates a new `AggregateError` from the given iterable of errors, a
470    /// human-readable description of the aggregate error, and an
471    /// [`ErrorOptions`] dictionary whose `cause` property indicates the
472    /// original cause of the error.
473    ///
474    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AggregateError/AggregateError)
475    #[wasm_bindgen(constructor)]
476    pub fn new_with_options(
477        errors: &[JsValue],
478        message: &str,
479        options: &ErrorOptions,
480    ) -> AggregateError;
481
482    /// The `errors` property of an `AggregateError` instance is an array
483    /// representing the errors that were aggregated.
484    ///
485    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AggregateError/errors)
486    #[wasm_bindgen(method, getter)]
487    pub fn errors(this: &AggregateError) -> Array;
488}
489
490// ErrorOptions
491#[wasm_bindgen]
492extern "C" {
493    /// The options dictionary accepted as the second argument to the
494    /// [`Error`] constructor (and other built-in error constructors such as
495    /// [`AggregateError`]). Its sole standard property is `cause`, which
496    /// indicates the original cause of the error.
497    ///
498    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/Error)
499    #[wasm_bindgen(extends = Object, typescript_type = "ErrorOptions")]
500    #[derive(Clone, Debug, PartialEq, Eq)]
501    pub type ErrorOptions;
502
503    /// The `cause` property indicates the underlying cause of an error.
504    ///
505    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause)
506    #[wasm_bindgen(method, getter = "cause")]
507    pub fn get_cause(this: &ErrorOptions) -> JsValue;
508
509    /// Sets the `cause` property of this `ErrorOptions` dictionary.
510    ///
511    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause)
512    #[wasm_bindgen(method, setter = "cause")]
513    pub fn set_cause(this: &ErrorOptions, cause: &JsValue);
514}
515
516impl ErrorOptions {
517    /// Construct a new `ErrorOptions` dictionary with the given `cause`.
518    pub fn new(cause: &JsValue) -> Self {
519        let ret: Self = ::wasm_bindgen::JsCast::unchecked_into(Object::new());
520        ret.set_cause(cause);
521        ret
522    }
523}
524
525// Array
526#[wasm_bindgen]
527extern "C" {
528    #[wasm_bindgen(extends = Object, is_type_of = Array::is_array, typescript_type = "Array<any>")]
529    #[derive(Clone, Debug, PartialEq, Eq)]
530    pub type Array<T = JsValue>;
531
532    /// Creates a new empty array.
533    ///
534    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Array)
535    #[cfg(not(js_sys_unstable_apis))]
536    #[wasm_bindgen(constructor)]
537    pub fn new() -> Array;
538
539    /// Creates a new empty array.
540    ///
541    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Array)
542    #[cfg(js_sys_unstable_apis)]
543    #[wasm_bindgen(constructor)]
544    pub fn new<T>() -> Array<T>;
545
546    // Next major: deprecate
547    /// Creates a new empty array.
548    ///
549    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Array)
550    #[wasm_bindgen(constructor)]
551    pub fn new_typed<T>() -> Array<T>;
552
553    /// Creates a new array with the specified length (elements are initialized to `undefined`).
554    ///
555    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Array)
556    #[cfg(not(js_sys_unstable_apis))]
557    #[wasm_bindgen(constructor)]
558    pub fn new_with_length(len: u32) -> Array;
559
560    /// Creates a new array with the specified length (elements are initialized to `undefined`).
561    ///
562    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Array)
563    #[cfg(js_sys_unstable_apis)]
564    #[wasm_bindgen(constructor)]
565    pub fn new_with_length<T>(len: u32) -> Array<T>;
566
567    // Next major: deprecate
568    /// Creates a new array with the specified length (elements are initialized to `undefined`).
569    ///
570    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Array)
571    #[wasm_bindgen(constructor)]
572    pub fn new_with_length_typed<T>(len: u32) -> Array<T>;
573
574    /// Retrieves the element at the index, counting from the end if negative
575    /// (returns `undefined` if the index is out of range).
576    ///
577    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at)
578    #[cfg(not(js_sys_unstable_apis))]
579    #[wasm_bindgen(method)]
580    pub fn at<T>(this: &Array<T>, index: i32) -> T;
581
582    /// Retrieves the element at the index, counting from the end if negative
583    /// (returns `None` if the index is out of range).
584    ///
585    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at)
586    #[cfg(js_sys_unstable_apis)]
587    #[wasm_bindgen(method)]
588    pub fn at<T>(this: &Array<T>, index: i32) -> Option<T>;
589
590    /// Retrieves the element at the index (returns `undefined` if the index is out of range).
591    ///
592    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at)
593    #[cfg(not(js_sys_unstable_apis))]
594    #[wasm_bindgen(method, indexing_getter)]
595    pub fn get<T>(this: &Array<T>, index: u32) -> T;
596
597    /// Retrieves the element at the index (returns `None` if the index is out of range).
598    ///
599    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at)
600    #[cfg(js_sys_unstable_apis)]
601    #[wasm_bindgen(method, indexing_getter)]
602    pub fn get<T>(this: &Array<T>, index: u32) -> Option<T>;
603
604    /// Retrieves the element at the index (returns `undefined` if the index is out of range).
605    ///
606    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at)
607    #[wasm_bindgen(method, indexing_getter)]
608    pub fn get_unchecked<T>(this: &Array<T>, index: u32) -> T;
609
610    // Next major: deprecate
611    /// Retrieves the element at the index (returns `None` if the index is out of range,
612    /// or if the element is explicitly `undefined`).
613    #[wasm_bindgen(method, indexing_getter)]
614    pub fn get_checked<T>(this: &Array<T>, index: u32) -> Option<T>;
615
616    /// Sets the element at the index (auto-enlarges the array if the index is out of range).
617    #[cfg(not(js_sys_unstable_apis))]
618    #[wasm_bindgen(method, indexing_setter)]
619    pub fn set<T>(this: &Array<T>, index: u32, value: T);
620
621    /// Sets the element at the index (auto-enlarges the array if the index is out of range).
622    #[cfg(js_sys_unstable_apis)]
623    #[wasm_bindgen(method, indexing_setter)]
624    pub fn set<T>(this: &Array<T>, index: u32, value: &T);
625
626    // Next major: deprecate
627    /// Sets the element at the index (auto-enlarges the array if the index is out of range).
628    #[wasm_bindgen(method, indexing_setter)]
629    pub fn set_ref<T>(this: &Array<T>, index: u32, value: &T);
630
631    /// Deletes the element at the index (does nothing if the index is out of range).
632    ///
633    /// The element at the index is set to `undefined`.
634    ///
635    /// This does not resize the array, the array will still be the same length.
636    #[wasm_bindgen(method, indexing_deleter)]
637    pub fn delete<T>(this: &Array<T>, index: u32);
638
639    /// The `Array.from()` static method creates a new, shallow-copied `Array` instance
640    /// from an array-like or iterable object.
641    ///
642    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from)
643    #[cfg(not(js_sys_unstable_apis))]
644    #[wasm_bindgen(static_method_of = Array)]
645    pub fn from(val: &JsValue) -> Array;
646
647    /// The `Array.from()` static method creates a new, shallow-copied `Array` instance
648    /// from an array-like or iterable object.
649    ///
650    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from)
651    #[cfg(js_sys_unstable_apis)]
652    #[wasm_bindgen(static_method_of = Array, catch, js_name = from)]
653    pub fn from<I: Iterable>(val: &I) -> Result<Array<I::Item>, JsValue>;
654
655    // Next major: deprecate
656    /// The `Array.from()` static method creates a new, shallow-copied `Array` instance
657    /// from an array-like or iterable object.
658    ///
659    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from)
660    #[wasm_bindgen(static_method_of = Array, catch, js_name = from)]
661    pub fn from_iterable<I: Iterable>(val: &I) -> Result<Array<I::Item>, JsValue>;
662
663    /// The `Array.from()` static method with a map function creates a new, shallow-copied
664    /// `Array` instance from an array-like or iterable object, applying the map function
665    /// to each value.
666    ///
667    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from)
668    #[wasm_bindgen(static_method_of = Array, catch, js_name = from)]
669    pub fn from_iterable_map<I: Iterable, U>(
670        val: &I,
671        map: &mut dyn FnMut(I::Item, u32) -> Result<U, JsError>,
672    ) -> Result<Array<U>, JsValue>;
673
674    /// The `Array.fromAsync()` static method creates a new, shallow-copied `Array` instance
675    /// from an async iterable, iterable or array-like object.
676    ///
677    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fromAsync)
678    #[wasm_bindgen(static_method_of = Array, catch, js_name = fromAsync)]
679    pub fn from_async<I: AsyncIterable>(val: &I) -> Result<Promise<Array<I::Item>>, JsValue>;
680
681    /// The `Array.fromAsync()` static method with a map function creates a new, shallow-copied
682    /// `Array` instance from an async iterable, iterable or array-like object, applying the map
683    /// function to each value.
684    ///
685    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fromAsync)
686    #[wasm_bindgen(static_method_of = Array, catch, js_name = fromAsync)]
687    pub fn from_async_map<'a, I: AsyncIterable, R: Promising>(
688        val: &I,
689        map: &ScopedClosure<'a, dyn FnMut(I::Item, u32) -> Result<R, JsError>>,
690    ) -> Result<Promise<Array<R::Resolution>>, JsValue>;
691
692    /// The `copyWithin()` method shallow copies part of an array to another
693    /// location in the same array and returns it, without modifying its size.
694    ///
695    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin)
696    #[wasm_bindgen(method, js_name = copyWithin)]
697    pub fn copy_within<T>(this: &Array<T>, target: i32, start: i32, end: i32) -> Array<T>;
698
699    /// The `concat()` method is used to merge two or more arrays. This method
700    /// does not change the existing arrays, but instead returns a new array.
701    ///
702    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat)
703    #[wasm_bindgen(method)]
704    pub fn concat<T, U: Upcast<T>>(this: &Array<T>, array: &Array<U>) -> Array<T>;
705
706    /// The `concat()` method is used to merge two or more arrays. This method
707    /// does not change the existing arrays, but instead returns a new array.
708    ///
709    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat)
710    #[wasm_bindgen(method)]
711    pub fn concat_many<T, U: Upcast<T>>(this: &Array<T>, array: &[Array<U>]) -> Array<T>;
712
713    /// The `every()` method tests whether all elements in the array pass the test
714    /// implemented by the provided function.
715    ///
716    /// **Note:** Consider using [`Array::try_every`] if the predicate might throw an error.
717    ///
718    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every)
719    #[wasm_bindgen(method)]
720    pub fn every<T>(this: &Array<T>, predicate: &mut dyn FnMut(T, u32, Array<T>) -> bool) -> bool;
721
722    /// The `every()` method tests whether all elements in the array pass the test
723    /// implemented by the provided function. _(Fallible variation)_
724    ///
725    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every)
726    #[wasm_bindgen(method, js_name = every, catch)]
727    pub fn try_every<T>(
728        this: &Array<T>,
729        predicate: &mut dyn FnMut(T, u32) -> Result<bool, JsError>,
730    ) -> Result<bool, JsValue>;
731
732    /// The `fill()` method fills all the elements of an array from a start index
733    /// to an end index with a static value. The end index is not included.
734    ///
735    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fill)
736    #[wasm_bindgen(method)]
737    pub fn fill<T>(this: &Array<T>, value: &T, start: u32, end: u32) -> Array<T>;
738
739    /// The `filter()` method creates a new array with all elements that pass the
740    /// test implemented by the provided function.
741    ///
742    /// **Note:** Consider using [`Array::try_filter`] if the predicate might throw an error.
743    ///
744    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter)
745    #[wasm_bindgen(method)]
746    pub fn filter<T>(
747        this: &Array<T>,
748        predicate: &mut dyn FnMut(T, u32, Array<T>) -> bool,
749    ) -> Array<T>;
750
751    /// The `filter()` method creates a new array with all elements that pass the
752    /// test implemented by the provided function. _(Fallible variation)_
753    ///
754    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter)
755    #[wasm_bindgen(method, js_name = filter, catch)]
756    pub fn try_filter<T>(
757        this: &Array<T>,
758        predicate: &mut dyn FnMut(T, u32) -> Result<bool, JsError>,
759    ) -> Result<Array<T>, JsValue>;
760
761    /// The `find()` method returns the value of the first element in the array that satisfies
762    /// the provided testing function. Otherwise `undefined` is returned.
763    ///
764    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find)
765    #[cfg(not(js_sys_unstable_apis))]
766    #[wasm_bindgen(method)]
767    pub fn find<T>(this: &Array<T>, predicate: &mut dyn FnMut(T, u32, Array<T>) -> bool) -> T;
768
769    /// The `find()` method returns the value of the first element in the array that satisfies
770    /// the provided testing function. Returns `None` if no element matches.
771    ///
772    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find)
773    #[cfg(js_sys_unstable_apis)]
774    #[wasm_bindgen(method)]
775    pub fn find<T>(
776        this: &Array<T>,
777        predicate: &mut dyn FnMut(T, u32, Array<T>) -> bool,
778    ) -> Option<T>;
779
780    /// The `find()` method returns the value of the first element in the array that satisfies
781    ///  the provided testing function. Otherwise `undefined` is returned. _(Fallible variation)_
782    ///
783    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find)
784    #[wasm_bindgen(method, js_name = find, catch)]
785    pub fn try_find<T>(
786        this: &Array<T>,
787        predicate: &mut dyn FnMut(T, u32) -> Result<bool, JsError>,
788    ) -> Result<Option<T>, JsValue>;
789
790    /// The `findIndex()` method returns the index of the first element in the array that
791    /// satisfies the provided testing function. Otherwise -1 is returned.
792    ///
793    /// **Note:** Consider using [`Array::try_find_index`] if the predicate might throw an error.
794    ///
795    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex)
796    #[wasm_bindgen(method, js_name = findIndex)]
797    pub fn find_index<T>(
798        this: &Array<T>,
799        predicate: &mut dyn FnMut(T, u32, Array<T>) -> bool,
800    ) -> i32;
801
802    /// The `findIndex()` method returns the index of the first element in the array that
803    /// satisfies the provided testing function. Otherwise -1 is returned. _(Fallible variation)_
804    ///
805    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex)
806    #[wasm_bindgen(method, js_name = findIndex, catch)]
807    pub fn try_find_index<T>(
808        this: &Array<T>,
809        predicate: &mut dyn FnMut(T, u32) -> Result<bool, JsError>,
810    ) -> Result<i32, JsValue>;
811
812    /// The `findLast()` method of Array instances iterates the array in reverse order
813    /// and returns the value of the first element that satisfies the provided testing function.
814    /// If no elements satisfy the testing function, undefined is returned.
815    ///
816    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findLast)
817    #[cfg(not(js_sys_unstable_apis))]
818    #[wasm_bindgen(method, js_name = findLast)]
819    pub fn find_last<T>(this: &Array<T>, predicate: &mut dyn FnMut(T, u32, Array<T>) -> bool) -> T;
820
821    /// The `findLast()` method of Array instances iterates the array in reverse order
822    /// and returns the value of the first element that satisfies the provided testing function.
823    /// Returns `None` if no element matches.
824    ///
825    /// **Note:** Consider using [`Array::try_find_last`] if the predicate might throw an error.
826    ///
827    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findLast)
828    #[cfg(js_sys_unstable_apis)]
829    #[wasm_bindgen(method, js_name = findLast)]
830    pub fn find_last<T>(this: &Array<T>, predicate: &mut dyn FnMut(T, u32) -> bool) -> Option<T>;
831
832    /// The `findLast()` method of Array instances iterates the array in reverse order
833    /// and returns the value of the first element that satisfies the provided testing function.
834    /// If no elements satisfy the testing function, undefined is returned. _(Fallible variation)_
835    ///
836    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findLast)
837    #[wasm_bindgen(method, js_name = findLast, catch)]
838    pub fn try_find_last<T>(
839        this: &Array<T>,
840        predicate: &mut dyn FnMut(T, u32) -> Result<bool, JsError>,
841    ) -> Result<Option<T>, JsValue>;
842
843    /// The `findLastIndex()` method of Array instances iterates the array in reverse order
844    /// and returns the index of the first element that satisfies the provided testing function.
845    /// If no elements satisfy the testing function, -1 is returned.
846    ///
847    /// **Note:** Consider using [`Array::try_find_last_index`] if the predicate might throw an error.
848    ///
849    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findLastIndex)
850    #[wasm_bindgen(method, js_name = findLastIndex)]
851    pub fn find_last_index<T>(
852        this: &Array<T>,
853        predicate: &mut dyn FnMut(T, u32, Array<T>) -> bool,
854    ) -> i32;
855
856    /// The `findLastIndex()` method of Array instances iterates the array in reverse order
857    /// and returns the index of the first element that satisfies the provided testing function.
858    /// If no elements satisfy the testing function, -1 is returned. _(Fallible variation)_
859    ///
860    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findLastIndex)
861    #[wasm_bindgen(method, js_name = findLastIndex, catch)]
862    pub fn try_find_last_index<T>(
863        this: &Array<T>,
864        predicate: &mut dyn FnMut(T, u32) -> Result<bool, JsError>,
865    ) -> Result<i32, JsValue>;
866
867    /// The `flat()` method creates a new array with all sub-array elements concatenated into it
868    /// recursively up to the specified depth.
869    ///
870    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat)
871    #[wasm_bindgen(method)]
872    pub fn flat<T>(this: &Array<T>, depth: i32) -> Array<JsValue>;
873
874    /// The `flatMap()` method first maps each element using a mapping function, then flattens
875    /// the result into a new array.
876    ///
877    /// **Note:** Consider using [`Array::try_flat_map`] for safer fallible handling.
878    ///
879    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap)
880    #[wasm_bindgen(method, js_name = flatMap)]
881    pub fn flat_map<T, U>(
882        this: &Array<T>,
883        callback: &mut dyn FnMut(T, u32, Array<T>) -> Vec<U>,
884    ) -> Array<U>;
885
886    /// The `flatMap()` method first maps each element using a mapping function, then flattens
887    /// the result into a new array.
888    ///
889    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap)
890    #[wasm_bindgen(method, js_name = flatMap, catch)]
891    pub fn try_flat_map<T, U>(
892        this: &Array<T>,
893        callback: &mut dyn FnMut(T, u32) -> Vec<U>,
894    ) -> Result<Array<U>, JsValue>;
895
896    /// The `forEach()` method executes a provided function once for each array element.
897    ///
898    /// **Note:** Consider using [`Array::try_for_each`] if the callback might throw an error.
899    ///
900    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach)
901    #[wasm_bindgen(method, js_name = forEach)]
902    pub fn for_each<T: JsGeneric>(this: &Array<T>, callback: &mut dyn FnMut(T, u32, Array<T>));
903
904    /// The `forEach()` method executes a provided function once for each array element. _(Fallible variation)_
905    ///
906    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach)
907    #[wasm_bindgen(method, js_name = forEach, catch)]
908    pub fn try_for_each<T>(
909        this: &Array<T>,
910        callback: &mut dyn FnMut(T, u32) -> Result<(), JsError>,
911    ) -> Result<(), JsValue>;
912
913    /// The `includes()` method determines whether an array includes a certain
914    /// element, returning true or false as appropriate.
915    ///
916    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes)
917    #[wasm_bindgen(method)]
918    pub fn includes<T>(this: &Array<T>, value: &T, from_index: i32) -> bool;
919
920    /// The `indexOf()` method returns the first index at which a given element
921    /// can be found in the array, or -1 if it is not present.
922    ///
923    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf)
924    #[wasm_bindgen(method, js_name = indexOf)]
925    pub fn index_of<T>(this: &Array<T>, value: &T, from_index: i32) -> i32;
926
927    /// The `Array.isArray()` method determines whether the passed value is an Array.
928    ///
929    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray)
930    #[wasm_bindgen(static_method_of = Array, js_name = isArray)]
931    pub fn is_array(value: &JsValue) -> bool;
932
933    /// The `join()` method joins all elements of an array (or an array-like object)
934    /// into a string and returns this string.
935    ///
936    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join)
937    #[wasm_bindgen(method)]
938    pub fn join<T>(this: &Array<T>, delimiter: &str) -> JsString;
939
940    /// The `lastIndexOf()` method returns the last index at which a given element
941    /// can be found in the array, or -1 if it is not present. The array is
942    /// searched backwards, starting at fromIndex.
943    ///
944    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf)
945    #[wasm_bindgen(method, js_name = lastIndexOf)]
946    pub fn last_index_of<T>(this: &Array<T>, value: &T, from_index: i32) -> i32;
947
948    /// The length property of an object which is an instance of type Array
949    /// sets or returns the number of elements in that array. The value is an
950    /// unsigned, 32-bit integer that is always numerically greater than the
951    /// highest index in the array.
952    ///
953    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/length)
954    #[wasm_bindgen(method, getter)]
955    pub fn length<T>(this: &Array<T>) -> u32;
956
957    /// Sets the length of the array.
958    ///
959    /// If it is set to less than the current length of the array, it will
960    /// shrink the array.
961    ///
962    /// If it is set to more than the current length of the array, it will
963    /// increase the length of the array, filling the new space with empty
964    /// slots.
965    ///
966    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/length)
967    #[wasm_bindgen(method, setter)]
968    pub fn set_length<T>(this: &Array<T>, value: u32);
969
970    /// `map()` calls a provided callback function once for each element in an array,
971    /// in order, and constructs a new array from the results. callback is invoked
972    /// only for indexes of the array which have assigned values, including undefined.
973    /// It is not called for missing elements of the array (that is, indexes that have
974    /// never been set, which have been deleted or which have never been assigned a value).
975    ///
976    /// **Note:** Consider using [`Array::try_map`] for safer fallible handling.
977    ///
978    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map)
979    #[wasm_bindgen(method)]
980    pub fn map<T, U>(this: &Array<T>, predicate: &mut dyn FnMut(T, u32, Array<T>) -> U)
981        -> Array<U>;
982
983    /// `map()` calls a provided callback function once for each element in an array,
984    /// in order, and constructs a new array from the results. callback is invoked
985    /// only for indexes of the array which have assigned values, including undefined.
986    /// It is not called for missing elements of the array (that is, indexes that have
987    /// never been set, which have been deleted or which have never been assigned a value).
988    /// _(Fallible variation)_
989    ///
990    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map)
991    #[wasm_bindgen(method, js_name = map, catch)]
992    pub fn try_map<T, U>(
993        this: &Array<T>,
994        predicate: &mut dyn FnMut(T, u32) -> Result<U, JsError>,
995    ) -> Result<Array<U>, JsValue>;
996
997    /// The `Array.of()` method creates a new Array instance with a variable
998    /// number of arguments, regardless of number or type of the arguments.
999    ///
1000    /// Note: For type inference use `Array::<T>::of(&[T])`.
1001    ///
1002    /// The difference between `Array.of()` and the `Array` constructor is in the
1003    /// handling of integer arguments: `Array.of(7)` creates an array with a single
1004    /// element, `7`, whereas `Array(7)` creates an empty array with a `length`
1005    /// property of `7` (Note: this implies an array of 7 empty slots, not slots
1006    /// with actual undefined values).
1007    ///
1008    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/of)
1009    #[wasm_bindgen(static_method_of = Array, js_name = of, variadic)]
1010    pub fn of<T>(values: &[T]) -> Array<T>;
1011
1012    // Next major: deprecate these
1013    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/of)
1014    #[wasm_bindgen(static_method_of = Array, js_name = of)]
1015    pub fn of1(a: &JsValue) -> Array;
1016
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 of2(a: &JsValue, b: &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 of3(a: &JsValue, b: &JsValue, c: &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 of4(a: &JsValue, b: &JsValue, c: &JsValue, d: &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 of5(a: &JsValue, b: &JsValue, c: &JsValue, d: &JsValue, e: &JsValue) -> Array;
1032
1033    /// The `pop()` method removes the last element from an array and returns that
1034    /// element. This method changes the length of the array.
1035    ///
1036    /// **Note:** Consider using [`Array::pop_checked`] for handling empty arrays.
1037    ///
1038    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/pop)
1039    #[cfg(not(js_sys_unstable_apis))]
1040    #[wasm_bindgen(method)]
1041    pub fn pop<T>(this: &Array<T>) -> T;
1042
1043    /// The `pop()` method removes the last element from an array and returns that
1044    /// element. This method changes the length of the array.
1045    /// Returns `None` if the array is empty.
1046    ///
1047    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/pop)
1048    #[cfg(js_sys_unstable_apis)]
1049    #[wasm_bindgen(method)]
1050    pub fn pop<T>(this: &Array<T>) -> Option<T>;
1051
1052    // Next major: deprecate
1053    /// The `pop()` method removes the last element from an array and returns that
1054    /// element. This method changes the length of the array.
1055    ///
1056    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/pop)
1057    #[wasm_bindgen(method, js_name = pop)]
1058    pub fn pop_checked<T>(this: &Array<T>) -> Option<T>;
1059
1060    /// The `push()` method adds one element to the end of an array and
1061    /// returns the new length of the array.
1062    ///
1063    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push)
1064    #[wasm_bindgen(method)]
1065    pub fn push<T>(this: &Array<T>, value: &T) -> u32;
1066
1067    /// The `push()` method adds one or more elements to the end of an array and
1068    /// returns the new length of the array.
1069    ///
1070    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push)
1071    #[wasm_bindgen(method, js_name = push, variadic)]
1072    pub fn push_many<T>(this: &Array<T>, values: &[T]) -> u32;
1073
1074    /// The `reduce()` method applies a function against an accumulator and each element in
1075    /// the array (from left to right) to reduce it to a single value.
1076    ///
1077    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce)
1078    #[cfg(not(js_sys_unstable_apis))]
1079    #[wasm_bindgen(method)]
1080    pub fn reduce<T>(
1081        this: &Array<T>,
1082        predicate: &mut dyn FnMut(JsValue, T, u32, Array<T>) -> JsValue,
1083        initial_value: &JsValue,
1084    ) -> JsValue;
1085
1086    /// The `reduce()` method applies a function against an accumulator and each element in
1087    /// the array (from left to right) to reduce it to a single value.
1088    ///
1089    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce)
1090    #[cfg(js_sys_unstable_apis)]
1091    #[wasm_bindgen(method)]
1092    pub fn reduce<T, A>(
1093        this: &Array<T>,
1094        predicate: &mut dyn FnMut(A, T, u32, Array<T>) -> A,
1095        initial_value: &A,
1096    ) -> A;
1097
1098    /// The `reduce()` method applies a function against an accumulator and each element in
1099    /// the array (from left to right) to reduce it to a single value. _(Fallible variation)_
1100    ///
1101    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce)
1102    #[wasm_bindgen(method, js_name = reduce, catch)]
1103    pub fn try_reduce<T, A>(
1104        this: &Array<T>,
1105        predicate: &mut dyn FnMut(A, T, u32) -> Result<A, JsError>,
1106        initial_value: &A,
1107    ) -> Result<A, JsValue>;
1108
1109    /// The `reduceRight()` method applies a function against an accumulator and each value
1110    /// of the array (from right-to-left) to reduce it to a single value.
1111    ///
1112    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/ReduceRight)
1113    #[cfg(not(js_sys_unstable_apis))]
1114    #[wasm_bindgen(method, js_name = reduceRight)]
1115    pub fn reduce_right<T>(
1116        this: &Array<T>,
1117        predicate: &mut dyn FnMut(JsValue, T, u32, Array<T>) -> JsValue,
1118        initial_value: &JsValue,
1119    ) -> JsValue;
1120
1121    /// The `reduceRight()` method applies a function against an accumulator and each value
1122    /// of the array (from right-to-left) to reduce it to a single value.
1123    ///
1124    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/ReduceRight)
1125    #[cfg(js_sys_unstable_apis)]
1126    #[wasm_bindgen(method, js_name = reduceRight)]
1127    pub fn reduce_right<T, A>(
1128        this: &Array<T>,
1129        predicate: &mut dyn FnMut(A, T, u32, Array<T>) -> A,
1130        initial_value: &A,
1131    ) -> A;
1132
1133    /// The `reduceRight()` method applies a function against an accumulator and each value
1134    /// of the array (from right-to-left) to reduce it to a single value. _(Fallible variation)_
1135    ///
1136    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/ReduceRight)
1137    #[wasm_bindgen(method, js_name = reduceRight, catch)]
1138    pub fn try_reduce_right<T, A>(
1139        this: &Array<T>,
1140        predicate: &mut dyn FnMut(JsValue, T, u32) -> Result<A, JsError>,
1141        initial_value: &A,
1142    ) -> Result<A, JsValue>;
1143
1144    /// The `reverse()` method reverses an array in place. The first array
1145    /// element becomes the last, and the last array element becomes the first.
1146    ///
1147    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse)
1148    #[wasm_bindgen(method)]
1149    pub fn reverse<T>(this: &Array<T>) -> Array<T>;
1150
1151    /// The `shift()` method removes the first element from an array and returns
1152    /// that removed element. This method changes the length of the array.
1153    ///
1154    /// **Note:** Consider using [`Array::shift_checked`] for handling empty arrays.
1155    ///
1156    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/shift)
1157    #[cfg(not(js_sys_unstable_apis))]
1158    #[wasm_bindgen(method)]
1159    pub fn shift<T>(this: &Array<T>) -> T;
1160
1161    /// The `shift()` method removes the first element from an array and returns
1162    /// that removed element. This method changes the length of the array.
1163    /// Returns `None` if the array is empty.
1164    ///
1165    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/shift)
1166    #[cfg(js_sys_unstable_apis)]
1167    #[wasm_bindgen(method)]
1168    pub fn shift<T>(this: &Array<T>) -> Option<T>;
1169
1170    // Next major: deprecate
1171    /// The `shift()` method removes the first element from an array and returns
1172    /// that removed element. This method changes the length of the array.
1173    ///
1174    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/shift)
1175    #[wasm_bindgen(method, js_name = shift)]
1176    pub fn shift_checked<T>(this: &Array<T>) -> Option<T>;
1177
1178    /// The `slice()` method returns a shallow copy of a portion of an array into
1179    /// a new array object selected from begin to end (end not included).
1180    /// The original array will not be modified.
1181    ///
1182    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice)
1183    #[cfg(not(js_sys_unstable_apis))]
1184    #[wasm_bindgen(method)]
1185    pub fn slice<T>(this: &Array<T>, start: u32, end: u32) -> Array<T>;
1186
1187    /// The `slice()` method returns a shallow copy of a portion of an array into
1188    /// a new array object selected from begin to end (end not included).
1189    /// The original array will not be modified. Negative indices count from the end.
1190    ///
1191    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice)
1192    #[cfg(js_sys_unstable_apis)]
1193    #[wasm_bindgen(method)]
1194    pub fn slice<T>(this: &Array<T>, start: i32, end: i32) -> Array<T>;
1195
1196    /// The `slice()` method returns a shallow copy of a portion of an array into
1197    /// a new array object selected from the given index to the end.
1198    /// The original array will not be modified.
1199    ///
1200    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice)
1201    #[cfg(not(js_sys_unstable_apis))]
1202    #[wasm_bindgen(method, js_name = slice)]
1203    pub fn slice_from<T>(this: &Array<T>, start: u32) -> Array<T>;
1204
1205    /// The `slice()` method returns a shallow copy of a portion of an array into
1206    /// a new array object selected from the given index to the end.
1207    /// The original array will not be modified. Negative indices count from the end.
1208    ///
1209    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice)
1210    #[cfg(js_sys_unstable_apis)]
1211    #[wasm_bindgen(method, js_name = slice)]
1212    pub fn slice_from<T>(this: &Array<T>, start: i32) -> Array<T>;
1213
1214    /// The `some()` method tests whether at least one element in the array passes the test implemented
1215    /// by the provided function.
1216    /// Note: This method returns false for any condition put on an empty array.
1217    ///
1218    /// **Note:** Consider using [`Array::try_some`] if the predicate might throw an error.
1219    ///
1220    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some)
1221    #[wasm_bindgen(method)]
1222    pub fn some<T>(this: &Array<T>, predicate: &mut dyn FnMut(T) -> bool) -> bool;
1223
1224    /// The `some()` method tests whether at least one element in the array passes the test implemented
1225    /// by the provided function. _(Fallible variation)_
1226    /// Note: This method returns false for any condition put on an empty array.
1227    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some)
1228    #[wasm_bindgen(method, js_name = some, catch)]
1229    pub fn try_some<T>(
1230        this: &Array<T>,
1231        predicate: &mut dyn FnMut(T) -> Result<bool, JsError>,
1232    ) -> Result<bool, JsValue>;
1233
1234    /// The `sort()` method sorts the elements of an array in place and returns
1235    /// the array. The sort is not necessarily stable. The default sort
1236    /// order is according to string Unicode code points.
1237    ///
1238    /// The time and space complexity of the sort cannot be guaranteed as it
1239    /// is implementation dependent.
1240    ///
1241    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort)
1242    #[wasm_bindgen(method)]
1243    pub fn sort<T>(this: &Array<T>) -> Array<T>;
1244
1245    /// The `sort()` method with a custom compare function.
1246    ///
1247    /// **Note:** Consider using [`Array::try_sort_by`] if the predicate might throw an error.
1248    ///
1249    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort)
1250    #[wasm_bindgen(method, js_name = sort)]
1251    pub fn sort_by<T>(this: &Array<T>, compare_fn: &mut dyn FnMut(T, T) -> i32) -> Array<T>;
1252
1253    /// The `sort()` method with a custom compare function. _(Fallible variation)_
1254    ///
1255    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort)
1256    #[wasm_bindgen(method, js_name = sort, catch)]
1257    pub fn try_sort_by<T>(
1258        this: &Array<T>,
1259        compare_fn: &mut dyn FnMut(T, T) -> Result<i32, JsError>,
1260    ) -> Result<Array<T>, JsValue>;
1261
1262    /// The `splice()` method changes the contents of an array by removing existing elements and/or
1263    /// adding new elements.
1264    ///
1265    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice)
1266    #[wasm_bindgen(method)]
1267    pub fn splice<T>(this: &Array<T>, start: u32, delete_count: u32, item: &T) -> Array<T>;
1268
1269    /// The `splice()` method changes the contents of an array by removing existing elements and/or
1270    /// adding new elements.
1271    ///
1272    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice)
1273    #[wasm_bindgen(method, js_name = splice, variadic)]
1274    pub fn splice_many<T>(this: &Array<T>, start: u32, delete_count: u32, items: &[T]) -> Array<T>;
1275
1276    /// The `toLocaleString()` method returns a string representing the elements of the array.
1277    /// The elements are converted to Strings using their toLocaleString methods and these
1278    /// Strings are separated by a locale-specific String (such as a comma ",").
1279    ///
1280    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toLocaleString)
1281    #[cfg(not(js_sys_unstable_apis))]
1282    #[wasm_bindgen(method, js_name = toLocaleString)]
1283    pub fn to_locale_string<T>(this: &Array<T>, locales: &JsValue, options: &JsValue) -> JsString;
1284
1285    /// The `toLocaleString()` method returns a string representing the elements of the array.
1286    /// The elements are converted to Strings using their toLocaleString methods and these
1287    /// Strings are separated by a locale-specific String (such as a comma ",").
1288    ///
1289    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toLocaleString)
1290    #[cfg(js_sys_unstable_apis)]
1291    #[wasm_bindgen(method, js_name = toLocaleString)]
1292    pub fn to_locale_string<T>(
1293        this: &Array<T>,
1294        locales: &[JsString],
1295        options: &Intl::NumberFormatOptions,
1296    ) -> JsString;
1297
1298    /// The `toReversed()` method returns a new array with the elements in reversed order,
1299    /// without modifying the original array.
1300    ///
1301    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toReversed)
1302    #[wasm_bindgen(method, js_name = toReversed)]
1303    pub fn to_reversed<T>(this: &Array<T>) -> Array<T>;
1304
1305    /// The `toSorted()` method returns a new array with the elements sorted in ascending order,
1306    /// without modifying the original array.
1307    ///
1308    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toSorted)
1309    #[wasm_bindgen(method, js_name = toSorted)]
1310    pub fn to_sorted<T>(this: &Array<T>) -> Array<T>;
1311
1312    /// The `toSorted()` method with a custom compare function.
1313    ///
1314    /// **Note:** Consider using [`Array::try_to_sorted_by`] if the predicate might throw an error.
1315    ///
1316    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toSorted)
1317    #[wasm_bindgen(method, js_name = toSorted)]
1318    pub fn to_sorted_by<T>(this: &Array<T>, compare_fn: &mut dyn FnMut(T, T) -> i32) -> Array<T>;
1319
1320    /// The `toSorted()` method with a custom compare function. _(Fallible variation)_
1321    ///
1322    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toSorted)
1323    #[wasm_bindgen(method, js_name = toSorted, catch)]
1324    pub fn try_to_sorted_by<T>(
1325        this: &Array<T>,
1326        compare_fn: &mut dyn FnMut(T, T) -> Result<i32, JsError>,
1327    ) -> Result<Array<T>, JsValue>;
1328
1329    /// The `toSpliced()` method returns a new array with some elements removed and/or
1330    /// replaced at a given index, without modifying the original array.
1331    ///
1332    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toSpliced)
1333    #[wasm_bindgen(method, js_name = toSpliced, variadic)]
1334    pub fn to_spliced<T>(this: &Array<T>, start: u32, delete_count: u32, items: &[T]) -> Array<T>;
1335
1336    /// The `toString()` method returns a string representing the specified array
1337    /// and its elements.
1338    ///
1339    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toString)
1340    #[cfg(not(js_sys_unstable_apis))]
1341    #[wasm_bindgen(method, js_name = toString)]
1342    pub fn to_string<T>(this: &Array<T>) -> JsString;
1343
1344    /// Converts the Array into a Vector.
1345    #[wasm_bindgen(method, js_name = slice)]
1346    pub fn to_vec<T>(this: &Array<T>) -> Vec<T>;
1347
1348    /// The `unshift()` method adds one element to the beginning of an
1349    /// array and returns the new length of the array.
1350    ///
1351    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/unshift)
1352    #[wasm_bindgen(method)]
1353    pub fn unshift<T>(this: &Array<T>, value: &T) -> u32;
1354
1355    /// The `unshift()` method adds one or more elements to the beginning of an
1356    /// array and returns the new length of the array.
1357    ///
1358    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/unshift)
1359    #[wasm_bindgen(method, js_name = unshift, variadic)]
1360    pub fn unshift_many<T>(this: &Array<T>, values: &[T]) -> u32;
1361
1362    /// The `with()` method returns a new array with the element at the given index
1363    /// replaced with the given value, without modifying the original array.
1364    ///
1365    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/with)
1366    #[wasm_bindgen(method, js_name = with)]
1367    pub fn with<T>(this: &Array<T>, index: u32, value: &T) -> Array<T>;
1368}
1369
1370// Tuples as a typed array variant
1371#[wasm_bindgen]
1372extern "C" {
1373    #[wasm_bindgen(extends = Object, js_name = Array, is_type_of = Array::is_array, no_upcast, typescript_type = "Array<any>")]
1374    #[derive(Clone, Debug)]
1375    pub type ArrayTuple<T: JsTuple = (JsValue,)>;
1376
1377    /// Creates a new JS array typed as a 1-tuple.
1378    #[wasm_bindgen(js_class = Array, static_method_of = ArrayTuple, js_name = of)]
1379    pub fn new1<T1>(t1: &T1) -> ArrayTuple<(T1,)>;
1380
1381    /// Creates a new JS array typed as a 2-tuple.
1382    #[wasm_bindgen(js_class = Array, static_method_of = ArrayTuple, js_name = of)]
1383    pub fn new2<T1, T2>(t1: &T1, t2: &T2) -> ArrayTuple<(T1, T2)>;
1384
1385    /// Creates a new JS array typed as a 3-tuple.
1386    #[wasm_bindgen(js_class = Array, static_method_of = ArrayTuple, js_name = of)]
1387    pub fn new3<T1, T2, T3>(t1: &T1, t2: &T2, t3: &T3) -> ArrayTuple<(T1, T2, T3)>;
1388
1389    /// Creates a new JS array typed as a 4-tuple.
1390    #[wasm_bindgen(js_class = Array, static_method_of = ArrayTuple, js_name = of)]
1391    pub fn new4<T1, T2, T3, T4>(t1: &T1, t2: &T2, t3: &T3, t4: &T4)
1392        -> ArrayTuple<(T1, T2, T3, T4)>;
1393
1394    /// Creates a new JS array typed as a 5-tuple.
1395    #[wasm_bindgen(js_class = Array, static_method_of = ArrayTuple, js_name = of)]
1396    pub fn new5<T1, T2, T3, T4, T5>(
1397        t1: &T1,
1398        t2: &T2,
1399        t3: &T3,
1400        t4: &T4,
1401        t5: &T5,
1402    ) -> ArrayTuple<(T1, T2, T3, T4, T5)>;
1403
1404    /// Creates a new JS array typed as a 6-tuple.
1405    #[wasm_bindgen(js_class = Array, static_method_of = ArrayTuple, js_name = of)]
1406    pub fn new6<T1, T2, T3, T4, T5, T6>(
1407        t1: &T1,
1408        t2: &T2,
1409        t3: &T3,
1410        t4: &T4,
1411        t5: &T5,
1412        t6: &T6,
1413    ) -> ArrayTuple<(T1, T2, T3, T4, T5, T6)>;
1414
1415    /// Creates a new JS array typed as a 7-tuple.
1416    #[wasm_bindgen(js_class = Array, static_method_of = ArrayTuple, js_name = of)]
1417    pub fn new7<T1, T2, T3, T4, T5, T6, T7>(
1418        t1: &T1,
1419        t2: &T2,
1420        t3: &T3,
1421        t4: &T4,
1422        t5: &T5,
1423        t6: &T6,
1424        t7: &T7,
1425    ) -> ArrayTuple<(T1, T2, T3, T4, T5, T6, T7)>;
1426
1427    /// Creates a new JS array typed as a 8-tuple.
1428    #[wasm_bindgen(js_class = Array, static_method_of = ArrayTuple, js_name = of)]
1429    pub fn new8<T1, T2, T3, T4, T5, T6, T7, T8>(
1430        t1: &T1,
1431        t2: &T2,
1432        t3: &T3,
1433        t4: &T4,
1434        t5: &T5,
1435        t6: &T6,
1436        t7: &T7,
1437        t8: &T8,
1438    ) -> ArrayTuple<(T1, T2, T3, T4, T5, T6, T7, T8)>;
1439
1440    /// Gets the 1st item
1441    #[wasm_bindgen(
1442        method,
1443        js_class = Array,
1444        getter,
1445        js_name = "0"
1446    )]
1447    pub fn get0<T: JsTuple1 = (JsValue,)>(this: &ArrayTuple<T>) -> <T as JsTuple1>::T1;
1448
1449    /// Gets the 2nd item
1450    #[wasm_bindgen(
1451        method,
1452        js_class = Array,
1453        getter,
1454        js_name = "1"
1455    )]
1456    pub fn get1<T: JsTuple2 = (JsValue, JsValue)>(this: &ArrayTuple<T>) -> <T as JsTuple2>::T2;
1457
1458    /// Gets the 3rd item
1459    #[wasm_bindgen(
1460        method,
1461        js_class = Array,
1462        getter,
1463        js_name = "2"
1464    )]
1465    pub fn get2<T: JsTuple3 = (JsValue, JsValue, JsValue)>(
1466        this: &ArrayTuple<T>,
1467    ) -> <T as JsTuple3>::T3;
1468
1469    /// Gets the 4th item
1470    #[wasm_bindgen(
1471        method,
1472        js_class = Array,
1473        getter,
1474        js_name = "3"
1475    )]
1476    pub fn get3<T: JsTuple4 = (JsValue, JsValue, JsValue, JsValue)>(
1477        this: &ArrayTuple<T>,
1478    ) -> <T as JsTuple4>::T4;
1479
1480    /// Gets the 5th item
1481    #[wasm_bindgen(
1482        method,
1483        js_class = Array,
1484        getter,
1485        js_name = "4"
1486    )]
1487    pub fn get4<T: JsTuple5 = (JsValue, JsValue, JsValue, JsValue, JsValue)>(
1488        this: &ArrayTuple<T>,
1489    ) -> <T as JsTuple5>::T5;
1490
1491    /// Gets the 6th item
1492    #[wasm_bindgen(
1493        method,
1494        js_class = Array,
1495        getter,
1496        js_name = "5"
1497    )]
1498    pub fn get5<T: JsTuple6 = (JsValue, JsValue, JsValue, JsValue, JsValue, JsValue)>(
1499        this: &ArrayTuple<T>,
1500    ) -> <T as JsTuple6>::T6;
1501
1502    /// Gets the 7th item
1503    #[wasm_bindgen(
1504        method,
1505        js_class = Array,
1506        getter,
1507        js_name = "6"
1508    )]
1509    pub fn get6<
1510        T: JsTuple7 = (
1511            JsValue,
1512            JsValue,
1513            JsValue,
1514            JsValue,
1515            JsValue,
1516            JsValue,
1517            JsValue,
1518        ),
1519    >(
1520        this: &ArrayTuple<T>,
1521    ) -> <T as JsTuple7>::T7;
1522
1523    /// Gets the 8th item
1524    #[wasm_bindgen(
1525        method,
1526        js_class = Array,
1527        getter,
1528        js_name = "7"
1529    )]
1530    pub fn get7<
1531        T: JsTuple8 = (
1532            JsValue,
1533            JsValue,
1534            JsValue,
1535            JsValue,
1536            JsValue,
1537            JsValue,
1538            JsValue,
1539            JsValue,
1540        ),
1541    >(
1542        this: &ArrayTuple<T>,
1543    ) -> <T as JsTuple8>::T8;
1544
1545    /// Sets the 1st item
1546    #[wasm_bindgen(
1547        method,
1548        js_class = Array,
1549        setter,
1550        js_name = "0"
1551    )]
1552    pub fn set0<T: JsTuple1 = (JsValue,)>(this: &ArrayTuple<T>, value: &<T as JsTuple1>::T1);
1553
1554    /// Sets the 2nd item
1555    #[wasm_bindgen(
1556        method,
1557        js_class = Array,
1558        setter,
1559        js_name = "1"
1560    )]
1561    pub fn set1<T: JsTuple2 = (JsValue, JsValue)>(
1562        this: &ArrayTuple<T>,
1563        value: &<T as JsTuple2>::T2,
1564    );
1565
1566    /// Sets the 3rd item
1567    #[wasm_bindgen(
1568        method,
1569        js_class = Array,
1570        setter,
1571        js_name = "2"
1572    )]
1573    pub fn set2<T: JsTuple3 = (JsValue, JsValue, JsValue)>(
1574        this: &ArrayTuple<T>,
1575        value: &<T as JsTuple3>::T3,
1576    );
1577
1578    /// Sets the 4th item
1579    #[wasm_bindgen(
1580        method,
1581        js_class = Array,
1582        setter,
1583        js_name = "3"
1584    )]
1585    pub fn set3<T: JsTuple4 = (JsValue, JsValue, JsValue, JsValue)>(
1586        this: &ArrayTuple<T>,
1587        value: &<T as JsTuple4>::T4,
1588    );
1589
1590    /// Sets the 5th item
1591    #[wasm_bindgen(
1592        method,
1593        js_class = Array,
1594        setter,
1595        js_name = "4"
1596    )]
1597    pub fn set4<T: JsTuple5 = (JsValue, JsValue, JsValue, JsValue, JsValue)>(
1598        this: &ArrayTuple<T>,
1599        value: &<T as JsTuple5>::T5,
1600    );
1601
1602    /// Sets the 6th item
1603    #[wasm_bindgen(
1604        method,
1605        js_class = Array,
1606        setter,
1607        js_name = "5"
1608    )]
1609    pub fn set5<T: JsTuple6 = (JsValue, JsValue, JsValue, JsValue, JsValue, JsValue)>(
1610        this: &ArrayTuple<T>,
1611        value: &<T as JsTuple6>::T6,
1612    );
1613
1614    /// Sets the 7th item
1615    #[wasm_bindgen(
1616        method,
1617        js_class = Array,
1618        setter,
1619        js_name = "6"
1620    )]
1621    pub fn set6<
1622        T: JsTuple7 = (
1623            JsValue,
1624            JsValue,
1625            JsValue,
1626            JsValue,
1627            JsValue,
1628            JsValue,
1629            JsValue,
1630        ),
1631    >(
1632        this: &ArrayTuple<T>,
1633        value: &<T as JsTuple7>::T7,
1634    );
1635
1636    /// Sets the 8th item
1637    #[wasm_bindgen(
1638        method,
1639        js_class = Array,
1640        setter,
1641        js_name = "7"
1642    )]
1643    pub fn set7<
1644        T: JsTuple8 = (
1645            JsValue,
1646            JsValue,
1647            JsValue,
1648            JsValue,
1649            JsValue,
1650            JsValue,
1651            JsValue,
1652            JsValue,
1653        ),
1654    >(
1655        this: &ArrayTuple<T>,
1656        value: &<T as JsTuple8>::T8,
1657    );
1658}
1659
1660/// Base trait for tuple types.
1661pub trait JsTuple {
1662    const ARITY: usize;
1663}
1664
1665macro_rules! impl_tuple_traits {
1666    // Base case: first trait has no parent (besides JsTuple)
1667    ($name:ident $ty:tt) => {
1668        pub trait $name: JsTuple {
1669            type $ty;
1670        }
1671    };
1672
1673    // Recursive case: define trait with parent, then recurse
1674    ($name:ident $ty:tt $($rest_name:ident $rest_ty:tt)+) => {
1675        pub trait $name: JsTuple {
1676            type $ty;
1677        }
1678
1679        impl_tuple_traits!(@with_parent $name $($rest_name $rest_ty)+);
1680    };
1681
1682    // Internal: traits that have a parent
1683    (@with_parent $trait:ident $name:ident $ty:tt) => {
1684        pub trait $name: $trait {
1685            type $ty;
1686        }
1687    };
1688
1689    (@with_parent $trait:ident $name:ident $ty:tt $($rest_name:ident $rest_ty:tt)+) => {
1690        pub trait $name: $trait {
1691            type $ty;
1692        }
1693
1694        impl_tuple_traits!(@with_parent $name $($rest_name $rest_ty)+);
1695    };
1696}
1697
1698macro_rules! impl_parent_traits {
1699    ([$($types:tt),+] [] []) => {};
1700
1701    ([$($types:tt),+] [$trait:ident $($rest_traits:ident)*] [$ty:tt $($rest_tys:tt)*]) => {
1702        impl<$($types),+> $trait for ($($types),+,) {
1703            type $ty = $ty;
1704        }
1705
1706        impl_parent_traits!([$($types),+] [$($rest_traits)*] [$($rest_tys)*]);
1707    };
1708}
1709
1710// Define the trait hierarchy once
1711impl_tuple_traits!(
1712    JsTuple1 T1
1713    JsTuple2 T2
1714    JsTuple3 T3
1715    JsTuple4 T4
1716    JsTuple5 T5
1717    JsTuple6 T6
1718    JsTuple7 T7
1719    JsTuple8 T8
1720);
1721
1722impl<T: JsTuple> ArrayTuple<T> {
1723    /// Get the static arity of the ArrayTuple type.
1724    #[allow(clippy::len_without_is_empty)]
1725    pub fn len(&self) -> usize {
1726        <T as JsTuple>::ARITY
1727    }
1728}
1729
1730macro_rules! impl_tuple {
1731    ($arity:literal [$($traits:ident)*] [$($T:tt)+] [$($vars:tt)+] $new:ident $last:ident $last_ty:tt) => {
1732        impl<$($T),+> JsTuple for ($($T),+,) {
1733            const ARITY: usize = $arity;
1734        }
1735
1736        impl_parent_traits!([$($T),+] [$($traits)*] [$($T)*]);
1737
1738        impl<$($T: JsGeneric),+> From<($($T,)+)> for ArrayTuple<($($T),+,)> {
1739            fn from(($($vars,)+): ($($T,)+)) -> Self {
1740                $(let $vars: JsValue = $vars.upcast_into();)+
1741                Array::of(&[$($vars),+]).unchecked_into()
1742            }
1743        }
1744
1745        impl<$($T: JsGeneric + Default),+> Default for ArrayTuple<($($T),+,)> {
1746            fn default() -> Self {
1747                (
1748                    $($T::default(),)+
1749                ).into()
1750            }
1751        }
1752
1753        impl<$($T: JsGeneric),+> ArrayTuple<($($T),+,)> {
1754            /// Get the first element of the ArrayTuple
1755            pub fn first(&self) -> T1 {
1756                self.get0()
1757            }
1758
1759            /// Get the last element of the ArrayTuple
1760            pub fn last(&self) -> $last_ty {
1761                self.$last()
1762            }
1763
1764            /// Convert the ArrayTuple into its corresponding Rust tuple.
1765            pub fn into_tuple(self) -> ($($T,)+) {
1766                ($(self.$vars(),)+)
1767            }
1768
1769            /// Deprecated alias for [`ArrayTuple::into_tuple`].
1770            #[deprecated(note = "renamed to `into_tuple`")]
1771            pub fn into_parts(self) -> ($($T,)+) {
1772                self.into_tuple()
1773            }
1774
1775            /// Create a new ArrayTuple from the corresponding parts.
1776            ///
1777            /// # Example
1778            ///
1779            /// ```
1780            /// use js_sys::{ArrayTuple, JsString};
1781            ///
1782            /// let tuple = ArrayTuple::<JsString, JsString>::new(&"a".into(), &"b".into());
1783            /// ```
1784            ///
1785            /// Note: You must specify the T using `::<...>` syntax on `ArrayTuple`.
1786            /// Alternatively, use `new1`, `new2`, etc. for type inference from the left-hand side.
1787            pub fn new($($vars: &$T),+) -> ArrayTuple<($($T),+,)> {
1788                ArrayTuple::$new($($vars),+)
1789            }
1790        }
1791    };
1792}
1793
1794// Implement for each tuple size
1795impl_tuple!(1 [JsTuple1] [T1] [get0] new1 get0 T1);
1796impl_tuple!(2 [JsTuple1 JsTuple2] [T1 T2] [get0 get1] new2 get1 T2);
1797impl_tuple!(3 [JsTuple1 JsTuple2 JsTuple3] [T1 T2 T3] [get0 get1 get2] new3 get2 T3);
1798impl_tuple!(4 [JsTuple1 JsTuple2 JsTuple3 JsTuple4] [T1 T2 T3 T4] [get0 get1 get2 get3] new4 get3 T4);
1799impl_tuple!(5 [JsTuple1 JsTuple2 JsTuple3 JsTuple4 JsTuple5] [T1 T2 T3 T4 T5] [get0 get1 get2 get3 get4] new5 get4 T5);
1800impl_tuple!(6 [JsTuple1 JsTuple2 JsTuple3 JsTuple4 JsTuple5 JsTuple6] [T1 T2 T3 T4 T5 T6] [get0 get1 get2 get3 get4 get5] new6 get5 T6);
1801impl_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);
1802impl_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);
1803
1804// Macro to generate structural covariance impls for each arity
1805macro_rules! impl_tuple_covariance {
1806    ([$($T:ident)+] [$($Target:ident)+]) => {
1807        // ArrayTuple -> Array
1808        // Allows (T1, T2, ...) to be used where (Target) is expected
1809        // when all T1, T2, ... are covariant to Target
1810        impl<$($T,)+ Target> UpcastFrom<ArrayTuple<($($T,)+)>> for Array<Target>
1811        where
1812            $(Target: UpcastFrom<$T>,)+
1813        {
1814        }
1815        impl<$($T,)+ Target> UpcastFrom<ArrayTuple<($($T,)+)>> for JsOption<Array<Target>>
1816        where
1817            $(Target: UpcastFrom<$T>,)+
1818        {}
1819    };
1820}
1821
1822impl_tuple_covariance!([T1][Target1]);
1823impl_tuple_covariance!([T1 T2] [Target1 Target2]);
1824impl_tuple_covariance!([T1 T2 T3] [Target1 Target2 Target3]);
1825impl_tuple_covariance!([T1 T2 T3 T4] [Target1 Target2 Target3 Target4]);
1826impl_tuple_covariance!([T1 T2 T3 T4 T5] [Target1 Target2 Target3 Target4 Target5]);
1827impl_tuple_covariance!([T1 T2 T3 T4 T5 T6] [Target1 Target2 Target3 Target4 Target5 Target6]);
1828impl_tuple_covariance!([T1 T2 T3 T4 T5 T6 T7] [Target1 Target2 Target3 Target4 Target5 Target6 Target7]);
1829impl_tuple_covariance!([T1 T2 T3 T4 T5 T6 T7 T8] [Target1 Target2 Target3 Target4 Target5 Target6 Target7 Target8]);
1830
1831// Tuple casting is implemented in core
1832impl<T: JsTuple, U: JsTuple> UpcastFrom<ArrayTuple<T>> for ArrayTuple<U> where U: UpcastFrom<T> {}
1833impl<T: JsTuple> UpcastFrom<ArrayTuple<T>> for JsValue {}
1834impl<T: JsTuple> UpcastFrom<ArrayTuple<T>> for JsOption<JsValue> {}
1835
1836/// Iterator returned by `Array::into_iter`
1837#[derive(Debug, Clone)]
1838pub struct ArrayIntoIter<T: JsGeneric = JsValue> {
1839    range: core::ops::Range<u32>,
1840    array: Array<T>,
1841}
1842
1843#[cfg(not(js_sys_unstable_apis))]
1844impl<T: JsGeneric> core::iter::Iterator for ArrayIntoIter<T> {
1845    type Item = T;
1846
1847    fn next(&mut self) -> Option<Self::Item> {
1848        let index = self.range.next()?;
1849        Some(self.array.get(index))
1850    }
1851
1852    #[inline]
1853    fn size_hint(&self) -> (usize, Option<usize>) {
1854        self.range.size_hint()
1855    }
1856
1857    #[inline]
1858    fn count(self) -> usize
1859    where
1860        Self: Sized,
1861    {
1862        self.range.count()
1863    }
1864
1865    #[inline]
1866    fn last(self) -> Option<Self::Item>
1867    where
1868        Self: Sized,
1869    {
1870        let Self { range, array } = self;
1871        range.last().map(|index| array.get(index))
1872    }
1873
1874    #[inline]
1875    fn nth(&mut self, n: usize) -> Option<Self::Item> {
1876        self.range.nth(n).map(|index| self.array.get(index))
1877    }
1878}
1879
1880#[cfg(js_sys_unstable_apis)]
1881impl<T: JsGeneric> core::iter::Iterator for ArrayIntoIter<T> {
1882    type Item = T;
1883
1884    fn next(&mut self) -> Option<Self::Item> {
1885        let index = self.range.next()?;
1886        self.array.get(index)
1887    }
1888
1889    #[inline]
1890    fn size_hint(&self) -> (usize, Option<usize>) {
1891        self.range.size_hint()
1892    }
1893
1894    #[inline]
1895    fn count(self) -> usize
1896    where
1897        Self: Sized,
1898    {
1899        self.range.count()
1900    }
1901
1902    #[inline]
1903    fn last(self) -> Option<Self::Item>
1904    where
1905        Self: Sized,
1906    {
1907        let Self { range, array } = self;
1908        range.last().and_then(|index| array.get(index))
1909    }
1910
1911    #[inline]
1912    fn nth(&mut self, n: usize) -> Option<Self::Item> {
1913        self.range.nth(n).and_then(|index| self.array.get(index))
1914    }
1915}
1916
1917#[cfg(not(js_sys_unstable_apis))]
1918impl<T: JsGeneric> core::iter::DoubleEndedIterator for ArrayIntoIter<T> {
1919    fn next_back(&mut self) -> Option<Self::Item> {
1920        let index = self.range.next_back()?;
1921        Some(self.array.get(index))
1922    }
1923
1924    fn nth_back(&mut self, n: usize) -> Option<Self::Item> {
1925        self.range.nth_back(n).map(|index| self.array.get(index))
1926    }
1927}
1928
1929#[cfg(js_sys_unstable_apis)]
1930impl<T: JsGeneric> core::iter::DoubleEndedIterator for ArrayIntoIter<T> {
1931    fn next_back(&mut self) -> Option<Self::Item> {
1932        let index = self.range.next_back()?;
1933        self.array.get(index)
1934    }
1935
1936    fn nth_back(&mut self, n: usize) -> Option<Self::Item> {
1937        self.range
1938            .nth_back(n)
1939            .and_then(|index| self.array.get(index))
1940    }
1941}
1942
1943impl<T: JsGeneric> core::iter::FusedIterator for ArrayIntoIter<T> {}
1944
1945impl<T: JsGeneric> core::iter::ExactSizeIterator for ArrayIntoIter<T> {}
1946
1947/// Iterator returned by `Array::iter`
1948#[derive(Debug, Clone)]
1949pub struct ArrayIter<'a, T: JsGeneric = JsValue> {
1950    range: core::ops::Range<u32>,
1951    array: &'a Array<T>,
1952}
1953
1954impl<T: JsGeneric> core::iter::Iterator for ArrayIter<'_, T> {
1955    type Item = T;
1956
1957    fn next(&mut self) -> Option<Self::Item> {
1958        let index = self.range.next()?;
1959        Some(self.array.get_unchecked(index))
1960    }
1961
1962    #[inline]
1963    fn size_hint(&self) -> (usize, Option<usize>) {
1964        self.range.size_hint()
1965    }
1966
1967    #[inline]
1968    fn count(self) -> usize
1969    where
1970        Self: Sized,
1971    {
1972        self.range.count()
1973    }
1974
1975    #[inline]
1976    fn last(self) -> Option<Self::Item>
1977    where
1978        Self: Sized,
1979    {
1980        let Self { range, array } = self;
1981        range.last().map(|index| array.get_unchecked(index))
1982    }
1983
1984    #[inline]
1985    fn nth(&mut self, n: usize) -> Option<Self::Item> {
1986        self.range
1987            .nth(n)
1988            .map(|index| self.array.get_unchecked(index))
1989    }
1990}
1991
1992impl<T: JsGeneric> core::iter::DoubleEndedIterator for ArrayIter<'_, T> {
1993    fn next_back(&mut self) -> Option<Self::Item> {
1994        let index = self.range.next_back()?;
1995        Some(self.array.get_unchecked(index))
1996    }
1997
1998    fn nth_back(&mut self, n: usize) -> Option<Self::Item> {
1999        self.range
2000            .nth_back(n)
2001            .map(|index| self.array.get_unchecked(index))
2002    }
2003}
2004
2005impl<T: JsGeneric> core::iter::FusedIterator for ArrayIter<'_, T> {}
2006
2007impl<T: JsGeneric> core::iter::ExactSizeIterator for ArrayIter<'_, T> {}
2008
2009impl<T: JsGeneric> Array<T> {
2010    /// Returns an iterator over the values of the JS array.
2011    pub fn iter(&self) -> ArrayIter<'_, T> {
2012        ArrayIter {
2013            range: 0..self.length(),
2014            array: self,
2015        }
2016    }
2017}
2018
2019impl<T: JsGeneric> core::iter::IntoIterator for Array<T> {
2020    type Item = T;
2021    type IntoIter = ArrayIntoIter<T>;
2022
2023    fn into_iter(self) -> Self::IntoIter {
2024        ArrayIntoIter {
2025            range: 0..self.length(),
2026            array: self,
2027        }
2028    }
2029}
2030
2031// `FromIterator` / `Extend` for `Array` (= `Array<JsValue>` via the default
2032// type parameter) preserve the long-standing stable behaviour: any iterator
2033// of items convertible to `&JsValue` collects into an erased `Array<JsValue>`.
2034//
2035// Typed collection (where the element type is inferred from the iterator
2036// item via [`IntoJsGeneric`]) is exposed as the inherent constructor
2037// [`Array::from_iter_typed`] rather than a second `FromIterator` impl. A
2038// blanket `impl<A: IntoJsGeneric> FromIterator<A> for Array<A::JsCanon>`
2039// would overlap with the stable `AsRef<JsValue>` impl on `Array<JsValue>`
2040// (since `JsValue: IntoJsGeneric` with `JsCanon = JsValue`), so the two
2041// cannot coexist as `FromIterator` impls without coherence violations.
2042//
2043// TODO(next major): deprecate this `FromIterator`/`Extend` pair in favour
2044// of a single `IntoJsGeneric`-based impl, and rename `from_iter_typed` to
2045// take its place. That migration is source-breaking for callers relying on
2046// `.collect::<Array>()` implicit erasure of typed items, so it is deferred.
2047
2048impl<A> core::iter::FromIterator<A> for Array
2049where
2050    A: AsRef<JsValue>,
2051{
2052    fn from_iter<I>(iter: I) -> Array
2053    where
2054        I: IntoIterator<Item = A>,
2055    {
2056        let mut out = Array::new();
2057        out.extend(iter);
2058        out
2059    }
2060}
2061
2062impl<A> core::iter::Extend<A> for Array
2063where
2064    A: AsRef<JsValue>,
2065{
2066    fn extend<I>(&mut self, iter: I)
2067    where
2068        I: IntoIterator<Item = A>,
2069    {
2070        for value in iter {
2071            self.push(value.as_ref());
2072        }
2073    }
2074}
2075
2076impl<T: JsGeneric> Array<T> {
2077    /// Collect an iterator into a typed `Array<T>`, projecting each item
2078    /// through its canonical [`JsGeneric`] via [`IntoJsGeneric`].
2079    ///
2080    /// This is the typed counterpart to the stable
2081    /// `impl FromIterator<A> for Array where A: AsRef<JsValue>`, which always
2082    /// produces an erased `Array<JsValue>`. Use `from_iter_typed` when you
2083    /// want the element type inferred from the iterator item:
2084    ///
2085    /// ```ignore
2086    /// use js_sys::{Array, Number};
2087    ///
2088    /// let arr = Array::from_iter_typed((0..10).map(Number::from));
2089    /// // arr: Array<Number>
2090    /// ```
2091    ///
2092    /// Reference iteration (`Item = &U`) is supported transparently via the
2093    /// `&U: IntoJsGeneric` blanket in `wasm-bindgen` core.
2094    //
2095    // TODO(next major): replace the stable `FromIterator` impl above with
2096    // this behaviour and remove `from_iter_typed`.
2097    pub fn from_iter_typed<A, I>(iter: I) -> Array<T>
2098    where
2099        A: IntoJsGeneric<JsCanon = T>,
2100        I: IntoIterator<Item = A>,
2101    {
2102        let mut out = Array::<T>::new_typed();
2103        out.extend_typed(iter);
2104        out
2105    }
2106
2107    /// Extend a typed `Array<T>` with an iterator of items convertible to
2108    /// `T` via [`IntoJsGeneric`]. Companion to [`Array::from_iter_typed`].
2109    //
2110    // TODO(next major): replace the stable `Extend` impl above with this
2111    // behaviour and remove `extend_typed`.
2112    pub fn extend_typed<A, I>(&mut self, iter: I)
2113    where
2114        A: IntoJsGeneric<JsCanon = T>,
2115        I: IntoIterator<Item = A>,
2116    {
2117        for value in iter {
2118            self.push(&value.to_js());
2119        }
2120    }
2121}
2122
2123impl Default for Array<JsValue> {
2124    fn default() -> Self {
2125        Self::new()
2126    }
2127}
2128
2129impl<T> Iterable for Array<T> {
2130    type Item = T;
2131}
2132
2133impl<T: JsTuple> Iterable for ArrayTuple<T> {
2134    type Item = JsValue;
2135}
2136
2137// ArrayBufferOptions
2138#[wasm_bindgen]
2139extern "C" {
2140    #[wasm_bindgen(extends = Object, typescript_type = "ArrayBufferOptions")]
2141    #[derive(Clone, Debug, PartialEq, Eq)]
2142    pub type ArrayBufferOptions;
2143
2144    /// The maximum size, in bytes, that the array buffer can be resized to.
2145    #[wasm_bindgen(method, setter, js_name = maxByteLength)]
2146    pub fn set_max_byte_length(this: &ArrayBufferOptions, max_byte_length: usize);
2147
2148    /// The maximum size, in bytes, that the array buffer can be resized to.
2149    #[wasm_bindgen(method, getter, js_name = maxByteLength)]
2150    pub fn get_max_byte_length(this: &ArrayBufferOptions) -> usize;
2151}
2152
2153impl ArrayBufferOptions {
2154    #[cfg(not(js_sys_unstable_apis))]
2155    pub fn new(max_byte_length: usize) -> ArrayBufferOptions {
2156        let options = JsCast::unchecked_into::<ArrayBufferOptions>(Object::new());
2157        options.set_max_byte_length(max_byte_length);
2158        options
2159    }
2160
2161    #[cfg(js_sys_unstable_apis)]
2162    pub fn new(max_byte_length: usize) -> ArrayBufferOptions {
2163        let options = JsCast::unchecked_into::<ArrayBufferOptions>(Object::<JsValue>::new());
2164        options.set_max_byte_length(max_byte_length);
2165        options
2166    }
2167}
2168
2169// ArrayBuffer
2170#[wasm_bindgen]
2171extern "C" {
2172    #[wasm_bindgen(extends = Object, typescript_type = "ArrayBuffer")]
2173    #[derive(Clone, Debug, PartialEq, Eq)]
2174    pub type ArrayBuffer;
2175
2176    /// The `ArrayBuffer` object is used to represent a generic,
2177    /// fixed-length raw binary data buffer. You cannot directly
2178    /// manipulate the contents of an `ArrayBuffer`; instead, you
2179    /// create one of the typed array objects or a `DataView` object
2180    /// which represents the buffer in a specific format, and use that
2181    /// to read and write the contents of the buffer.
2182    ///
2183    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer)
2184    #[cfg(not(js_sys_unstable_apis))]
2185    #[wasm_bindgen(constructor)]
2186    pub fn new(length: u32) -> ArrayBuffer;
2187
2188    /// The `ArrayBuffer` object is used to represent a generic,
2189    /// fixed-length raw binary data buffer. You cannot directly
2190    /// manipulate the contents of an `ArrayBuffer`; instead, you
2191    /// create one of the typed array objects or a `DataView` object
2192    /// which represents the buffer in a specific format, and use that
2193    /// to read and write the contents of the buffer.
2194    ///
2195    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer)
2196    #[cfg(js_sys_unstable_apis)]
2197    #[wasm_bindgen(constructor)]
2198    pub fn new(length: usize) -> ArrayBuffer;
2199
2200    /// The `ArrayBuffer` object is used to represent a generic,
2201    /// fixed-length raw binary data buffer. You cannot directly
2202    /// manipulate the contents of an `ArrayBuffer`; instead, you
2203    /// create one of the typed array objects or a `DataView` object
2204    /// which represents the buffer in a specific format, and use that
2205    /// to read and write the contents of the buffer.
2206    ///
2207    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer)
2208    #[wasm_bindgen(constructor)]
2209    pub fn new_with_options(length: usize, options: &ArrayBufferOptions) -> ArrayBuffer;
2210
2211    /// The `byteLength` property of an object which is an instance of type ArrayBuffer
2212    /// it's an accessor property whose set accessor function is undefined,
2213    /// meaning that you can only read this property.
2214    /// The value is established when the array is constructed and cannot be changed.
2215    /// This property returns 0 if this ArrayBuffer has been detached.
2216    ///
2217    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/byteLength)
2218    #[cfg(not(js_sys_unstable_apis))]
2219    #[wasm_bindgen(method, getter, js_name = byteLength)]
2220    pub fn byte_length(this: &ArrayBuffer) -> u32;
2221
2222    /// The `byteLength` property of an object which is an instance of type ArrayBuffer
2223    /// it's an accessor property whose set accessor function is undefined,
2224    /// meaning that you can only read this property.
2225    /// The value is established when the array is constructed and cannot be changed.
2226    /// This property returns 0 if this ArrayBuffer has been detached.
2227    ///
2228    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/byteLength)
2229    #[cfg(js_sys_unstable_apis)]
2230    #[wasm_bindgen(method, getter, js_name = byteLength)]
2231    pub fn byte_length(this: &ArrayBuffer) -> usize;
2232
2233    /// The `detached` accessor property of `ArrayBuffer` instances returns a boolean indicating
2234    /// whether or not this buffer has been detached (transferred).
2235    ///
2236    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/detached)
2237    #[wasm_bindgen(method, getter)]
2238    pub fn detached(this: &ArrayBuffer) -> bool;
2239
2240    /// The `isView()` method returns true if arg is one of the `ArrayBuffer`
2241    /// views, such as typed array objects or a DataView; false otherwise.
2242    ///
2243    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/isView)
2244    #[wasm_bindgen(static_method_of = ArrayBuffer, js_name = isView)]
2245    pub fn is_view(value: &JsValue) -> bool;
2246
2247    /// The `maxByteLength` accessor property of ArrayBuffer instances returns the maximum
2248    /// length (in bytes) that this array buffer can be resized to.
2249    ///
2250    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/maxByteLength)
2251    #[wasm_bindgen(method, getter, js_name = maxByteLength)]
2252    pub fn max_byte_length(this: &ArrayBuffer) -> usize;
2253
2254    /// The `resizable` accessor property of `ArrayBuffer` instances returns whether this array buffer
2255    /// can be resized or not.
2256    ///
2257    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/resizable)
2258    #[wasm_bindgen(method, getter)]
2259    pub fn resizable(this: &ArrayBuffer) -> bool;
2260
2261    /// The `resize()` method of ArrayBuffer instances resizes the ArrayBuffer to the
2262    /// specified size, in bytes.
2263    ///
2264    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/resize)
2265    #[wasm_bindgen(method, catch)]
2266    pub fn resize(this: &ArrayBuffer, new_len: usize) -> Result<(), JsValue>;
2267
2268    /// The `slice()` method returns a new `ArrayBuffer` whose contents
2269    /// are a copy of this `ArrayBuffer`'s bytes from begin, inclusive,
2270    /// up to end, exclusive.
2271    ///
2272    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/slice)
2273    #[cfg(not(js_sys_unstable_apis))]
2274    #[wasm_bindgen(method)]
2275    pub fn slice(this: &ArrayBuffer, begin: u32) -> ArrayBuffer;
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. Negative indices count from the end.
2280    ///
2281    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/slice)
2282    #[cfg(js_sys_unstable_apis)]
2283    #[wasm_bindgen(method)]
2284    pub fn slice(this: &ArrayBuffer, begin: isize, end: isize) -> 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.
2289    ///
2290    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/slice)
2291    #[cfg(not(js_sys_unstable_apis))]
2292    #[wasm_bindgen(method, js_name = slice)]
2293    pub fn slice_from(this: &ArrayBuffer, begin: isize) -> ArrayBuffer;
2294
2295    /// The `slice()` method returns a new `ArrayBuffer` whose contents
2296    /// are a copy of this `ArrayBuffer`'s bytes from begin to the end.
2297    /// Negative indices count from the end.
2298    ///
2299    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/slice)
2300    #[cfg(js_sys_unstable_apis)]
2301    #[wasm_bindgen(method, js_name = slice)]
2302    pub fn slice_from(this: &ArrayBuffer, begin: isize) -> ArrayBuffer;
2303
2304    // Next major: deprecate
2305    /// Like `slice()` but with the `end` argument.
2306    ///
2307    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/slice)
2308    #[wasm_bindgen(method, js_name = slice)]
2309    pub fn slice_with_end(this: &ArrayBuffer, begin: u32, end: u32) -> ArrayBuffer;
2310
2311    /// The `transfer()` method of ArrayBuffer instances creates a new `ArrayBuffer`
2312    /// with the same byte content as this buffer, then detaches this buffer.
2313    ///
2314    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/transfer)
2315    #[wasm_bindgen(method, catch)]
2316    pub fn transfer(this: &ArrayBuffer) -> Result<ArrayBuffer, JsValue>;
2317
2318    /// The `transfer()` method of `ArrayBuffer` instances creates a new `ArrayBuffer`
2319    /// with the same byte content as this buffer, then detaches this buffer.
2320    ///
2321    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/transfer)
2322    #[wasm_bindgen(method, catch, js_name = transfer)]
2323    pub fn transfer_with_length(
2324        this: &ArrayBuffer,
2325        new_byte_length: usize,
2326    ) -> Result<ArrayBuffer, JsValue>;
2327
2328    /// The `transferToFixedLength()` method of `ArrayBuffer` instances creates a new non-resizable
2329    /// ArrayBuffer with the same byte content as this buffer, then detaches this buffer.
2330    ///
2331    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/transferToFixedLength)
2332    #[wasm_bindgen(method, catch, js_name = transferToFixedLength)]
2333    pub fn transfer_to_fixed_length(this: &ArrayBuffer) -> Result<ArrayBuffer, JsValue>;
2334
2335    /// The `transferToFixedLength()` method of `ArrayBuffer` instances creates a new non-resizable
2336    /// `ArrayBuffer` with the same byte content as this buffer, then detaches this buffer.
2337    ///
2338    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/transferToFixedLength)
2339    #[wasm_bindgen(method, catch, js_name = transferToFixedLength)]
2340    pub fn transfer_to_fixed_length_with_length(
2341        this: &ArrayBuffer,
2342        new_byte_length: usize,
2343    ) -> Result<ArrayBuffer, JsValue>;
2344}
2345
2346impl UpcastFrom<&[u8]> for ArrayBuffer {}
2347
2348// SharedArrayBuffer
2349#[wasm_bindgen]
2350extern "C" {
2351    #[wasm_bindgen(extends = Object, typescript_type = "SharedArrayBuffer")]
2352    #[derive(Clone, Debug)]
2353    pub type SharedArrayBuffer;
2354
2355    /// The `SharedArrayBuffer` object is used to represent a generic,
2356    /// fixed-length raw binary data buffer, similar to the `ArrayBuffer`
2357    /// object, but in a way that they can be used to create views
2358    /// on shared memory. Unlike an `ArrayBuffer`, a `SharedArrayBuffer`
2359    /// cannot become detached.
2360    ///
2361    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer)
2362    #[cfg(not(js_sys_unstable_apis))]
2363    #[wasm_bindgen(constructor)]
2364    pub fn new(length: u32) -> SharedArrayBuffer;
2365
2366    /// The `SharedArrayBuffer` object is used to represent a generic,
2367    /// fixed-length raw binary data buffer, similar to the `ArrayBuffer`
2368    /// object, but in a way that they can be used to create views
2369    /// on shared memory. Unlike an `ArrayBuffer`, a `SharedArrayBuffer`
2370    /// cannot become detached.
2371    ///
2372    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer)
2373    #[cfg(js_sys_unstable_apis)]
2374    #[wasm_bindgen(constructor)]
2375    pub fn new(length: usize) -> SharedArrayBuffer;
2376
2377    /// The `SharedArrayBuffer` object is used to represent a generic,
2378    /// fixed-length raw binary data buffer, similar to the `ArrayBuffer`
2379    /// object, but in a way that they can be used to create views
2380    /// on shared memory. Unlike an `ArrayBuffer`, a `SharedArrayBuffer`
2381    /// cannot become detached.
2382    ///
2383    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer)
2384    #[wasm_bindgen(constructor)]
2385    pub fn new_with_options(length: usize, options: &ArrayBufferOptions) -> SharedArrayBuffer;
2386
2387    /// The `byteLength` accessor property represents the length of
2388    /// an `SharedArrayBuffer` in bytes. This is established when
2389    /// the `SharedArrayBuffer` is constructed and cannot be changed.
2390    ///
2391    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/byteLength)
2392    #[cfg(not(js_sys_unstable_apis))]
2393    #[wasm_bindgen(method, getter, js_name = byteLength)]
2394    pub fn byte_length(this: &SharedArrayBuffer) -> u32;
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(js_sys_unstable_apis)]
2402    #[wasm_bindgen(method, getter, js_name = byteLength)]
2403    pub fn byte_length(this: &SharedArrayBuffer) -> usize;
2404
2405    /// The `growable` accessor property of `SharedArrayBuffer` instances returns whether
2406    /// this `SharedArrayBuffer` can be grown or not.
2407    ///
2408    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/growable)
2409    #[wasm_bindgen(method, getter)]
2410    pub fn growable(this: &SharedArrayBuffer) -> bool;
2411
2412    /// The `grow()` method of `SharedArrayBuffer` instances grows the
2413    /// `SharedArrayBuffer` to the specified size, in bytes.
2414    ///
2415    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/grow)
2416    #[wasm_bindgen(method, catch)]
2417    pub fn grow(this: &SharedArrayBuffer, new_byte_length: usize) -> Result<(), JsValue>;
2418
2419    /// The `maxByteLength` accessor property of `SharedArrayBuffer` instances returns the maximum
2420    /// length (in bytes) that this `SharedArrayBuffer` can be resized to.
2421    ///
2422    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/maxByteLength)
2423    #[wasm_bindgen(method, getter, js_name = maxByteLength)]
2424    pub fn max_byte_length(this: &SharedArrayBuffer) -> usize;
2425
2426    /// The `slice()` method returns a new `SharedArrayBuffer` whose contents
2427    /// are a copy of this `SharedArrayBuffer`'s bytes from begin, inclusive,
2428    /// up to end, exclusive.
2429    ///
2430    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/slice)
2431    #[cfg(not(js_sys_unstable_apis))]
2432    #[wasm_bindgen(method)]
2433    pub fn slice(this: &SharedArrayBuffer, begin: u32) -> SharedArrayBuffer;
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. Negative indices count from the end.
2438    ///
2439    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/slice)
2440    #[cfg(js_sys_unstable_apis)]
2441    #[wasm_bindgen(method)]
2442    pub fn slice(this: &SharedArrayBuffer, begin: isize, end: isize) -> 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.
2447    ///
2448    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/slice)
2449    #[cfg(not(js_sys_unstable_apis))]
2450    #[wasm_bindgen(method)]
2451    pub fn slice_from(this: &SharedArrayBuffer, begin: isize) -> SharedArrayBuffer;
2452
2453    /// The `slice()` method returns a new `SharedArrayBuffer` whose contents
2454    /// are a copy of this `SharedArrayBuffer`'s bytes from begin to end.
2455    /// Negative indices count from the end.
2456    ///
2457    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/slice)
2458    #[cfg(js_sys_unstable_apis)]
2459    #[wasm_bindgen(method)]
2460    pub fn slice_from(this: &SharedArrayBuffer, begin: isize) -> SharedArrayBuffer;
2461
2462    // Next major: deprecate
2463    /// Like `slice()` but with the `end` argument.
2464    ///
2465    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/slice)
2466    #[wasm_bindgen(method, js_name = slice)]
2467    pub fn slice_with_end(this: &SharedArrayBuffer, begin: u32, end: u32) -> SharedArrayBuffer;
2468}
2469
2470// Array Iterator
2471#[wasm_bindgen]
2472extern "C" {
2473    /// The `keys()` method returns a new Array Iterator object that contains the
2474    /// keys for each index in the array.
2475    ///
2476    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/keys)
2477    #[wasm_bindgen(method)]
2478    pub fn keys<T>(this: &Array<T>) -> Iterator<T>;
2479
2480    /// The `entries()` method returns a new Array Iterator object that contains
2481    /// the key/value pairs for each index in the array.
2482    ///
2483    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/entries)
2484    #[cfg(not(js_sys_unstable_apis))]
2485    #[wasm_bindgen(method)]
2486    #[deprecated(note = "recommended to use `Array::entries_typed` instead for typing")]
2487    #[allow(deprecated)]
2488    pub fn entries<T>(this: &Array<T>) -> Iterator<T>;
2489
2490    /// The `entries()` method returns a new Array Iterator object that contains
2491    /// the key/value pairs for each index in the array.
2492    ///
2493    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/entries)
2494    #[cfg(js_sys_unstable_apis)]
2495    #[wasm_bindgen(method)]
2496    pub fn entries<T: JsGeneric>(this: &Array<T>) -> Iterator<ArrayTuple<(Number, T)>>;
2497
2498    // Next major: deprecate
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    #[wasm_bindgen(method, js_name = entries)]
2504    pub fn entries_typed<T: JsGeneric>(this: &Array<T>) -> Iterator<ArrayTuple<(Number, T)>>;
2505
2506    /// The `values()` method returns a new Array Iterator object that
2507    /// contains the values for each index in the array.
2508    ///
2509    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/values)
2510    #[wasm_bindgen(method)]
2511    pub fn values<T>(this: &Array<T>) -> Iterator<T>;
2512}
2513
2514// FIXME(next-major): rename this trait to `ArrayBufferView`. The DOM/WebIDL
2515// spec name `ArrayBufferView` covers both `DataView` and the typed-array
2516// types, which more accurately reflects the set of types that implement this
2517// trait. The `TypedArray` name is kept for now to avoid a breaking change.
2518pub trait TypedArray: JsGeneric {}
2519
2520impl TypedArray for DataView {}
2521
2522// Next major: use usize/isize for indices
2523/// The `Atomics` object provides atomic operations as static methods.
2524/// They are used with `SharedArrayBuffer` objects.
2525///
2526/// The Atomic operations are installed on an `Atomics` module. Unlike
2527/// the other global objects, `Atomics` is not a constructor. You cannot
2528/// use it with a new operator or invoke the `Atomics` object as a
2529/// function. All properties and methods of `Atomics` are static
2530/// (as is the case with the Math object, for example).
2531/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics)
2532#[allow(non_snake_case)]
2533pub mod Atomics {
2534    use super::*;
2535
2536    #[wasm_bindgen]
2537    extern "C" {
2538        /// The static `Atomics.add()` method adds a given value at a given
2539        /// position in the array and returns the old value at that position.
2540        /// This atomic operation guarantees that no other write happens
2541        /// until the modified value is written back.
2542        ///
2543        /// You should use `add_bigint` to operate on a `BigInt64Array` or a `BigUint64Array`.
2544        ///
2545        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/add)
2546        #[wasm_bindgen(js_namespace = Atomics, catch)]
2547        pub fn add<T: TypedArray = Int32Array>(
2548            typed_array: &T,
2549            index: u32,
2550            value: i32,
2551        ) -> Result<i32, JsValue>;
2552
2553        /// The static `Atomics.add()` method adds a given value at a given
2554        /// position in the array and returns the old value at that position.
2555        /// This atomic operation guarantees that no other write happens
2556        /// until the modified value is written back.
2557        ///
2558        /// This method is used to operate on a `BigInt64Array` or a `BigUint64Array`.
2559        ///
2560        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/add)
2561        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = add)]
2562        pub fn add_bigint<T: TypedArray = Int32Array>(
2563            typed_array: &T,
2564            index: u32,
2565            value: i64,
2566        ) -> Result<i64, JsValue>;
2567
2568        /// The static `Atomics.and()` method computes a bitwise AND with a given
2569        /// value at a given position in the array, and returns the old value
2570        /// at that position.
2571        /// This atomic operation guarantees that no other write happens
2572        /// until the modified value is written back.
2573        ///
2574        /// You should use `and_bigint` to operate on a `BigInt64Array` or a `BigUint64Array`.
2575        ///
2576        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/and)
2577        #[wasm_bindgen(js_namespace = Atomics, catch)]
2578        pub fn and<T: TypedArray = Int32Array>(
2579            typed_array: &T,
2580            index: u32,
2581            value: i32,
2582        ) -> Result<i32, JsValue>;
2583
2584        /// The static `Atomics.and()` method computes a bitwise AND with a given
2585        /// value at a given position in the array, and returns the old value
2586        /// at that position.
2587        /// This atomic operation guarantees that no other write happens
2588        /// until the modified value is written back.
2589        ///
2590        /// This method is used to operate on a `BigInt64Array` or a `BigUint64Array`.
2591        ///
2592        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/and)
2593        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = and)]
2594        pub fn and_bigint<T: TypedArray = Int32Array>(
2595            typed_array: &T,
2596            index: u32,
2597            value: i64,
2598        ) -> Result<i64, JsValue>;
2599
2600        /// The static `Atomics.compareExchange()` method exchanges a given
2601        /// replacement value at a given position in the array, if a given expected
2602        /// value equals the old value. It returns the old value at that position
2603        /// whether it was equal to the expected value or not.
2604        /// This atomic operation guarantees that no other write happens
2605        /// until the modified value is written back.
2606        ///
2607        /// You should use `compare_exchange_bigint` to operate on a `BigInt64Array` or a `BigUint64Array`.
2608        ///
2609        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/compareExchange)
2610        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = compareExchange)]
2611        pub fn compare_exchange<T: TypedArray = Int32Array>(
2612            typed_array: &T,
2613            index: u32,
2614            expected_value: i32,
2615            replacement_value: i32,
2616        ) -> Result<i32, JsValue>;
2617
2618        /// The static `Atomics.compareExchange()` method exchanges a given
2619        /// replacement value at a given position in the array, if a given expected
2620        /// value equals the old value. It returns the old value at that position
2621        /// whether it was equal to the expected value or not.
2622        /// This atomic operation guarantees that no other write happens
2623        /// until the modified value is written back.
2624        ///
2625        /// This method is used to operate on a `BigInt64Array` or a `BigUint64Array`.
2626        ///
2627        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/compareExchange)
2628        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = compareExchange)]
2629        pub fn compare_exchange_bigint<T: TypedArray = Int32Array>(
2630            typed_array: &T,
2631            index: u32,
2632            expected_value: i64,
2633            replacement_value: i64,
2634        ) -> Result<i64, JsValue>;
2635
2636        /// The static `Atomics.exchange()` method stores a given value at a given
2637        /// position in the array and returns the old value at that position.
2638        /// This atomic operation guarantees that no other write happens
2639        /// until the modified value is written back.
2640        ///
2641        /// You should use `exchange_bigint` to operate on a `BigInt64Array` or a `BigUint64Array`.
2642        ///
2643        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/exchange)
2644        #[wasm_bindgen(js_namespace = Atomics, catch)]
2645        pub fn exchange<T: TypedArray = Int32Array>(
2646            typed_array: &T,
2647            index: u32,
2648            value: i32,
2649        ) -> Result<i32, JsValue>;
2650
2651        /// The static `Atomics.exchange()` method stores a given value at a given
2652        /// position in the array and returns the old value at that position.
2653        /// This atomic operation guarantees that no other write happens
2654        /// until the modified value is written back.
2655        ///
2656        /// This method is used to operate on a `BigInt64Array` or a `BigUint64Array`.
2657        ///
2658        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/exchange)
2659        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = exchange)]
2660        pub fn exchange_bigint<T: TypedArray = Int32Array>(
2661            typed_array: &T,
2662            index: u32,
2663            value: i64,
2664        ) -> Result<i64, JsValue>;
2665
2666        /// The static `Atomics.isLockFree()` method is used to determine
2667        /// whether to use locks or atomic operations. It returns true,
2668        /// if the given size is one of the `BYTES_PER_ELEMENT` property
2669        /// of integer `TypedArray` types.
2670        ///
2671        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/isLockFree)
2672        #[wasm_bindgen(js_namespace = Atomics, js_name = isLockFree)]
2673        pub fn is_lock_free(size: u32) -> bool;
2674
2675        /// The static `Atomics.load()` method returns a value at a given
2676        /// position in the array.
2677        ///
2678        /// You should use `load_bigint` to operate on a `BigInt64Array` or a `BigUint64Array`.
2679        ///
2680        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/load)
2681        #[wasm_bindgen(js_namespace = Atomics, catch)]
2682        pub fn load<T: TypedArray = Int32Array>(
2683            typed_array: &T,
2684            index: u32,
2685        ) -> Result<i32, JsValue>;
2686
2687        /// The static `Atomics.load()` method returns a value at a given
2688        /// position in the array.
2689        ///
2690        /// This method is used to operate on a `BigInt64Array` or a `BigUint64Array`.
2691        ///
2692        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/load)
2693        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = load)]
2694        pub fn load_bigint<T: TypedArray = Int32Array>(
2695            typed_array: &T,
2696            index: i64,
2697        ) -> Result<i64, JsValue>;
2698
2699        /// The static `Atomics.notify()` method notifies up some agents that
2700        /// are sleeping in the wait queue.
2701        /// Note: This operation works with a shared `Int32Array` only.
2702        /// If `count` is not provided, notifies all the agents in the queue.
2703        ///
2704        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/notify)
2705        #[wasm_bindgen(js_namespace = Atomics, catch)]
2706        pub fn notify(typed_array: &Int32Array, index: u32) -> Result<u32, 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_bigint(typed_array: &BigInt64Array, index: u32) -> Result<u32, JsValue>;
2716
2717        /// Notifies up to `count` agents in the wait queue.
2718        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = notify)]
2719        pub fn notify_with_count(
2720            typed_array: &Int32Array,
2721            index: u32,
2722            count: u32,
2723        ) -> Result<u32, JsValue>;
2724
2725        /// Notifies up to `count` agents in the wait queue.
2726        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = notify)]
2727        pub fn notify_bigint_with_count(
2728            typed_array: &BigInt64Array,
2729            index: u32,
2730            count: u32,
2731        ) -> Result<u32, JsValue>;
2732
2733        /// The static `Atomics.or()` method computes a bitwise OR with a given value
2734        /// at a given position in the array, and returns the old value at that position.
2735        /// This atomic operation guarantees that no other write happens
2736        /// until the modified value is written back.
2737        ///
2738        /// You should use `or_bigint` to operate on a `BigInt64Array` or a `BigUint64Array`.
2739        ///
2740        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/or)
2741        #[wasm_bindgen(js_namespace = Atomics, catch)]
2742        pub fn or<T: TypedArray = Int32Array>(
2743            typed_array: &T,
2744            index: u32,
2745            value: i32,
2746        ) -> Result<i32, JsValue>;
2747
2748        /// The static `Atomics.or()` method computes a bitwise OR with a given value
2749        /// at a given position in the array, and returns the old value at that position.
2750        /// This atomic operation guarantees that no other write happens
2751        /// until the modified value is written back.
2752        ///
2753        /// This method is used to operate on a `BigInt64Array` or a `BigUint64Array`.
2754        ///
2755        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/or)
2756        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = or)]
2757        pub fn or_bigint<T: TypedArray = Int32Array>(
2758            typed_array: &T,
2759            index: u32,
2760            value: i64,
2761        ) -> Result<i64, JsValue>;
2762
2763        /// The static `Atomics.pause()` static method provides a micro-wait primitive that hints to the CPU
2764        /// that the caller is spinning while waiting on access to a shared resource. This allows the system
2765        /// to reduce the resources allocated to the core (such as power) or thread, without yielding the
2766        /// current thread.
2767        ///
2768        /// `pause()` has no observable behavior other than timing. The exact behavior is dependent on the CPU
2769        /// architecture and the operating system. For example, in Intel x86, it may be a pause instruction as
2770        /// per Intel's optimization manual. It could be a no-op in certain platforms.
2771        ///
2772        /// This method is used to operate on a `BigInt64Array` or a `BigUint64Array`.
2773        ///
2774        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/xor)
2775        #[wasm_bindgen(js_namespace = Atomics)]
2776        pub fn pause();
2777
2778        /// The static `Atomics.pause()` static method provides a micro-wait primitive that hints to the CPU
2779        /// that the caller is spinning while waiting on access to a shared resource. This allows the system
2780        /// to reduce the resources allocated to the core (such as power) or thread, without yielding the
2781        /// current thread.
2782        ///
2783        /// `pause()` has no observable behavior other than timing. The exact behavior is dependent on the CPU
2784        /// architecture and the operating system. For example, in Intel x86, it may be a pause instruction as
2785        /// per Intel's optimization manual. It could be a no-op in certain platforms.
2786        ///
2787        /// This method is used to operate on a `BigInt64Array` or a `BigUint64Array`.
2788        ///
2789        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/xor)
2790        #[wasm_bindgen(js_namespace = Atomics)]
2791        pub fn pause_with_hint(duration_hint: u32);
2792
2793        /// The static `Atomics.store()` method stores a given value at the given
2794        /// position in the array and returns that value.
2795        ///
2796        /// You should use `store_bigint` 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/store)
2799        #[wasm_bindgen(js_namespace = Atomics, catch)]
2800        pub fn store<T: TypedArray = Int32Array>(
2801            typed_array: &T,
2802            index: u32,
2803            value: i32,
2804        ) -> Result<i32, JsValue>;
2805
2806        /// The static `Atomics.store()` method stores a given value at the given
2807        /// position in the array and returns that value.
2808        ///
2809        /// This method is used to operate on a `BigInt64Array` or a `BigUint64Array`.
2810        ///
2811        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/store)
2812        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = store)]
2813        pub fn store_bigint<T: TypedArray = Int32Array>(
2814            typed_array: &T,
2815            index: u32,
2816            value: i64,
2817        ) -> Result<i64, JsValue>;
2818
2819        /// The static `Atomics.sub()` method subtracts a given value at a
2820        /// given position in the array and returns the old value at that position.
2821        /// This atomic operation guarantees that no other write happens
2822        /// until the modified value is written back.
2823        ///
2824        /// You should use `sub_bigint` to operate on a `BigInt64Array` or a `BigUint64Array`.
2825        ///
2826        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/sub)
2827        #[wasm_bindgen(js_namespace = Atomics, catch)]
2828        pub fn sub<T: TypedArray = Int32Array>(
2829            typed_array: &T,
2830            index: u32,
2831            value: i32,
2832        ) -> Result<i32, JsValue>;
2833
2834        /// The static `Atomics.sub()` method subtracts a given value at a
2835        /// given position in the array and returns the old value at that position.
2836        /// This atomic operation guarantees that no other write happens
2837        /// until the modified value is written back.
2838        ///
2839        /// This method is used to operate on a `BigInt64Array` or a `BigUint64Array`.
2840        ///
2841        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/sub)
2842        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = sub)]
2843        pub fn sub_bigint<T: TypedArray = Int32Array>(
2844            typed_array: &T,
2845            index: u32,
2846            value: i64,
2847        ) -> Result<i64, JsValue>;
2848
2849        /// The static `Atomics.wait()` method verifies that a given
2850        /// position in an `Int32Array` still contains a given value
2851        /// and if so sleeps, awaiting a wakeup or a timeout.
2852        /// It returns a string which is either "ok", "not-equal", or "timed-out".
2853        /// Note: This operation only works with a shared `Int32Array`
2854        /// and may not be allowed on the main thread.
2855        ///
2856        /// You should use `wait_bigint` to operate on a `BigInt64Array`.
2857        ///
2858        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/wait)
2859        #[wasm_bindgen(js_namespace = Atomics, catch)]
2860        pub fn wait(typed_array: &Int32Array, index: u32, value: i32) -> Result<JsString, JsValue>;
2861
2862        /// The static `Atomics.wait()` method verifies that a given
2863        /// position in an `BigInt64Array` still contains a given value
2864        /// and if so sleeps, awaiting a wakeup or a timeout.
2865        /// It returns a string which is either "ok", "not-equal", or "timed-out".
2866        /// Note: This operation only works with a shared `BigInt64Array`
2867        /// and may not be allowed on the main thread.
2868        ///
2869        /// You should use `wait` to operate on a `Int32Array`.
2870        ///
2871        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/wait)
2872        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = wait)]
2873        pub fn wait_bigint(
2874            typed_array: &BigInt64Array,
2875            index: u32,
2876            value: i64,
2877        ) -> Result<JsString, JsValue>;
2878
2879        /// Like `wait()`, but with timeout
2880        ///
2881        /// You should use `wait_with_timeout_bigint` to operate on a `BigInt64Array`.
2882        ///
2883        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/wait)
2884        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = wait)]
2885        pub fn wait_with_timeout(
2886            typed_array: &Int32Array,
2887            index: u32,
2888            value: i32,
2889            timeout: f64,
2890        ) -> Result<JsString, JsValue>;
2891
2892        /// Like `wait()`, but with timeout
2893        ///
2894        /// You should use `wait_with_timeout` to operate on a `Int32Array`.
2895        ///
2896        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/wait)
2897        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = wait)]
2898        pub fn wait_with_timeout_bigint(
2899            typed_array: &BigInt64Array,
2900            index: u32,
2901            value: i64,
2902            timeout: f64,
2903        ) -> Result<JsString, JsValue>;
2904
2905        /// The static `Atomics.waitAsync()` method verifies that a given position in an
2906        /// `Int32Array` still contains a given value and if so sleeps, awaiting a
2907        /// wakeup or a timeout. It returns an object with two properties. The first
2908        /// property `async` is a boolean which if true indicates that the second
2909        /// property `value` is a promise. If `async` is false then value is a string
2910        /// whether equal to either "not-equal" or "timed-out".
2911        /// Note: This operation only works with a shared `Int32Array` and may be used
2912        /// on the main thread.
2913        ///
2914        /// You should use `wait_async_bigint` to operate on a `BigInt64Array`.
2915        ///
2916        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/waitAsync)
2917        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = waitAsync)]
2918        pub fn wait_async(
2919            typed_array: &Int32Array,
2920            index: u32,
2921            value: i32,
2922        ) -> Result<Object, JsValue>;
2923
2924        /// The static `Atomics.waitAsync()` method verifies that a given position in an
2925        /// `Int32Array` still contains a given value and if so sleeps, awaiting a
2926        /// wakeup or a timeout. It returns an object with two properties. The first
2927        /// property `async` is a boolean which if true indicates that the second
2928        /// property `value` is a promise. If `async` is false then value is a string
2929        /// whether equal to either "not-equal" or "timed-out".
2930        /// Note: This operation only works with a shared `BigInt64Array` and may be used
2931        /// on the main thread.
2932        ///
2933        /// You should use `wait_async` to operate on a `Int32Array`.
2934        ///
2935        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/waitAsync)
2936        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = waitAsync)]
2937        pub fn wait_async_bigint(
2938            typed_array: &BigInt64Array,
2939            index: u32,
2940            value: i64,
2941        ) -> Result<Object, JsValue>;
2942
2943        /// Like `waitAsync()`, but with timeout
2944        ///
2945        /// You should use `wait_async_with_timeout_bigint` to operate on a `BigInt64Array`.
2946        ///
2947        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/waitAsync)
2948        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = waitAsync)]
2949        pub fn wait_async_with_timeout(
2950            typed_array: &Int32Array,
2951            index: u32,
2952            value: i32,
2953            timeout: f64,
2954        ) -> Result<Object, JsValue>;
2955
2956        /// Like `waitAsync()`, but with timeout
2957        ///
2958        /// You should use `wait_async_with_timeout` to operate on a `Int32Array`.
2959        ///
2960        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/waitAsync)
2961        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = waitAsync)]
2962        pub fn wait_async_with_timeout_bigint(
2963            typed_array: &BigInt64Array,
2964            index: u32,
2965            value: i64,
2966            timeout: f64,
2967        ) -> Result<Object, JsValue>;
2968
2969        /// The static `Atomics.xor()` method computes a bitwise XOR
2970        /// with a given value at a given position in the array,
2971        /// and returns the old value at that position.
2972        /// This atomic operation guarantees that no other write happens
2973        /// until the modified value is written back.
2974        ///
2975        /// You should use `xor_bigint` to operate on a `BigInt64Array` or a `BigUint64Array`.
2976        ///
2977        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/xor)
2978        #[wasm_bindgen(js_namespace = Atomics, catch)]
2979        pub fn xor<T: TypedArray = Int32Array>(
2980            typed_array: &T,
2981            index: u32,
2982            value: i32,
2983        ) -> Result<i32, JsValue>;
2984
2985        /// The static `Atomics.xor()` method computes a bitwise XOR
2986        /// with a given value at a given position in the array,
2987        /// and returns the old value at that position.
2988        /// This atomic operation guarantees that no other write happens
2989        /// until the modified value is written back.
2990        ///
2991        /// This method is used to operate on a `BigInt64Array` or a `BigUint64Array`.
2992        ///
2993        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/xor)
2994        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = xor)]
2995        pub fn xor_bigint<T: TypedArray = Int32Array>(
2996            typed_array: &T,
2997            index: u32,
2998            value: i64,
2999        ) -> Result<i64, JsValue>;
3000    }
3001}
3002
3003// BigInt
3004#[wasm_bindgen]
3005extern "C" {
3006    #[wasm_bindgen(extends = Object, is_type_of = |v| v.is_bigint(), typescript_type = "bigint")]
3007    #[derive(Clone, PartialEq, Eq)]
3008    pub type BigInt;
3009
3010    #[wasm_bindgen(catch, js_name = BigInt)]
3011    fn new_bigint(value: &JsValue) -> Result<BigInt, Error>;
3012
3013    #[wasm_bindgen(js_name = BigInt)]
3014    fn new_bigint_unchecked(value: &JsValue) -> BigInt;
3015
3016    /// Clamps a BigInt value to a signed integer value, and returns that value.
3017    ///
3018    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/asIntN)
3019    #[wasm_bindgen(static_method_of = BigInt, js_name = asIntN)]
3020    pub fn as_int_n(bits: f64, bigint: &BigInt) -> BigInt;
3021
3022    /// Clamps a BigInt value to an unsigned integer value, and returns that value.
3023    ///
3024    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/asUintN)
3025    #[wasm_bindgen(static_method_of = BigInt, js_name = asUintN)]
3026    pub fn as_uint_n(bits: f64, bigint: &BigInt) -> BigInt;
3027
3028    /// 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.
3029    ///
3030    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/toLocaleString)
3031    #[cfg(not(js_sys_unstable_apis))]
3032    #[wasm_bindgen(method, js_name = toLocaleString)]
3033    pub fn to_locale_string(this: &BigInt, locales: &JsValue, options: &JsValue) -> JsString;
3034
3035    /// 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.
3036    ///
3037    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/toLocaleString)
3038    #[cfg(js_sys_unstable_apis)]
3039    #[wasm_bindgen(method, js_name = toLocaleString)]
3040    pub fn to_locale_string(
3041        this: &BigInt,
3042        locales: &[JsString],
3043        options: &Intl::NumberFormatOptions,
3044    ) -> JsString;
3045
3046    // Next major: deprecate
3047    /// 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.
3048    ///
3049    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/toString)
3050    #[wasm_bindgen(catch, method, js_name = toString)]
3051    pub fn to_string(this: &BigInt, radix: u8) -> Result<JsString, RangeError>;
3052
3053    /// Returns a string representing this BigInt value in the specified radix (base).
3054    ///
3055    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/toString)
3056    #[cfg(js_sys_unstable_apis)]
3057    #[wasm_bindgen(catch, method, js_name = toString)]
3058    pub fn to_string_with_radix(this: &BigInt, radix: u8) -> Result<JsString, RangeError>;
3059
3060    #[wasm_bindgen(method, js_name = toString)]
3061    fn to_string_unchecked(this: &BigInt, radix: u8) -> String;
3062
3063    /// Returns this BigInt value. Overrides the [`Object.prototype.valueOf()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/valueOf) method.
3064    ///
3065    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/valueOf)
3066    #[wasm_bindgen(method, js_name = valueOf)]
3067    pub fn value_of(this: &BigInt, radix: u8) -> BigInt;
3068}
3069
3070impl BigInt {
3071    /// Creates a new BigInt value.
3072    ///
3073    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/BigInt)
3074    #[inline]
3075    pub fn new(value: &JsValue) -> Result<BigInt, Error> {
3076        new_bigint(value)
3077    }
3078
3079    /// Applies the binary `/` JS operator on two `BigInt`s, catching and returning any `RangeError` thrown.
3080    ///
3081    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Division)
3082    pub fn checked_div(&self, rhs: &Self) -> Result<Self, RangeError> {
3083        let result = JsValue::as_ref(self).checked_div(JsValue::as_ref(rhs));
3084
3085        if result.is_instance_of::<RangeError>() {
3086            Err(result.unchecked_into())
3087        } else {
3088            Ok(result.unchecked_into())
3089        }
3090    }
3091
3092    /// Applies the binary `**` JS operator on the two `BigInt`s.
3093    ///
3094    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Exponentiation)
3095    #[inline]
3096    pub fn pow(&self, rhs: &Self) -> Self {
3097        JsValue::as_ref(self)
3098            .pow(JsValue::as_ref(rhs))
3099            .unchecked_into()
3100    }
3101
3102    /// Returns a tuple of this [`BigInt`]'s absolute value along with a
3103    /// [`bool`] indicating whether the [`BigInt`] was negative.
3104    fn abs(&self) -> (Self, bool) {
3105        if self < &BigInt::from(0) {
3106            (-self, true)
3107        } else {
3108            (self.clone(), false)
3109        }
3110    }
3111}
3112
3113macro_rules! bigint_from {
3114    ($($x:ident)*) => ($(
3115        impl From<$x> for BigInt {
3116            #[inline]
3117            fn from(x: $x) -> BigInt {
3118                new_bigint_unchecked(&JsValue::from(x))
3119            }
3120        }
3121
3122        impl PartialEq<$x> for BigInt {
3123            #[inline]
3124            fn eq(&self, other: &$x) -> bool {
3125                JsValue::from(self) == JsValue::from(BigInt::from(*other))
3126            }
3127        }
3128    )*)
3129}
3130bigint_from!(i8 u8 i16 u16 i32 u32 isize usize);
3131
3132macro_rules! bigint_from_big {
3133    ($($x:ident)*) => ($(
3134        impl From<$x> for BigInt {
3135            #[inline]
3136            fn from(x: $x) -> BigInt {
3137                JsValue::from(x).unchecked_into()
3138            }
3139        }
3140
3141        impl PartialEq<$x> for BigInt {
3142            #[inline]
3143            fn eq(&self, other: &$x) -> bool {
3144                self == &BigInt::from(*other)
3145            }
3146        }
3147
3148        impl TryFrom<BigInt> for $x {
3149            type Error = BigInt;
3150
3151            #[inline]
3152            fn try_from(x: BigInt) -> Result<Self, BigInt> {
3153                Self::try_from(JsValue::from(x)).map_err(JsCast::unchecked_into)
3154            }
3155        }
3156    )*)
3157}
3158bigint_from_big!(i64 u64 i128 u128);
3159
3160impl PartialEq<Number> for BigInt {
3161    #[inline]
3162    fn eq(&self, other: &Number) -> bool {
3163        JsValue::as_ref(self).loose_eq(JsValue::as_ref(other))
3164    }
3165}
3166
3167impl Not for &BigInt {
3168    type Output = BigInt;
3169
3170    #[inline]
3171    fn not(self) -> Self::Output {
3172        JsValue::as_ref(self).bit_not().unchecked_into()
3173    }
3174}
3175
3176forward_deref_unop!(impl Not, not for BigInt);
3177forward_js_unop!(impl Neg, neg for BigInt);
3178forward_js_binop!(impl BitAnd, bitand for BigInt);
3179forward_js_binop!(impl BitOr, bitor for BigInt);
3180forward_js_binop!(impl BitXor, bitxor for BigInt);
3181forward_js_binop!(impl Shl, shl for BigInt);
3182forward_js_binop!(impl Shr, shr for BigInt);
3183forward_js_binop!(impl Add, add for BigInt);
3184forward_js_binop!(impl Sub, sub for BigInt);
3185forward_js_binop!(impl Div, div for BigInt);
3186forward_js_binop!(impl Mul, mul for BigInt);
3187forward_js_binop!(impl Rem, rem for BigInt);
3188sum_product!(BigInt);
3189
3190partialord_ord!(BigInt);
3191
3192impl Default for BigInt {
3193    fn default() -> Self {
3194        BigInt::from(i32::default())
3195    }
3196}
3197
3198impl FromStr for BigInt {
3199    type Err = Error;
3200
3201    #[inline]
3202    fn from_str(s: &str) -> Result<Self, Self::Err> {
3203        BigInt::new(&s.into())
3204    }
3205}
3206
3207impl fmt::Debug for BigInt {
3208    #[inline]
3209    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3210        fmt::Display::fmt(self, f)
3211    }
3212}
3213
3214impl fmt::Display for BigInt {
3215    #[inline]
3216    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3217        let (abs, is_neg) = self.abs();
3218        f.pad_integral(!is_neg, "", &abs.to_string_unchecked(10))
3219    }
3220}
3221
3222impl fmt::Binary for BigInt {
3223    #[inline]
3224    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3225        let (abs, is_neg) = self.abs();
3226        f.pad_integral(!is_neg, "0b", &abs.to_string_unchecked(2))
3227    }
3228}
3229
3230impl fmt::Octal for BigInt {
3231    #[inline]
3232    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3233        let (abs, is_neg) = self.abs();
3234        f.pad_integral(!is_neg, "0o", &abs.to_string_unchecked(8))
3235    }
3236}
3237
3238impl fmt::LowerHex for BigInt {
3239    #[inline]
3240    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3241        let (abs, is_neg) = self.abs();
3242        f.pad_integral(!is_neg, "0x", &abs.to_string_unchecked(16))
3243    }
3244}
3245
3246impl fmt::UpperHex for BigInt {
3247    #[inline]
3248    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3249        let (abs, is_neg) = self.abs();
3250        let mut s: String = abs.to_string_unchecked(16);
3251        s.make_ascii_uppercase();
3252        f.pad_integral(!is_neg, "0x", &s)
3253    }
3254}
3255
3256// Boolean
3257#[wasm_bindgen]
3258extern "C" {
3259    #[wasm_bindgen(extends = Object, is_type_of = |v| v.as_bool().is_some(), typescript_type = "boolean")]
3260    #[derive(Clone, PartialEq, Eq)]
3261    pub type Boolean;
3262
3263    /// The `Boolean()` constructor creates an object wrapper for a boolean value.
3264    ///
3265    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)
3266    #[cfg(not(js_sys_unstable_apis))]
3267    #[wasm_bindgen(constructor)]
3268    #[deprecated(note = "recommended to use `Boolean::from` instead")]
3269    #[allow(deprecated)]
3270    pub fn new(value: &JsValue) -> Boolean;
3271
3272    /// The `valueOf()` method returns the primitive value of a `Boolean` object.
3273    ///
3274    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean/valueOf)
3275    #[wasm_bindgen(method, js_name = valueOf)]
3276    pub fn value_of(this: &Boolean) -> bool;
3277}
3278
3279impl UpcastFrom<bool> for Boolean {}
3280impl UpcastFrom<Boolean> for bool {}
3281
3282impl Boolean {
3283    /// Typed Boolean true constant.
3284    pub const TRUE: Boolean = Self {
3285        obj: Object {
3286            obj: JsValue::TRUE,
3287            generics: PhantomData,
3288        },
3289    };
3290
3291    /// Typed Boolean false constant.
3292    pub const FALSE: Boolean = Self {
3293        obj: Object {
3294            obj: JsValue::FALSE,
3295            generics: PhantomData,
3296        },
3297    };
3298}
3299
3300impl From<bool> for Boolean {
3301    #[inline]
3302    fn from(b: bool) -> Boolean {
3303        Boolean::unchecked_from_js(JsValue::from(b))
3304    }
3305}
3306
3307impl From<Boolean> for bool {
3308    #[inline]
3309    fn from(b: Boolean) -> bool {
3310        b.value_of()
3311    }
3312}
3313
3314impl PartialEq<bool> for Boolean {
3315    #[inline]
3316    fn eq(&self, other: &bool) -> bool {
3317        self.value_of() == *other
3318    }
3319}
3320
3321impl fmt::Debug for Boolean {
3322    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
3323        fmt::Debug::fmt(&self.value_of(), f)
3324    }
3325}
3326
3327impl fmt::Display for Boolean {
3328    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
3329        fmt::Display::fmt(&self.value_of(), f)
3330    }
3331}
3332
3333impl Default for Boolean {
3334    fn default() -> Self {
3335        Self::from(bool::default())
3336    }
3337}
3338
3339impl Not for &Boolean {
3340    type Output = Boolean;
3341
3342    #[inline]
3343    fn not(self) -> Self::Output {
3344        (!JsValue::as_ref(self)).into()
3345    }
3346}
3347
3348forward_deref_unop!(impl Not, not for Boolean);
3349
3350partialord_ord!(Boolean);
3351
3352// DataView
3353#[wasm_bindgen]
3354extern "C" {
3355    #[wasm_bindgen(extends = Object, typescript_type = "DataView")]
3356    #[derive(Clone, Debug, PartialEq, Eq)]
3357    pub type DataView;
3358
3359    /// The `DataView` view provides a low-level interface for reading and
3360    /// writing multiple number types in an `ArrayBuffer` irrespective of the
3361    /// platform's endianness.
3362    ///
3363    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView)
3364    #[wasm_bindgen(constructor)]
3365    pub fn new(buffer: &ArrayBuffer, byteOffset: usize, byteLength: usize) -> DataView;
3366
3367    /// The `DataView` view provides a low-level interface for reading and
3368    /// writing multiple number types in an `ArrayBuffer` irrespective of the
3369    /// platform's endianness.
3370    ///
3371    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView)
3372    #[wasm_bindgen(constructor)]
3373    pub fn new_with_shared_array_buffer(
3374        buffer: &SharedArrayBuffer,
3375        byteOffset: usize,
3376        byteLength: usize,
3377    ) -> DataView;
3378
3379    /// The ArrayBuffer referenced by this view. Fixed at construction time and thus read only.
3380    ///
3381    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/buffer)
3382    #[wasm_bindgen(method, getter)]
3383    pub fn buffer(this: &DataView) -> ArrayBuffer;
3384
3385    /// The length (in bytes) of this view from the start of its ArrayBuffer.
3386    /// Fixed at construction time and thus read only.
3387    ///
3388    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/byteLength)
3389    #[wasm_bindgen(method, getter, js_name = byteLength)]
3390    pub fn byte_length(this: &DataView) -> usize;
3391
3392    /// The offset (in bytes) of this view from the start of its ArrayBuffer.
3393    /// Fixed at construction time and thus read only.
3394    ///
3395    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/byteOffset)
3396    #[wasm_bindgen(method, getter, js_name = byteOffset)]
3397    pub fn byte_offset(this: &DataView) -> usize;
3398
3399    /// The `getInt8()` method gets a signed 8-bit integer (byte) at the
3400    /// specified byte offset from the start of the DataView.
3401    ///
3402    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getInt8)
3403    #[wasm_bindgen(method, js_name = getInt8)]
3404    pub fn get_int8(this: &DataView, byte_offset: usize) -> i8;
3405
3406    /// The `getUint8()` method gets a unsigned 8-bit integer (byte) at the specified
3407    /// byte offset from the start of the DataView.
3408    ///
3409    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getUint8)
3410    #[wasm_bindgen(method, js_name = getUint8)]
3411    pub fn get_uint8(this: &DataView, byte_offset: usize) -> u8;
3412
3413    /// The `getInt16()` method gets a signed 16-bit integer (short) at the specified
3414    /// byte offset from the start of the DataView.
3415    ///
3416    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getInt16)
3417    #[wasm_bindgen(method, js_name = getInt16)]
3418    pub fn get_int16(this: &DataView, byte_offset: usize) -> i16;
3419
3420    /// The `getInt16()` method gets a signed 16-bit integer (short) at the specified
3421    /// byte offset from the start of the DataView.
3422    ///
3423    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getInt16)
3424    #[wasm_bindgen(method, js_name = getInt16)]
3425    pub fn get_int16_endian(this: &DataView, byte_offset: usize, little_endian: bool) -> i16;
3426
3427    /// The `getUint16()` method gets an unsigned 16-bit integer (unsigned short) at the specified
3428    /// byte offset from the start of the view.
3429    ///
3430    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getUint16)
3431    #[wasm_bindgen(method, js_name = getUint16)]
3432    pub fn get_uint16(this: &DataView, byte_offset: usize) -> u16;
3433
3434    /// The `getUint16()` method gets an unsigned 16-bit integer (unsigned short) at the specified
3435    /// byte offset from the start of the view.
3436    ///
3437    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getUint16)
3438    #[wasm_bindgen(method, js_name = getUint16)]
3439    pub fn get_uint16_endian(this: &DataView, byte_offset: usize, little_endian: bool) -> u16;
3440
3441    /// The `getInt32()` method gets a signed 32-bit integer (long) at the specified
3442    /// byte offset from the start of the DataView.
3443    ///
3444    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getInt32)
3445    #[wasm_bindgen(method, js_name = getInt32)]
3446    pub fn get_int32(this: &DataView, byte_offset: usize) -> i32;
3447
3448    /// The `getInt32()` method gets a signed 32-bit integer (long) at the specified
3449    /// byte offset from the start of the DataView.
3450    ///
3451    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getInt32)
3452    #[wasm_bindgen(method, js_name = getInt32)]
3453    pub fn get_int32_endian(this: &DataView, byte_offset: usize, little_endian: bool) -> i32;
3454
3455    /// The `getUint32()` method gets an unsigned 32-bit integer (unsigned long) at the specified
3456    /// byte offset from the start of the view.
3457    ///
3458    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getUint32)
3459    #[wasm_bindgen(method, js_name = getUint32)]
3460    pub fn get_uint32(this: &DataView, byte_offset: usize) -> u32;
3461
3462    /// The `getUint32()` method gets an unsigned 32-bit integer (unsigned long) at the specified
3463    /// byte offset from the start of the view.
3464    ///
3465    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getUint32)
3466    #[wasm_bindgen(method, js_name = getUint32)]
3467    pub fn get_uint32_endian(this: &DataView, byte_offset: usize, little_endian: bool) -> u32;
3468
3469    /// The `getFloat32()` method gets a signed 32-bit float (float) at the specified
3470    /// byte offset from the start of the DataView.
3471    ///
3472    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getFloat32)
3473    #[wasm_bindgen(method, js_name = getFloat32)]
3474    pub fn get_float32(this: &DataView, byte_offset: usize) -> f32;
3475
3476    /// The `getFloat32()` method gets a signed 32-bit float (float) at the specified
3477    /// byte offset from the start of the DataView.
3478    ///
3479    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getFloat32)
3480    #[wasm_bindgen(method, js_name = getFloat32)]
3481    pub fn get_float32_endian(this: &DataView, byte_offset: usize, little_endian: bool) -> f32;
3482
3483    /// The `getFloat16()` method gets a signed 16-bit float at the specified
3484    /// byte offset from the start of the DataView as an `f32`.
3485    ///
3486    /// The unsuffixed `get_float16` name is reserved for a future native
3487    /// `f16` binding once Rust stabilizes the type.
3488    ///
3489    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getFloat16)
3490    #[wasm_bindgen(method, js_name = getFloat16)]
3491    pub fn get_float16_as_f32(this: &DataView, byte_offset: usize) -> f32;
3492
3493    /// The `getFloat16()` method gets a signed 16-bit float at the specified
3494    /// byte offset from the start of the DataView as an `f32`.
3495    ///
3496    /// The unsuffixed `get_float16_endian` name is reserved for a future
3497    /// native `f16` binding once Rust stabilizes the type.
3498    ///
3499    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getFloat16)
3500    #[wasm_bindgen(method, js_name = getFloat16)]
3501    pub fn get_float16_endian_as_f32(
3502        this: &DataView,
3503        byte_offset: usize,
3504        little_endian: bool,
3505    ) -> f32;
3506
3507    /// The `getFloat64()` method gets a signed 64-bit float (double) at the specified
3508    /// byte offset from the start of the DataView.
3509    ///
3510    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getFloat64)
3511    #[wasm_bindgen(method, js_name = getFloat64)]
3512    pub fn get_float64(this: &DataView, byte_offset: usize) -> f64;
3513
3514    /// The `getFloat64()` method gets a signed 64-bit float (double) at the specified
3515    /// byte offset from the start of the DataView.
3516    ///
3517    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getFloat64)
3518    #[wasm_bindgen(method, js_name = getFloat64)]
3519    pub fn get_float64_endian(this: &DataView, byte_offset: usize, little_endian: bool) -> f64;
3520
3521    /// The `setInt8()` method stores a signed 8-bit integer (byte) value at the
3522    /// specified byte offset from the start of the DataView.
3523    ///
3524    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setInt8)
3525    #[wasm_bindgen(method, js_name = setInt8)]
3526    pub fn set_int8(this: &DataView, byte_offset: usize, value: i8);
3527
3528    /// The `setUint8()` method stores an unsigned 8-bit integer (byte) value at the
3529    /// specified byte offset from the start of the DataView.
3530    ///
3531    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setUint8)
3532    #[wasm_bindgen(method, js_name = setUint8)]
3533    pub fn set_uint8(this: &DataView, byte_offset: usize, value: u8);
3534
3535    /// The `setInt16()` method stores a signed 16-bit integer (short) value at the
3536    /// specified byte offset from the start of the DataView.
3537    ///
3538    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setInt16)
3539    #[wasm_bindgen(method, js_name = setInt16)]
3540    pub fn set_int16(this: &DataView, byte_offset: usize, value: i16);
3541
3542    /// The `setInt16()` method stores a signed 16-bit integer (short) value at the
3543    /// specified byte offset from the start of the DataView.
3544    ///
3545    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setInt16)
3546    #[wasm_bindgen(method, js_name = setInt16)]
3547    pub fn set_int16_endian(this: &DataView, byte_offset: usize, value: i16, little_endian: bool);
3548
3549    /// The `setUint16()` method stores an unsigned 16-bit integer (unsigned short) value at the
3550    /// specified byte offset from the start of the DataView.
3551    ///
3552    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setUint16)
3553    #[wasm_bindgen(method, js_name = setUint16)]
3554    pub fn set_uint16(this: &DataView, byte_offset: usize, value: u16);
3555
3556    /// The `setUint16()` method stores an unsigned 16-bit integer (unsigned short) value at the
3557    /// specified byte offset from the start of the DataView.
3558    ///
3559    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setUint16)
3560    #[wasm_bindgen(method, js_name = setUint16)]
3561    pub fn set_uint16_endian(this: &DataView, byte_offset: usize, value: u16, little_endian: bool);
3562
3563    /// The `setInt32()` method stores a signed 32-bit integer (long) value at the
3564    /// specified byte offset from the start of the DataView.
3565    ///
3566    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setInt32)
3567    #[wasm_bindgen(method, js_name = setInt32)]
3568    pub fn set_int32(this: &DataView, byte_offset: usize, value: i32);
3569
3570    /// The `setInt32()` method stores a signed 32-bit integer (long) value at the
3571    /// specified byte offset from the start of the DataView.
3572    ///
3573    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setInt32)
3574    #[wasm_bindgen(method, js_name = setInt32)]
3575    pub fn set_int32_endian(this: &DataView, byte_offset: usize, value: i32, little_endian: bool);
3576
3577    /// The `setUint32()` method stores an unsigned 32-bit integer (unsigned long) value at the
3578    /// specified byte offset from the start of the DataView.
3579    ///
3580    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setUint32)
3581    #[wasm_bindgen(method, js_name = setUint32)]
3582    pub fn set_uint32(this: &DataView, byte_offset: usize, value: u32);
3583
3584    /// The `setUint32()` method stores an unsigned 32-bit integer (unsigned long) value at the
3585    /// specified byte offset from the start of the DataView.
3586    ///
3587    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setUint32)
3588    #[wasm_bindgen(method, js_name = setUint32)]
3589    pub fn set_uint32_endian(this: &DataView, byte_offset: usize, value: u32, little_endian: bool);
3590
3591    /// The `setFloat32()` method stores a signed 32-bit float (float) value at the
3592    /// specified byte offset from the start of the DataView.
3593    ///
3594    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setFloat32)
3595    #[wasm_bindgen(method, js_name = setFloat32)]
3596    pub fn set_float32(this: &DataView, byte_offset: usize, value: f32);
3597
3598    /// The `setFloat32()` method stores a signed 32-bit float (float) value at the
3599    /// specified byte offset from the start of the DataView.
3600    ///
3601    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setFloat32)
3602    #[wasm_bindgen(method, js_name = setFloat32)]
3603    pub fn set_float32_endian(this: &DataView, byte_offset: usize, value: f32, little_endian: bool);
3604
3605    /// The `setFloat16()` method stores a signed 16-bit float value from an
3606    /// `f32` at the specified byte offset from the start of the DataView.
3607    ///
3608    /// The unsuffixed `set_float16` name is reserved for a future native
3609    /// `f16` binding once Rust stabilizes the type.
3610    ///
3611    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setFloat16)
3612    #[wasm_bindgen(method, js_name = setFloat16)]
3613    pub fn set_float16_from_f32(this: &DataView, byte_offset: usize, value: f32);
3614
3615    /// The `setFloat16()` method stores a signed 16-bit float value from an
3616    /// `f32` at the specified byte offset from the start of the DataView.
3617    ///
3618    /// The unsuffixed `set_float16_endian` name is reserved for a future
3619    /// native `f16` binding once Rust stabilizes the type.
3620    ///
3621    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setFloat16)
3622    #[wasm_bindgen(method, js_name = setFloat16)]
3623    pub fn set_float16_endian_from_f32(
3624        this: &DataView,
3625        byte_offset: usize,
3626        value: f32,
3627        little_endian: bool,
3628    );
3629
3630    /// The `setFloat64()` method stores a signed 64-bit float (double) value at the
3631    /// specified byte offset from the start of the DataView.
3632    ///
3633    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setFloat64)
3634    #[wasm_bindgen(method, js_name = setFloat64)]
3635    pub fn set_float64(this: &DataView, byte_offset: usize, value: f64);
3636
3637    /// The `setFloat64()` method stores a signed 64-bit float (double) value at the
3638    /// specified byte offset from the start of the DataView.
3639    ///
3640    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setFloat64)
3641    #[wasm_bindgen(method, js_name = setFloat64)]
3642    pub fn set_float64_endian(this: &DataView, byte_offset: usize, value: f64, little_endian: bool);
3643}
3644
3645// Error
3646#[wasm_bindgen]
3647extern "C" {
3648    #[wasm_bindgen(extends = Object, typescript_type = "Error")]
3649    #[derive(Clone, Debug, PartialEq, Eq)]
3650    pub type Error;
3651
3652    /// The Error constructor creates an error object.
3653    /// Instances of Error objects are thrown when runtime errors occur.
3654    /// The Error object can also be used as a base object for user-defined exceptions.
3655    /// See below for standard built-in error types.
3656    ///
3657    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error)
3658    #[wasm_bindgen(constructor)]
3659    pub fn new(message: &str) -> Error;
3660
3661    /// Creates a new `Error` with the given message and an untyped options
3662    /// object whose `cause` property indicates the original cause of the
3663    /// error.
3664    ///
3665    /// New code should prefer [`Error::new_with_error_options`], which takes
3666    /// a typed [`ErrorOptions`] dictionary.
3667    ///
3668    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/Error)
3669    #[wasm_bindgen(constructor)]
3670    pub fn new_with_options(message: &str, options: &Object) -> Error;
3671
3672    /// Creates a new `Error` with the given message and a typed
3673    /// [`ErrorOptions`] dictionary whose `cause` property indicates the
3674    /// original cause of the error.
3675    ///
3676    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/Error)
3677    #[wasm_bindgen(constructor)]
3678    pub fn new_with_error_options(message: &str, options: &ErrorOptions) -> Error;
3679
3680    /// The cause property is the underlying cause of the error.
3681    /// Usually this is used to add context to re-thrown errors.
3682    ///
3683    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error#differentiate_between_similar_errors)
3684    #[wasm_bindgen(method, getter)]
3685    pub fn cause(this: &Error) -> JsValue;
3686    #[wasm_bindgen(method, setter)]
3687    pub fn set_cause(this: &Error, cause: &JsValue);
3688
3689    /// The message property is a human-readable description of the error.
3690    ///
3691    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/message)
3692    #[wasm_bindgen(method, getter)]
3693    pub fn message(this: &Error) -> JsString;
3694    #[wasm_bindgen(method, setter)]
3695    pub fn set_message(this: &Error, message: &str);
3696
3697    /// The name property represents a name for the type of error. The initial value is "Error".
3698    ///
3699    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/name)
3700    #[wasm_bindgen(method, getter)]
3701    pub fn name(this: &Error) -> JsString;
3702    #[wasm_bindgen(method, setter)]
3703    pub fn set_name(this: &Error, name: &str);
3704
3705    /// The `toString()` method returns a string representing the specified Error object
3706    ///
3707    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/toString)
3708    #[cfg(not(js_sys_unstable_apis))]
3709    #[wasm_bindgen(method, js_name = toString)]
3710    pub fn to_string(this: &Error) -> JsString;
3711
3712    /// The `Error.stackTraceLimit` property controls the number of stack
3713    /// frames collected by a stack trace.
3714    ///
3715    /// This is a non-standard V8/Node.js API.
3716    ///
3717    /// [V8 documentation](https://v8.dev/docs/stack-trace-api#stack-trace-collection-for-custom-exceptions)
3718    #[wasm_bindgen(static_method_of = Error, getter, js_name = stackTraceLimit)]
3719    pub fn stack_trace_limit() -> JsValue;
3720
3721    /// Set `Error.stackTraceLimit` to control the number of stack frames
3722    /// 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, setter, js_name = stackTraceLimit)]
3728    pub fn set_stack_trace_limit(value: &JsValue);
3729}
3730
3731partialord_ord!(JsString);
3732
3733// EvalError
3734#[wasm_bindgen]
3735extern "C" {
3736    #[wasm_bindgen(extends = Object, extends = Error, typescript_type = "EvalError")]
3737    #[derive(Clone, Debug, PartialEq, Eq)]
3738    pub type EvalError;
3739
3740    /// The `EvalError` object indicates an error regarding the global eval() function. This
3741    /// exception is not thrown by JavaScript anymore, however the EvalError object remains for
3742    /// compatibility.
3743    ///
3744    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError)
3745    #[wasm_bindgen(constructor)]
3746    pub fn new(message: &str) -> EvalError;
3747
3748    /// Creates a new `EvalError` with the given message and a typed
3749    /// [`ErrorOptions`] dictionary whose `cause` property indicates the
3750    /// original cause of the error.
3751    ///
3752    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError/EvalError)
3753    #[wasm_bindgen(constructor)]
3754    pub fn new_with_options(message: &str, options: &ErrorOptions) -> EvalError;
3755}
3756
3757#[wasm_bindgen]
3758extern "C" {
3759    #[wasm_bindgen(extends = Object, is_type_of = JsValue::is_function, no_upcast, typescript_type = "Function")]
3760    #[derive(Clone, Debug, PartialEq, Eq)]
3761    /// `Function` represents any generic Function in JS, by treating all arguments as `JsValue`.
3762    ///
3763    /// It takes a generic parameter of phantom type `fn (Arg1, ..., Argn) -> Ret` which
3764    /// is used to type the JS function. For example, `Function<fn () -> Number>` represents
3765    /// a function taking no arguments that returns a number.
3766    ///
3767    /// The 8 generic argument parameters (`Arg1` through `Arg8`) are the argument
3768    /// types. Arguments not provided enable strict arity checking at compile time.
3769    ///
3770    /// A void function is represented by `fn (Arg) -> Undefined`, and **not** the `()` unit
3771    /// type. This is because generics must be based on JS values in the JS generic type system.
3772    ///
3773    /// _The default without any parameters is as a void function - no arguments, `Undefined` return._
3774    ///
3775    /// _The default generic for `Function` is `fn (JsValue, JsValue, ...) -> JsValue`,
3776    /// representing any function, since all functions safely upcast into this function._
3777    ///
3778    /// ### Arity Enforcement
3779    ///
3780    /// It is not possible to use `call4` or `bind4` on a function that does not have
3781    /// at least 4 arguments — the compiler will reject this because only arguments that
3782    /// are not `None` support the trait bound for `ErasableGeneric`.
3783    ///
3784    /// ### Examples
3785    ///
3786    /// ```ignore
3787    /// // A function taking no args, returning Number
3788    /// let f: Function<Number> = get_some_fn();
3789    ///
3790    /// // A function taking (String, Number) and returning Boolean
3791    /// let f: Function<Boolean, String, Number> = get_some_fn();
3792    ///
3793    /// ### Upcasting
3794    ///
3795    /// To pass a typed `Function` where a different generic Function is expected, `upcast()` may be used
3796    /// to convert into any generic `Function` at zero cost with type-safety.
3797    ///
3798    /// MDN documentation (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function)
3799    pub type Function<
3800        T: JsFunction = fn(
3801            JsValue,
3802            JsValue,
3803            JsValue,
3804            JsValue,
3805            JsValue,
3806            JsValue,
3807            JsValue,
3808            JsValue,
3809        ) -> JsValue,
3810    >;
3811}
3812
3813#[wasm_bindgen]
3814extern "C" {
3815    /// The `Function` constructor creates a new `Function` object. Calling the
3816    /// constructor directly can create functions dynamically, but suffers from
3817    /// security and similar (but far less significant) performance issues
3818    /// similar to `eval`. However, unlike `eval`, the `Function` constructor
3819    /// allows executing code in the global scope, prompting better programming
3820    /// habits and allowing for more efficient code minification.
3821    ///
3822    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function)
3823    #[cfg(all(feature = "unsafe-eval", not(js_sys_unstable_apis)))]
3824    #[wasm_bindgen(constructor)]
3825    pub fn new_with_args(args: &str, body: &str) -> Function;
3826
3827    /// The `Function` constructor creates a new `Function` object. Calling the
3828    /// constructor directly can create functions dynamically, but suffers from
3829    /// security and similar (but far less significant) performance issues
3830    /// similar to `eval`. However, unlike `eval`, the `Function` constructor
3831    /// allows executing code in the global scope, prompting better programming
3832    /// habits and allowing for more efficient code minification.
3833    ///
3834    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function)
3835    #[cfg(all(feature = "unsafe-eval", js_sys_unstable_apis))]
3836    #[wasm_bindgen(constructor)]
3837    pub fn new_with_args<T: JsFunction = fn() -> JsValue>(args: &str, body: &str) -> Function<T>;
3838
3839    // Next major: deprecate
3840    /// The `Function` constructor creates a new `Function` object. Calling the
3841    /// constructor directly can create functions dynamically, but suffers from
3842    /// security and similar (but far less significant) performance issues
3843    /// similar to `eval`. However, unlike `eval`, the `Function` constructor
3844    /// allows executing code in the global scope, prompting better programming
3845    /// habits and allowing for more efficient code minification.
3846    ///
3847    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function)
3848    #[cfg(feature = "unsafe-eval")]
3849    #[wasm_bindgen(constructor)]
3850    pub fn new_with_args_typed<T: JsFunction = fn() -> JsValue>(
3851        args: &str,
3852        body: &str,
3853    ) -> Function<T>;
3854
3855    /// The `Function` constructor creates a new `Function` object. Calling the
3856    /// constructor directly can create functions dynamically, but suffers from
3857    /// security and similar (but far less significant) performance issues
3858    /// similar to `eval`. However, unlike `eval`, the `Function` constructor
3859    /// allows executing code in the global scope, prompting better programming
3860    /// habits and allowing for more efficient code minification.
3861    ///
3862    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function)
3863    #[cfg(all(feature = "unsafe-eval", not(js_sys_unstable_apis)))]
3864    #[wasm_bindgen(constructor)]
3865    pub fn new_no_args(body: &str) -> Function;
3866
3867    /// The `Function` constructor creates a new `Function` object. Calling the
3868    /// constructor directly can create functions dynamically, but suffers from
3869    /// security and similar (but far less significant) performance issues
3870    /// similar to `eval`. However, unlike `eval`, the `Function` constructor
3871    /// allows executing code in the global scope, prompting better programming
3872    /// habits and allowing for more efficient code minification.
3873    ///
3874    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function)
3875    #[cfg(all(feature = "unsafe-eval", js_sys_unstable_apis))]
3876    #[wasm_bindgen(constructor)]
3877    pub fn new_no_args<T: JsFunction = fn() -> JsValue>(body: &str) -> Function<T>;
3878
3879    // Next major: deprecate
3880    /// The `Function` constructor creates a new `Function` object.
3881    ///
3882    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function)
3883    #[cfg(feature = "unsafe-eval")]
3884    #[wasm_bindgen(constructor)]
3885    pub fn new_no_args_typed<T: JsFunction = fn() -> JsValue>(body: &str) -> Function<T>;
3886
3887    /// The `apply()` method calls a function with a given this value, and arguments provided as an array
3888    /// (or an array-like object).
3889    ///
3890    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/apply)
3891    #[wasm_bindgen(method, catch)]
3892    pub fn apply<T: JsFunction = fn() -> JsValue>(
3893        this: &Function<T>,
3894        context: &JsValue,
3895        args: &Array,
3896    ) -> Result<<T as JsFunction>::Ret, JsValue>;
3897
3898    // Next major: Deprecate, and separately provide provide impl
3899    /// The `call()` method calls a function with a given this value and
3900    /// arguments provided individually.
3901    ///
3902    /// **Note: Use [`call()`](Function::call) to get exact arity and also checked generic type casting.**
3903    ///
3904    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
3905    #[wasm_bindgen(method, catch, js_name = call)]
3906    pub fn call0<Ret: JsGeneric, F: JsFunction<Ret = Ret> = fn() -> JsValue>(
3907        this: &Function<F>,
3908        context: &JsValue,
3909    ) -> Result<Ret, JsValue>;
3910
3911    // Next major: Deprecate, and separately provide provide impl
3912    /// The `call()` method calls a function with a given this value and
3913    /// arguments provided individually.
3914    ///
3915    /// **Note: Use [`call()`](Function::call) to get exact arity and also checked generic type casting.**
3916    ///
3917    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
3918    #[wasm_bindgen(method, catch, js_name = call)]
3919    pub fn call1<
3920        Ret: JsGeneric,
3921        Arg1: JsGeneric,
3922        F: JsFunction<Ret = Ret> + JsFunction1<Arg1 = Arg1> = fn(JsValue) -> JsValue,
3923    >(
3924        this: &Function<F>,
3925        context: &JsValue,
3926        arg1: &Arg1,
3927    ) -> Result<Ret, JsValue>;
3928
3929    // Next major: Deprecate, and separately provide provide impl
3930    /// The `call()` method calls a function with a given this value and
3931    /// arguments provided individually.
3932    ///
3933    /// **Note: Use [`call()`](Function::call) to get exact arity and also checked generic type casting.**
3934    ///
3935    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
3936    #[wasm_bindgen(method, catch, js_name = call)]
3937    pub fn call2<
3938        Ret: JsGeneric,
3939        Arg1: JsGeneric,
3940        Arg2: JsGeneric,
3941        F: JsFunction<Ret = Ret> + JsFunction1<Arg1 = Arg1> + JsFunction2<Arg2 = Arg2> = fn(
3942            JsValue,
3943            JsValue,
3944        ) -> JsValue,
3945    >(
3946        this: &Function<F>,
3947        context: &JsValue,
3948        arg1: &Arg1,
3949        arg2: &Arg2,
3950    ) -> Result<Ret, JsValue>;
3951
3952    // Next major: Deprecate, and separately provide provide impl
3953    /// The `call()` method calls a function with a given this value and
3954    /// arguments provided individually.
3955    ///
3956    /// **Note: Use [`call()`](Function::call) to get exact arity and also checked generic type casting.**
3957    ///
3958    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
3959    #[wasm_bindgen(method, catch, js_name = call)]
3960    pub fn call3<
3961        Ret: JsGeneric,
3962        Arg1: JsGeneric,
3963        Arg2: JsGeneric,
3964        Arg3: JsGeneric,
3965        F: JsFunction<Ret = Ret> + JsFunction3<Arg1 = Arg1, Arg2 = Arg2, Arg3 = Arg3> = fn(
3966            JsValue,
3967            JsValue,
3968            JsValue,
3969        ) -> JsValue,
3970    >(
3971        this: &Function<F>,
3972        context: &JsValue,
3973        arg1: &Arg1,
3974        arg2: &Arg2,
3975        arg3: &Arg3,
3976    ) -> Result<Ret, JsValue>;
3977
3978    // Next major: Deprecate, and separately provide provide impl
3979    /// The `call()` method calls a function with a given this value and
3980    /// arguments provided individually.
3981    ///
3982    /// **Note: Use [`call()`](Function::call) to get exact arity and also checked generic type casting.**
3983    ///
3984    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
3985    #[wasm_bindgen(method, catch, js_name = call)]
3986    pub fn call4<
3987        Ret: JsGeneric,
3988        Arg1: JsGeneric,
3989        Arg2: JsGeneric,
3990        Arg3: JsGeneric,
3991        Arg4: JsGeneric,
3992        F: JsFunction<Ret = Ret> + JsFunction4<Arg1 = Arg1, Arg2 = Arg2, Arg3 = Arg3, Arg4 = Arg4> = fn(
3993            JsValue,
3994            JsValue,
3995            JsValue,
3996            JsValue,
3997        ) -> JsValue,
3998    >(
3999        this: &Function<F>,
4000        context: &JsValue,
4001        arg1: &Arg1,
4002        arg2: &Arg2,
4003        arg3: &Arg3,
4004        arg4: &Arg4,
4005    ) -> Result<Ret, JsValue>;
4006
4007    // Next major: Deprecate, and separately provide provide impl
4008    /// The `call()` method calls a function with a given this value and
4009    /// arguments provided individually.
4010    ///
4011    /// **Note: Use [`call()`](Function::call) to get exact arity and also checked generic type casting.**
4012    ///
4013    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
4014    #[wasm_bindgen(method, catch, js_name = call)]
4015    pub fn call5<
4016        Ret: JsGeneric,
4017        Arg1: JsGeneric,
4018        Arg2: JsGeneric,
4019        Arg3: JsGeneric,
4020        Arg4: JsGeneric,
4021        Arg5: JsGeneric,
4022        F: JsFunction<Ret = Ret>
4023            + JsFunction5<Arg1 = Arg1, Arg2 = Arg2, Arg3 = Arg3, Arg4 = Arg4, Arg5 = Arg5> = fn(
4024            JsValue,
4025            JsValue,
4026            JsValue,
4027            JsValue,
4028            JsValue,
4029        ) -> JsValue,
4030    >(
4031        this: &Function<F>,
4032        context: &JsValue,
4033        arg1: &Arg1,
4034        arg2: &Arg2,
4035        arg3: &Arg3,
4036        arg4: &Arg4,
4037        arg5: &Arg5,
4038    ) -> Result<Ret, JsValue>;
4039
4040    // Next major: Deprecate, and separately provide provide impl
4041    /// The `call()` method calls a function with a given this value and
4042    /// arguments provided individually.
4043    ///
4044    /// **Note: Use [`call()`](Function::call) to get exact arity and also checked generic type casting.**
4045    ///
4046    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
4047    #[wasm_bindgen(method, catch, js_name = call)]
4048    pub fn call6<
4049        Ret: JsGeneric,
4050        Arg1: JsGeneric,
4051        Arg2: JsGeneric,
4052        Arg3: JsGeneric,
4053        Arg4: JsGeneric,
4054        Arg5: JsGeneric,
4055        Arg6: JsGeneric,
4056        F: JsFunction<Ret = Ret>
4057            + JsFunction6<
4058                Arg1 = Arg1,
4059                Arg2 = Arg2,
4060                Arg3 = Arg3,
4061                Arg4 = Arg4,
4062                Arg5 = Arg5,
4063                Arg6 = Arg6,
4064            > = fn(JsValue, JsValue, JsValue, JsValue, JsValue, JsValue) -> JsValue,
4065    >(
4066        this: &Function<F>,
4067        context: &JsValue,
4068        arg1: &Arg1,
4069        arg2: &Arg2,
4070        arg3: &Arg3,
4071        arg4: &Arg4,
4072        arg5: &Arg5,
4073        arg6: &Arg6,
4074    ) -> Result<Ret, JsValue>;
4075
4076    // Next major: Deprecate, and separately provide provide impl
4077    /// The `call()` method calls a function with a given this value and
4078    /// arguments provided individually.
4079    ///
4080    /// **Note: Use [`call()`](Function::call) to get exact arity and also checked generic type casting.**
4081    ///
4082    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
4083    #[wasm_bindgen(method, catch, js_name = call)]
4084    pub fn call7<
4085        Ret: JsGeneric,
4086        Arg1: JsGeneric,
4087        Arg2: JsGeneric,
4088        Arg3: JsGeneric,
4089        Arg4: JsGeneric,
4090        Arg5: JsGeneric,
4091        Arg6: JsGeneric,
4092        Arg7: JsGeneric,
4093        F: JsFunction<Ret = Ret>
4094            + JsFunction7<
4095                Arg1 = Arg1,
4096                Arg2 = Arg2,
4097                Arg3 = Arg3,
4098                Arg4 = Arg4,
4099                Arg5 = Arg5,
4100                Arg6 = Arg6,
4101                Arg7 = Arg7,
4102            > = fn(
4103            JsValue,
4104            JsValue,
4105            JsValue,
4106            JsValue,
4107            JsValue,
4108            JsValue,
4109            JsValue,
4110        ) -> JsValue,
4111    >(
4112        this: &Function<F>,
4113        context: &JsValue,
4114        arg1: &Arg1,
4115        arg2: &Arg2,
4116        arg3: &Arg3,
4117        arg4: &Arg4,
4118        arg5: &Arg5,
4119        arg6: &Arg6,
4120        arg7: &Arg7,
4121    ) -> Result<Ret, JsValue>;
4122
4123    // Next major: Deprecate, and separately provide provide impl
4124    /// The `call()` method calls a function with a given this value and
4125    /// arguments provided individually.
4126    ///
4127    /// **Note: Use [`call()`](Function::call) to get exact arity and also checked generic type casting.**
4128    ///
4129    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
4130    #[wasm_bindgen(method, catch, js_name = call)]
4131    pub fn call8<
4132        Ret: JsGeneric,
4133        Arg1: JsGeneric,
4134        Arg2: JsGeneric,
4135        Arg3: JsGeneric,
4136        Arg4: JsGeneric,
4137        Arg5: JsGeneric,
4138        Arg6: JsGeneric,
4139        Arg7: JsGeneric,
4140        Arg8: JsGeneric,
4141        F: JsFunction8<
4142            Ret = Ret,
4143            Arg1 = Arg1,
4144            Arg2 = Arg2,
4145            Arg3 = Arg3,
4146            Arg4 = Arg4,
4147            Arg5 = Arg5,
4148            Arg6 = Arg6,
4149            Arg7 = Arg7,
4150            Arg8 = Arg8,
4151        > = fn(
4152            JsValue,
4153            JsValue,
4154            JsValue,
4155            JsValue,
4156            JsValue,
4157            JsValue,
4158            JsValue,
4159            JsValue,
4160        ) -> JsValue,
4161    >(
4162        this: &Function<F>,
4163        context: &JsValue,
4164        arg1: &Arg1,
4165        arg2: &Arg2,
4166        arg3: &Arg3,
4167        arg4: &Arg4,
4168        arg5: &Arg5,
4169        arg6: &Arg6,
4170        arg7: &Arg7,
4171        arg8: &Arg8,
4172    ) -> Result<Ret, JsValue>;
4173
4174    /// The `call()` method calls a function with a given this value and
4175    /// arguments provided individually.
4176    ///
4177    /// **Note: Use [`call()`](Function::call) to get exact arity and also checked generic type casting.**
4178    ///
4179    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
4180    #[deprecated]
4181    #[allow(deprecated)]
4182    #[wasm_bindgen(method, catch, js_name = call)]
4183    pub fn call9<
4184        Ret: JsGeneric,
4185        Arg1: JsGeneric,
4186        Arg2: JsGeneric,
4187        Arg3: JsGeneric,
4188        Arg4: JsGeneric,
4189        Arg5: JsGeneric,
4190        Arg6: JsGeneric,
4191        Arg7: JsGeneric,
4192        Arg8: JsGeneric,
4193        F: JsFunction8<
4194            Ret = Ret,
4195            Arg1 = Arg1,
4196            Arg2 = Arg2,
4197            Arg3 = Arg3,
4198            Arg4 = Arg4,
4199            Arg5 = Arg5,
4200            Arg6 = Arg6,
4201            Arg7 = Arg7,
4202            Arg8 = Arg8,
4203        > = fn(
4204            JsValue,
4205            JsValue,
4206            JsValue,
4207            JsValue,
4208            JsValue,
4209            JsValue,
4210            JsValue,
4211            JsValue,
4212        ) -> JsValue,
4213    >(
4214        this: &Function<F>,
4215        context: &JsValue,
4216        arg1: &Arg1,
4217        arg2: &Arg2,
4218        arg3: &Arg3,
4219        arg4: &Arg4,
4220        arg5: &Arg5,
4221        arg6: &Arg6,
4222        arg7: &Arg7,
4223        arg8: &Arg8,
4224        arg9: &JsValue,
4225    ) -> Result<Ret, JsValue>;
4226
4227    /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
4228    /// with a given sequence of arguments preceding any provided when the new function is called.
4229    ///
4230    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
4231    #[cfg(not(js_sys_unstable_apis))]
4232    #[deprecated(note = "Use `Function::bind0` instead.")]
4233    #[allow(deprecated)]
4234    #[wasm_bindgen(method, js_name = bind)]
4235    pub fn bind<T: JsFunction = fn() -> JsValue>(
4236        this: &Function<T>,
4237        context: &JsValue,
4238    ) -> Function<T>;
4239
4240    /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
4241    /// with a given sequence of arguments preceding any provided when the new function is called.
4242    ///
4243    /// *Note:* See [`Function::bindn`] for arbitrary binding with function arity checking.
4244    ///
4245    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
4246    #[wasm_bindgen(method, js_name = bind)]
4247    pub fn bind0<T: JsFunction = fn() -> JsValue>(
4248        this: &Function<T>,
4249        context: &JsValue,
4250    ) -> Function<T>;
4251
4252    /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
4253    /// with a given sequence of arguments preceding any provided when the new function is called.
4254    ///
4255    /// *Note:* See [`Function::bindn`] for arbitrary binding with function arity checking.
4256    ///
4257    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
4258    #[wasm_bindgen(method, js_name = bind)]
4259    pub fn bind1<
4260        Ret: JsGeneric,
4261        Arg1: JsGeneric,
4262        F: JsFunction1<Ret = Ret, Arg1 = Arg1> = fn(JsValue) -> JsValue,
4263    >(
4264        this: &Function<F>,
4265        context: &JsValue,
4266        arg1: &Arg1,
4267    ) -> Function<<F as JsFunction1>::Bind1>;
4268
4269    /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
4270    /// with a given sequence of arguments preceding any provided when the new function is called.
4271    ///
4272    /// *Note:* See [`Function::bindn`] for arbitrary binding with function arity checking.
4273    ///
4274    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
4275    #[wasm_bindgen(method, js_name = bind)]
4276    pub fn bind2<
4277        Ret: JsGeneric,
4278        Arg1: JsGeneric,
4279        Arg2: JsGeneric,
4280        F: JsFunction2<Ret = Ret, Arg1 = Arg1, Arg2 = Arg2> = fn(JsValue, JsValue) -> JsValue,
4281    >(
4282        this: &Function<F>,
4283        context: &JsValue,
4284        arg1: &Arg1,
4285        arg2: &Arg2,
4286    ) -> Function<<F as JsFunction2>::Bind2>;
4287
4288    /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
4289    /// with a given sequence of arguments preceding any provided when the new function is called.
4290    ///
4291    /// *Note:* See [`Function::bindn`] for arbitrary binding with function arity checking.
4292    ///
4293    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
4294    #[wasm_bindgen(method, js_name = bind)]
4295    pub fn bind3<
4296        Ret: JsGeneric,
4297        Arg1: JsGeneric,
4298        Arg2: JsGeneric,
4299        Arg3: JsGeneric,
4300        F: JsFunction3<Ret = Ret, Arg1 = Arg1, Arg2 = Arg2, Arg3 = Arg3> = fn(
4301            JsValue,
4302            JsValue,
4303            JsValue,
4304        ) -> JsValue,
4305    >(
4306        this: &Function<F>,
4307        context: &JsValue,
4308        arg1: &Arg1,
4309        arg2: &Arg2,
4310        arg3: &Arg3,
4311    ) -> Function<<F as JsFunction3>::Bind3>;
4312
4313    /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
4314    /// with a given sequence of arguments preceding any provided when the new function is called.
4315    ///
4316    /// *Note:* See [`Function::bindn`] for arbitrary binding with function arity checking.
4317    ///
4318    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
4319    #[wasm_bindgen(method, js_name = bind)]
4320    pub fn bind4<
4321        Ret: JsGeneric,
4322        Arg1: JsGeneric,
4323        Arg2: JsGeneric,
4324        Arg3: JsGeneric,
4325        Arg4: JsGeneric,
4326        F: JsFunction4<Ret = Ret, Arg1 = Arg1, Arg2 = Arg2, Arg3 = Arg3, Arg4 = Arg4> = fn(
4327            JsValue,
4328            JsValue,
4329            JsValue,
4330            JsValue,
4331        ) -> JsValue,
4332    >(
4333        this: &Function<F>,
4334        context: &JsValue,
4335        arg1: &Arg1,
4336        arg2: &Arg2,
4337        arg3: &Arg3,
4338        arg4: &Arg4,
4339    ) -> Function<<F as JsFunction4>::Bind4>;
4340
4341    /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
4342    /// with a given sequence of arguments preceding any provided when the new function is called.
4343    ///
4344    /// *Note:* See [`Function::bindn`] for arbitrary binding with function arity checking.
4345    ///
4346    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
4347    #[wasm_bindgen(method, js_name = bind)]
4348    pub fn bind5<
4349        Ret: JsGeneric,
4350        Arg1: JsGeneric,
4351        Arg2: JsGeneric,
4352        Arg3: JsGeneric,
4353        Arg4: JsGeneric,
4354        Arg5: JsGeneric,
4355        F: JsFunction5<Ret = Ret, Arg1 = Arg1, Arg2 = Arg2, Arg3 = Arg3, Arg4 = Arg4, Arg5 = Arg5> = fn(
4356            JsValue,
4357            JsValue,
4358            JsValue,
4359            JsValue,
4360            JsValue,
4361        ) -> JsValue,
4362    >(
4363        this: &Function<F>,
4364        context: &JsValue,
4365        arg1: &Arg1,
4366        arg2: &Arg2,
4367        arg3: &Arg3,
4368        arg4: &Arg4,
4369        arg5: &Arg5,
4370    ) -> Function<<F as JsFunction5>::Bind5>;
4371
4372    /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
4373    /// with a given sequence of arguments preceding any provided when the new function is called.
4374    ///
4375    /// *Note:* See [`Function::bindn`] for arbitrary binding with function arity checking.
4376    ///
4377    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
4378    #[wasm_bindgen(method, js_name = bind)]
4379    pub fn bind6<
4380        Ret: JsGeneric,
4381        Arg1: JsGeneric,
4382        Arg2: JsGeneric,
4383        Arg3: JsGeneric,
4384        Arg4: JsGeneric,
4385        Arg5: JsGeneric,
4386        Arg6: JsGeneric,
4387        F: JsFunction6<
4388            Ret = Ret,
4389            Arg1 = Arg1,
4390            Arg2 = Arg2,
4391            Arg3 = Arg3,
4392            Arg4 = Arg4,
4393            Arg5 = Arg5,
4394            Arg6 = Arg6,
4395        > = fn(JsValue, JsValue, JsValue, JsValue, JsValue, JsValue) -> JsValue,
4396    >(
4397        this: &Function<F>,
4398        context: &JsValue,
4399        arg1: &Arg1,
4400        arg2: &Arg2,
4401        arg3: &Arg3,
4402        arg4: &Arg4,
4403        arg5: &Arg5,
4404        arg6: &Arg6,
4405    ) -> Function<<F as JsFunction6>::Bind6>;
4406
4407    /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
4408    /// with a given sequence of arguments preceding any provided when the new function is called.
4409    ///
4410    /// *Note:* See [`Function::bindn`] for arbitrary binding with function arity checking.
4411    ///
4412    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
4413    #[wasm_bindgen(method, js_name = bind)]
4414    pub fn bind7<
4415        Ret: JsGeneric,
4416        Arg1: JsGeneric,
4417        Arg2: JsGeneric,
4418        Arg3: JsGeneric,
4419        Arg4: JsGeneric,
4420        Arg5: JsGeneric,
4421        Arg6: JsGeneric,
4422        Arg7: JsGeneric,
4423        F: JsFunction7<
4424            Ret = Ret,
4425            Arg1 = Arg1,
4426            Arg2 = Arg2,
4427            Arg3 = Arg3,
4428            Arg4 = Arg4,
4429            Arg5 = Arg5,
4430            Arg6 = Arg6,
4431            Arg7 = Arg7,
4432        > = fn(
4433            JsValue,
4434            JsValue,
4435            JsValue,
4436            JsValue,
4437            JsValue,
4438            JsValue,
4439            JsValue,
4440        ) -> JsValue,
4441    >(
4442        this: &Function<F>,
4443        context: &JsValue,
4444        arg1: &Arg1,
4445        arg2: &Arg2,
4446        arg3: &Arg3,
4447        arg4: &Arg4,
4448        arg5: &Arg5,
4449        arg6: &Arg6,
4450        arg7: &Arg7,
4451    ) -> Function<<F as JsFunction7>::Bind7>;
4452
4453    /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
4454    /// with a given sequence of arguments preceding any provided when the new function is called.
4455    ///
4456    /// *Note:* See [`Function::bindn`] for arbitrary binding with function arity checking.
4457    ///
4458    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
4459    #[wasm_bindgen(method, js_name = bind)]
4460    pub fn bind8<
4461        Ret: JsGeneric,
4462        Arg1: JsGeneric,
4463        Arg2: JsGeneric,
4464        Arg3: JsGeneric,
4465        Arg4: JsGeneric,
4466        Arg5: JsGeneric,
4467        Arg6: JsGeneric,
4468        Arg7: JsGeneric,
4469        Arg8: JsGeneric,
4470        F: JsFunction8<
4471            Ret = Ret,
4472            Arg1 = Arg1,
4473            Arg2 = Arg2,
4474            Arg3 = Arg3,
4475            Arg4 = Arg4,
4476            Arg5 = Arg5,
4477            Arg6 = Arg6,
4478            Arg7 = Arg7,
4479            Arg8 = Arg8,
4480        > = fn(
4481            JsValue,
4482            JsValue,
4483            JsValue,
4484            JsValue,
4485            JsValue,
4486            JsValue,
4487            JsValue,
4488            JsValue,
4489        ) -> JsValue,
4490    >(
4491        this: &Function<F>,
4492        context: &JsValue,
4493        arg1: &Arg1,
4494        arg2: &Arg2,
4495        arg3: &Arg3,
4496        arg4: &Arg4,
4497        arg5: &Arg5,
4498        arg6: &Arg6,
4499        arg7: &Arg7,
4500        arg8: &Arg8,
4501    ) -> Function<<F as JsFunction8>::Bind8>;
4502
4503    /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
4504    /// with a given sequence of arguments preceding any provided when the new function is called.
4505    ///
4506    /// *Note:* See [`Function::bindn`] for arbitrary binding with function arity checking.
4507    ///
4508    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
4509    #[deprecated]
4510    #[allow(deprecated)]
4511    #[wasm_bindgen(method, js_name = bind)]
4512    pub fn bind9<
4513        Ret: JsGeneric,
4514        Arg1: JsGeneric,
4515        Arg2: JsGeneric,
4516        Arg3: JsGeneric,
4517        Arg4: JsGeneric,
4518        Arg5: JsGeneric,
4519        Arg6: JsGeneric,
4520        Arg7: JsGeneric,
4521        Arg8: JsGeneric,
4522        F: JsFunction8<
4523            Ret = Ret,
4524            Arg1 = Arg1,
4525            Arg2 = Arg2,
4526            Arg3 = Arg3,
4527            Arg4 = Arg4,
4528            Arg5 = Arg5,
4529            Arg6 = Arg6,
4530            Arg7 = Arg7,
4531            Arg8 = Arg8,
4532        > = fn(
4533            JsValue,
4534            JsValue,
4535            JsValue,
4536            JsValue,
4537            JsValue,
4538            JsValue,
4539            JsValue,
4540            JsValue,
4541        ) -> JsValue,
4542    >(
4543        this: &Function<F>,
4544        context: &JsValue,
4545        arg1: &Arg1,
4546        arg2: &Arg2,
4547        arg3: &Arg3,
4548        arg4: &Arg4,
4549        arg5: &Arg5,
4550        arg6: &Arg6,
4551        arg7: &Arg7,
4552        arg8: &Arg8,
4553        arg9: &JsValue,
4554    ) -> Function<fn() -> Ret>;
4555
4556    /// The length property indicates the number of arguments expected by the function.
4557    ///
4558    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/length)
4559    #[wasm_bindgen(method, getter)]
4560    pub fn length<T: JsFunction = fn() -> JsValue>(this: &Function<T>) -> u32;
4561
4562    /// A Function object's read-only name property indicates the function's
4563    /// name as specified when it was created or "anonymous" for functions
4564    /// created anonymously.
4565    ///
4566    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name)
4567    #[wasm_bindgen(method, getter)]
4568    pub fn name<T: JsFunction = fn() -> JsValue>(this: &Function<T>) -> JsString;
4569
4570    /// The `toString()` method returns a string representing the source code of the function.
4571    ///
4572    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/toString)
4573    #[cfg(not(js_sys_unstable_apis))]
4574    #[wasm_bindgen(method, js_name = toString)]
4575    pub fn to_string<T: JsFunction = fn() -> JsValue>(this: &Function<T>) -> JsString;
4576}
4577
4578// Basic UpcastFrom impls for Function<T>
4579impl<T: JsFunction> UpcastFrom<Function<T>> for JsValue {}
4580impl<T: JsFunction> UpcastFrom<Function<T>> for JsOption<JsValue> {}
4581impl<T: JsFunction> UpcastFrom<Function<T>> for Object {}
4582impl<T: JsFunction> UpcastFrom<Function<T>> for JsOption<Object> {}
4583
4584// Blanket trait for Function upcast
4585// Function<T> upcasts to Function<U> when the underlying fn type T upcasts to U.
4586// The fn signature UpcastFrom impls already encode correct variance (covariant return, contravariant args).
4587impl<T: JsFunction, U: JsFunction> UpcastFrom<Function<T>> for Function<U> where U: UpcastFrom<T> {}
4588
4589// len() method for Function<T> using JsFunction::ARITY
4590impl<T: JsFunction> Function<T> {
4591    /// Get the static arity of this function type.
4592    #[allow(clippy::len_without_is_empty)]
4593    pub fn len(&self) -> usize {
4594        T::ARITY
4595    }
4596
4597    /// Returns true if this is a zero-argument function.
4598    pub fn is_empty(&self) -> bool {
4599        T::ARITY == 0
4600    }
4601}
4602
4603// Base traits for function signature types.
4604pub trait JsFunction {
4605    type Ret: JsGeneric;
4606    const ARITY: usize;
4607}
4608
4609pub trait JsFunction1: JsFunction {
4610    type Arg1: JsGeneric;
4611    type Bind1: JsFunction;
4612}
4613pub trait JsFunction2: JsFunction1 {
4614    type Arg2: JsGeneric;
4615    type Bind2: JsFunction;
4616}
4617pub trait JsFunction3: JsFunction2 {
4618    type Arg3: JsGeneric;
4619    type Bind3: JsFunction;
4620}
4621pub trait JsFunction4: JsFunction3 {
4622    type Arg4: JsGeneric;
4623    type Bind4: JsFunction;
4624}
4625pub trait JsFunction5: JsFunction4 {
4626    type Arg5: JsGeneric;
4627    type Bind5: JsFunction;
4628}
4629pub trait JsFunction6: JsFunction5 {
4630    type Arg6: JsGeneric;
4631    type Bind6: JsFunction;
4632}
4633pub trait JsFunction7: JsFunction6 {
4634    type Arg7: JsGeneric;
4635    type Bind7: JsFunction;
4636}
4637pub trait JsFunction8: JsFunction7 {
4638    type Arg8: JsGeneric;
4639    type Bind8: JsFunction;
4640}
4641
4642// Manual impl for fn() -> R
4643impl<Ret: JsGeneric> JsFunction for fn() -> Ret {
4644    type Ret = Ret;
4645    const ARITY: usize = 0;
4646}
4647
4648macro_rules! impl_fn {
4649    () => {
4650        impl_fn!(@impl 1 [Arg1] [
4651            JsFunction1 Arg1 Bind1 {fn() -> Ret}
4652        ]);
4653        impl_fn!(@impl 2 [Arg1 Arg2] [
4654            JsFunction1 Arg1 Bind1 {fn(Arg2) -> Ret}
4655            JsFunction2 Arg2 Bind2 {fn() -> Ret}
4656        ]);
4657        impl_fn!(@impl 3 [Arg1 Arg2 Arg3] [
4658            JsFunction1 Arg1 Bind1 {fn(Arg2, Arg3) -> Ret}
4659            JsFunction2 Arg2 Bind2 {fn(Arg3) -> Ret}
4660            JsFunction3 Arg3 Bind3 {fn() -> Ret}
4661        ]);
4662        impl_fn!(@impl 4 [Arg1 Arg2 Arg3 Arg4] [
4663            JsFunction1 Arg1 Bind1 {fn(Arg2, Arg3, Arg4) -> Ret}
4664            JsFunction2 Arg2 Bind2 {fn(Arg3, Arg4) -> Ret}
4665            JsFunction3 Arg3 Bind3 {fn(Arg4) -> Ret}
4666            JsFunction4 Arg4 Bind4 {fn() -> Ret}
4667        ]);
4668        impl_fn!(@impl 5 [Arg1 Arg2 Arg3 Arg4 Arg5] [
4669            JsFunction1 Arg1 Bind1 {fn(Arg2, Arg3, Arg4, Arg5) -> Ret}
4670            JsFunction2 Arg2 Bind2 {fn(Arg3, Arg4, Arg5) -> Ret}
4671            JsFunction3 Arg3 Bind3 {fn(Arg4, Arg5) -> Ret}
4672            JsFunction4 Arg4 Bind4 {fn(Arg5) -> Ret}
4673            JsFunction5 Arg5 Bind5 {fn() -> Ret}
4674        ]);
4675        impl_fn!(@impl 6 [Arg1 Arg2 Arg3 Arg4 Arg5 Arg6] [
4676            JsFunction1 Arg1 Bind1 {fn(Arg2, Arg3, Arg4, Arg5, Arg6) -> Ret}
4677            JsFunction2 Arg2 Bind2 {fn(Arg3, Arg4, Arg5, Arg6) -> Ret}
4678            JsFunction3 Arg3 Bind3 {fn(Arg4, Arg5, Arg6) -> Ret}
4679            JsFunction4 Arg4 Bind4 {fn(Arg5, Arg6) -> Ret}
4680            JsFunction5 Arg5 Bind5 {fn(Arg6) -> Ret}
4681            JsFunction6 Arg6 Bind6 {fn() -> Ret}
4682        ]);
4683        impl_fn!(@impl 7 [Arg1 Arg2 Arg3 Arg4 Arg5 Arg6 Arg7] [
4684            JsFunction1 Arg1 Bind1 {fn(Arg2, Arg3, Arg4, Arg5, Arg6, Arg7) -> Ret}
4685            JsFunction2 Arg2 Bind2 {fn(Arg3, Arg4, Arg5, Arg6, Arg7) -> Ret}
4686            JsFunction3 Arg3 Bind3 {fn(Arg4, Arg5, Arg6, Arg7) -> Ret}
4687            JsFunction4 Arg4 Bind4 {fn(Arg5, Arg6, Arg7) -> Ret}
4688            JsFunction5 Arg5 Bind5 {fn(Arg6, Arg7) -> Ret}
4689            JsFunction6 Arg6 Bind6 {fn(Arg7) -> Ret}
4690            JsFunction7 Arg7 Bind7 {fn() -> Ret}
4691        ]);
4692        impl_fn!(@impl 8 [Arg1 Arg2 Arg3 Arg4 Arg5 Arg6 Arg7 Arg8] [
4693            JsFunction1 Arg1 Bind1 {fn(Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8) -> Ret}
4694            JsFunction2 Arg2 Bind2 {fn(Arg3, Arg4, Arg5, Arg6, Arg7, Arg8) -> Ret}
4695            JsFunction3 Arg3 Bind3 {fn(Arg4, Arg5, Arg6, Arg7, Arg8) -> Ret}
4696            JsFunction4 Arg4 Bind4 {fn(Arg5, Arg6, Arg7, Arg8) -> Ret}
4697            JsFunction5 Arg5 Bind5 {fn(Arg6, Arg7, Arg8) -> Ret}
4698            JsFunction6 Arg6 Bind6 {fn(Arg7, Arg8) -> Ret}
4699            JsFunction7 Arg7 Bind7 {fn(Arg8) -> Ret}
4700            JsFunction8 Arg8 Bind8 {fn() -> Ret}
4701        ]);
4702    };
4703
4704    (@impl $arity:literal [$($A:ident)+] [$($trait:ident $arg:ident $bind:ident {$bind_ty:ty})+]) => {
4705        impl<Ret: JsGeneric $(, $A: JsGeneric)+> JsFunction for fn($($A),+) -> Ret {
4706            type Ret = Ret;
4707            const ARITY: usize = $arity;
4708        }
4709
4710        impl_fn!(@traits [$($A)+] [$($trait $arg $bind {$bind_ty})+]);
4711    };
4712
4713    (@traits [$($A:ident)+] []) => {};
4714
4715    (@traits [$($A:ident)+] [$trait:ident $arg:ident $bind:ident {$bind_ty:ty} $($rest:tt)*]) => {
4716        impl<Ret: JsGeneric $(, $A: JsGeneric)+> $trait for fn($($A),+) -> Ret {
4717            type $arg = $arg;
4718            type $bind = $bind_ty;
4719        }
4720
4721        impl_fn!(@traits [$($A)+] [$($rest)*]);
4722    };
4723}
4724
4725impl_fn!();
4726
4727/// Trait for argument tuples that can call or bind a `Function<T>`.
4728pub trait JsArgs<T: JsFunction> {
4729    type BindOutput;
4730    fn apply_call(self, func: &Function<T>, context: &JsValue) -> Result<T::Ret, JsValue>;
4731    fn apply_bind(self, func: &Function<T>, context: &JsValue) -> Self::BindOutput;
4732}
4733
4734// Manual impl for 0-arg
4735impl<Ret: JsGeneric, F: JsFunction<Ret = Ret>> JsArgs<F> for () {
4736    type BindOutput = Function<F>;
4737
4738    #[inline]
4739    fn apply_call(self, func: &Function<F>, context: &JsValue) -> Result<Ret, JsValue> {
4740        func.call0(context)
4741    }
4742
4743    #[inline]
4744    fn apply_bind(self, func: &Function<F>, context: &JsValue) -> Self::BindOutput {
4745        func.bind0(context)
4746    }
4747}
4748
4749macro_rules! impl_js_args {
4750    ($arity:literal $trait:ident $bind_output:ident [$($A:ident)+] [$($idx:tt)+] $call:ident $bind:ident) => {
4751        impl<Ret: JsGeneric, $($A: JsGeneric,)+ F: $trait<Ret = Ret, $($A = $A,)*>> JsArgs<F> for ($(&$A,)+)
4752        {
4753            type BindOutput = Function<<F as $trait>::$bind_output>;
4754
4755            #[inline]
4756            fn apply_call(self, func: &Function<F>, context: &JsValue) -> Result<Ret, JsValue> {
4757                func.$call(context, $(self.$idx),+)
4758            }
4759
4760            #[inline]
4761            fn apply_bind(self, func: &Function<F>, context: &JsValue) -> Self::BindOutput {
4762                func.$bind(context, $(self.$idx),+)
4763            }
4764        }
4765    };
4766}
4767
4768impl_js_args!(1 JsFunction1 Bind1 [Arg1] [0] call1 bind1);
4769impl_js_args!(2 JsFunction2 Bind2 [Arg1 Arg2] [0 1] call2 bind2);
4770impl_js_args!(3 JsFunction3 Bind3 [Arg1 Arg2 Arg3] [0 1 2] call3 bind3);
4771impl_js_args!(4 JsFunction4 Bind4 [Arg1 Arg2 Arg3 Arg4] [0 1 2 3] call4 bind4);
4772impl_js_args!(5 JsFunction5 Bind5 [Arg1 Arg2 Arg3 Arg4 Arg5] [0 1 2 3 4] call5 bind5);
4773impl_js_args!(6 JsFunction6 Bind6 [Arg1 Arg2 Arg3 Arg4 Arg5 Arg6] [0 1 2 3 4 5] call6 bind6);
4774impl_js_args!(7 JsFunction7 Bind7 [Arg1 Arg2 Arg3 Arg4 Arg5 Arg6 Arg7] [0 1 2 3 4 5 6] call7 bind7);
4775impl_js_args!(8 JsFunction8 Bind8 [Arg1 Arg2 Arg3 Arg4 Arg5 Arg6 Arg7 Arg8] [0 1 2 3 4 5 6 7] call8 bind8);
4776
4777impl<T: JsFunction> Function<T> {
4778    /// The `call()` method calls a function with a given `this` value and
4779    /// arguments provided as a tuple.
4780    ///
4781    /// This method accepts a tuple of references matching the function's
4782    /// argument types.
4783    ///
4784    /// # Example
4785    ///
4786    /// ```ignore
4787    /// // 0-arg function
4788    /// let f: Function<fn() -> Number> = get_fn();
4789    /// let result = f.call(&JsValue::NULL, ())?;
4790    ///
4791    /// // 1-arg function (note trailing comma for 1-tuple)
4792    /// let f: Function<fn(JsString) -> Number> = get_fn();
4793    /// let result = f.call(&JsValue::NULL, (&name,))?;
4794    ///
4795    /// // 2-arg function
4796    /// let f: Function<fn(JsString, Boolean) -> Number> = get_fn();
4797    /// let result = f.call(&JsValue::NULL, (&name, &flag))?;
4798    /// ```
4799    ///
4800    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
4801    #[inline]
4802    pub fn call<Args: JsArgs<T>>(&self, context: &JsValue, args: Args) -> Result<T::Ret, JsValue> {
4803        args.apply_call(self, context)
4804    }
4805
4806    /// The `bind()` method creates a new function that, when called, has its
4807    /// `this` keyword set to the provided value, with a given sequence of
4808    /// arguments preceding any provided when the new function is called.
4809    ///
4810    /// This method accepts a tuple of references to bind.
4811    ///
4812    /// # Example
4813    ///
4814    /// ```ignore
4815    /// let f: Function<fn(JsString, Boolean) -> Number> = get_fn();
4816    ///
4817    /// // Bind no args - same signature
4818    /// let bound: Function<fn(JsString, Boolean) -> Number> = f.bind(&ctx, ());
4819    ///
4820    /// // Bind one arg (use 1-tuple of references)
4821    /// let bound: Function<fn(Boolean) -> Number> = f.bind(&ctx, (&my_string,));
4822    ///
4823    /// // Bind two args - becomes 0-arg function
4824    /// let bound: Function<fn() -> Number> = f.bind(&ctx, (&my_string, &my_bool));
4825    /// ```
4826    ///
4827    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
4828    #[inline]
4829    pub fn bindn<Args: JsArgs<T>>(&self, context: &JsValue, args: Args) -> Args::BindOutput {
4830        args.apply_bind(self, context)
4831    }
4832
4833    /// The `bind()` method creates a new function that, when called, has its
4834    /// `this` keyword set to the provided value, with a given sequence of
4835    /// arguments preceding any provided when the new function is called.
4836    ///
4837    /// This method accepts a tuple of references to bind.
4838    ///
4839    /// # Example
4840    ///
4841    /// ```ignore
4842    /// let f: Function<fn(JsString, Boolean) -> Number> = get_fn();
4843    ///
4844    /// // Bind no args - same signature
4845    /// let bound: Function<fn(JsString, Boolean) -> Number> = f.bind(&ctx, ());
4846    ///
4847    /// // Bind one arg (use 1-tuple of references)
4848    /// let bound: Function<fn(Boolean) -> Number> = f.bind(&ctx, (&my_string,));
4849    ///
4850    /// // Bind two args - becomes 0-arg function
4851    /// let bound: Function<fn() -> Number> = f.bind(&ctx, (&my_string, &my_bool));
4852    /// ```
4853    ///
4854    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
4855    #[cfg(js_sys_unstable_apis)]
4856    #[inline]
4857    pub fn bind<Args: JsArgs<T>>(&self, context: &JsValue, args: Args) -> Args::BindOutput {
4858        args.apply_bind(self, context)
4859    }
4860}
4861
4862pub trait FunctionIntoClosure: JsFunction {
4863    type ClosureTypeMut: WasmClosure + ?Sized;
4864}
4865
4866macro_rules! impl_function_into_closure {
4867    ( $(($($var:ident)*))* ) => {$(
4868        impl<$($var: FromWasmAbi + JsGeneric,)* R: IntoWasmAbi + JsGeneric> FunctionIntoClosure for fn($($var),*) -> R {
4869            type ClosureTypeMut = dyn FnMut($($var),*) -> R;
4870        }
4871    )*};
4872}
4873
4874impl_function_into_closure! {
4875    ()
4876    (A)
4877    (A B)
4878    (A B C)
4879    (A B C D)
4880    (A B C D E)
4881    (A B C D E F)
4882    (A B C D E F G)
4883    (A B C D E F G H)
4884}
4885
4886impl<F: JsFunction> Function<F> {
4887    /// Convert a borrowed `ScopedClosure` into a typed JavaScript Function reference.
4888    ///
4889    /// The conversion is a direct type-safe conversion and upcast of a
4890    /// closure into its corresponding typed JavaScript Function,
4891    /// based on covariance and contravariance [`Upcast`] trait hierarchy.
4892    ///
4893    /// For transferring ownership to JS, use [`Function::from_closure`].
4894    #[inline]
4895    pub fn closure_ref<'a, C>(closure: &'a ScopedClosure<'_, C>) -> &'a Self
4896    where
4897        F: FunctionIntoClosure,
4898        C: WasmClosure + ?Sized,
4899        <F as FunctionIntoClosure>::ClosureTypeMut: UpcastFrom<<C as WasmClosure>::AsMut>,
4900    {
4901        closure.as_js_value().unchecked_ref()
4902    }
4903
4904    /// Convert a Rust closure into a typed JavaScript Function.
4905    ///
4906    /// This function releases ownership of the closure to JS, and provides
4907    /// an owned function handle for the same closure.
4908    ///
4909    /// The conversion is a direct type-safe conversion and upcast of a
4910    /// closure into its corresponding typed JavaScript Function,
4911    /// based on covariance and contravariance [`Upcast`] trait hierarchy.
4912    ///
4913    /// This method is only supported for static closures which do not have
4914    /// borrowed lifetime data, and thus can be released into JS.
4915    ///
4916    /// For borrowed closures, which cannot cede ownership to JS,
4917    /// instead use [`Function::closure_ref`].
4918    #[inline]
4919    pub fn from_closure<C>(closure: ScopedClosure<'static, C>) -> Self
4920    where
4921        F: FunctionIntoClosure,
4922        C: WasmClosure + ?Sized,
4923        <F as FunctionIntoClosure>::ClosureTypeMut: UpcastFrom<<C as WasmClosure>::AsMut>,
4924    {
4925        closure.into_js_value().unchecked_into()
4926    }
4927}
4928
4929#[cfg(not(js_sys_unstable_apis))]
4930impl Function {
4931    /// Returns the `Function` value of this JS value if it's an instance of a
4932    /// function.
4933    ///
4934    /// If this JS value is not an instance of a function then this returns
4935    /// `None`.
4936    #[deprecated(note = "recommended to use dyn_ref instead which is now equivalent")]
4937    pub fn try_from(val: &JsValue) -> Option<&Function> {
4938        val.dyn_ref()
4939    }
4940}
4941
4942#[cfg(feature = "unsafe-eval")]
4943impl Default for Function {
4944    fn default() -> Self {
4945        Self::new_no_args("")
4946    }
4947}
4948
4949// FinalizationRegistry
4950#[wasm_bindgen]
4951extern "C" {
4952    /// The `FinalizationRegistry` object lets you request a callback when an
4953    /// object is garbage-collected.
4954    ///
4955    /// `FinalizationRegistry` provides a way to request that a cleanup
4956    /// callback get called at some point when an object registered with the
4957    /// registry has been reclaimed (garbage-collected). Cleanup callbacks
4958    /// are sometimes called *finalizers*.
4959    ///
4960    /// Avoid where possible: cleanup callbacks should not be relied upon for
4961    /// anything essential. They are best used to reduce memory usage over the
4962    /// course of a program for objects that benefit from cleanup. Whether,
4963    /// when, and in what order callbacks fire is implementation-defined.
4964    ///
4965    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/FinalizationRegistry)
4966    #[wasm_bindgen(extends = Object, typescript_type = "FinalizationRegistry<any>")]
4967    #[derive(Clone, Debug, PartialEq, Eq)]
4968    pub type FinalizationRegistry;
4969
4970    /// Creates a new `FinalizationRegistry` with the given cleanup callback.
4971    ///
4972    /// The cleanup callback is invoked, at some point after a registered
4973    /// target is garbage-collected, with the `held_value` that was passed to
4974    /// [`FinalizationRegistry::register`]. Because callbacks may be deferred
4975    /// or skipped entirely, the callback should normally outlive the
4976    /// `FinalizationRegistry` (for example by being created via
4977    /// [`Function::from_closure`]).
4978    ///
4979    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/FinalizationRegistry/FinalizationRegistry)
4980    #[wasm_bindgen(constructor)]
4981    pub fn new(cleanup_callback: &Function<fn(JsValue) -> Undefined>) -> FinalizationRegistry;
4982
4983    /// Registers `target` with this `FinalizationRegistry`. When `target` is
4984    /// reclaimed by the garbage collector the cleanup callback may be called
4985    /// with `held_value`.
4986    ///
4987    /// `target` must be an object (or a non-registered symbol).
4988    ///
4989    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/FinalizationRegistry/register)
4990    #[wasm_bindgen(method)]
4991    pub fn register(this: &FinalizationRegistry, target: &JsValue, held_value: &JsValue);
4992
4993    /// Registers `target` with this `FinalizationRegistry`, with an
4994    /// `unregister_token` that can later be passed to
4995    /// [`FinalizationRegistry::unregister`] to remove the registration.
4996    ///
4997    /// `target` and `unregister_token` must be objects (or non-registered
4998    /// symbols), and the same value may be passed for both.
4999    ///
5000    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/FinalizationRegistry/register)
5001    #[wasm_bindgen(method, js_name = register)]
5002    pub fn register_with_token(
5003        this: &FinalizationRegistry,
5004        target: &JsValue,
5005        held_value: &JsValue,
5006        unregister_token: &JsValue,
5007    );
5008
5009    /// Unregisters all entries registered with this `FinalizationRegistry`
5010    /// using `unregister_token`. Returns `true` if any cells were removed.
5011    ///
5012    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/FinalizationRegistry/unregister)
5013    #[wasm_bindgen(method)]
5014    pub fn unregister(this: &FinalizationRegistry, unregister_token: &JsValue) -> bool;
5015}
5016
5017// Generator
5018#[wasm_bindgen]
5019extern "C" {
5020    #[wasm_bindgen(extends = Object, typescript_type = "Generator<any, any, any>")]
5021    #[derive(Clone, Debug, PartialEq, Eq)]
5022    pub type Generator<T = JsValue>;
5023
5024    /// The `next()` method returns an object with two properties done and value.
5025    /// You can also provide a parameter to the next method to send a value to the generator.
5026    ///
5027    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/next)
5028    #[cfg(not(js_sys_unstable_apis))]
5029    #[wasm_bindgen(method, catch)]
5030    pub fn next<T>(this: &Generator<T>, value: &T) -> Result<JsValue, JsValue>;
5031
5032    /// The `next()` method returns an object with two properties done and value.
5033    /// You can also provide a parameter to the next method to send a value to the generator.
5034    ///
5035    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/next)
5036    #[cfg(js_sys_unstable_apis)]
5037    #[wasm_bindgen(method, catch, js_name = next)]
5038    pub fn next<T: FromWasmAbi>(this: &Generator<T>, value: &T)
5039        -> Result<IteratorNext<T>, JsValue>;
5040
5041    // Next major: deprecate
5042    /// The `next()` method returns an object with two properties done and value.
5043    /// You can also provide a parameter to the next method to send a value to the generator.
5044    ///
5045    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/next)
5046    #[wasm_bindgen(method, catch)]
5047    pub fn next_iterator<T: FromWasmAbi>(
5048        this: &Generator<T>,
5049        value: &T,
5050    ) -> Result<IteratorNext<T>, JsValue>;
5051
5052    /// The `return()` method returns the given value and finishes the generator.
5053    ///
5054    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/return)
5055    #[cfg(not(js_sys_unstable_apis))]
5056    #[wasm_bindgen(method, js_name = "return")]
5057    pub fn return_<T>(this: &Generator<T>, value: &T) -> JsValue;
5058
5059    /// The `return()` method returns the given value and finishes the generator.
5060    ///
5061    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/return)
5062    #[cfg(js_sys_unstable_apis)]
5063    #[wasm_bindgen(method, catch, js_name = "return")]
5064    pub fn return_<T: FromWasmAbi>(
5065        this: &Generator<T>,
5066        value: &T,
5067    ) -> Result<IteratorNext<T>, JsValue>;
5068
5069    // Next major: deprecate
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    #[wasm_bindgen(method, catch, js_name = "return")]
5074    pub fn try_return<T: FromWasmAbi>(
5075        this: &Generator<T>,
5076        value: &T,
5077    ) -> Result<IteratorNext<T>, JsValue>;
5078
5079    /// The `throw()` method resumes the execution of a generator by throwing an error into it
5080    /// and returns an object with two properties done and value.
5081    ///
5082    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/throw)
5083    #[cfg(not(js_sys_unstable_apis))]
5084    #[wasm_bindgen(method, catch)]
5085    pub fn throw<T>(this: &Generator<T>, error: &Error) -> Result<JsValue, JsValue>;
5086
5087    /// The `throw()` method resumes the execution of a generator by throwing an error into it
5088    /// and returns an object with two properties done and value.
5089    ///
5090    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/throw)
5091    #[cfg(js_sys_unstable_apis)]
5092    #[wasm_bindgen(method, catch, js_name = throw)]
5093    pub fn throw<T: FromWasmAbi>(
5094        this: &Generator<T>,
5095        error: &JsValue,
5096    ) -> Result<IteratorNext<T>, JsValue>;
5097
5098    // Next major: deprecate
5099    /// The `throw()` method resumes the execution of a generator by throwing an error into it
5100    /// and returns an object with two properties done and value.
5101    ///
5102    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/throw)
5103    #[wasm_bindgen(method, catch, js_name = throw)]
5104    pub fn throw_value<T: FromWasmAbi>(
5105        this: &Generator<T>,
5106        error: &JsValue,
5107    ) -> Result<IteratorNext<T>, JsValue>;
5108}
5109
5110impl<T: FromWasmAbi> Iterable for Generator<T> {
5111    type Item = T;
5112}
5113
5114// AsyncGenerator
5115#[wasm_bindgen]
5116extern "C" {
5117    #[wasm_bindgen(extends = Object, typescript_type = "AsyncGenerator<any, any, any>")]
5118    #[derive(Clone, Debug, PartialEq, Eq)]
5119    pub type AsyncGenerator<T = JsValue>;
5120
5121    /// The `next()` method returns an object with two properties done and value.
5122    /// You can also provide a parameter to the next method to send a value to the generator.
5123    ///
5124    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncGenerator/next)
5125    #[wasm_bindgen(method, catch)]
5126    pub fn next<T>(
5127        this: &AsyncGenerator<T>,
5128        value: &T,
5129    ) -> Result<Promise<IteratorNext<T>>, JsValue>;
5130
5131    /// The `return()` method returns the given value and finishes the generator.
5132    ///
5133    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncGenerator/return)
5134    #[wasm_bindgen(method, js_name = "return", catch)]
5135    pub fn return_<T>(
5136        this: &AsyncGenerator<T>,
5137        value: &T,
5138    ) -> Result<Promise<IteratorNext<T>>, JsValue>;
5139
5140    /// The `throw()` method resumes the execution of a generator by throwing an error into it
5141    /// and returns an object with two properties done and value.
5142    ///
5143    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncGenerator/throw)
5144    #[wasm_bindgen(method, catch)]
5145    pub fn throw<T>(
5146        this: &AsyncGenerator<T>,
5147        error: &JsValue,
5148    ) -> Result<Promise<IteratorNext<T>>, JsValue>;
5149}
5150
5151impl<T: FromWasmAbi> AsyncIterable for AsyncGenerator<T> {
5152    type Item = T;
5153}
5154
5155// Map
5156#[wasm_bindgen]
5157extern "C" {
5158    #[wasm_bindgen(extends = Object, typescript_type = "Map<any, any>")]
5159    #[derive(Clone, Debug, PartialEq, Eq)]
5160    pub type Map<K = JsValue, V = JsValue>;
5161
5162    /// The Map object holds key-value pairs. Any value (both objects and
5163    /// primitive values) maybe used as either a key or a value.
5164    ///
5165    /// **Note:** Consider using [`Map::new_typed`] for typing support.
5166    ///
5167    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map)
5168    #[cfg(not(js_sys_unstable_apis))]
5169    #[wasm_bindgen(constructor)]
5170    pub fn new() -> Map;
5171
5172    /// The Map object holds key-value pairs. Any value (both objects and
5173    /// primitive values) maybe used as either a key or a value.
5174    ///
5175    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map)
5176    #[cfg(js_sys_unstable_apis)]
5177    #[wasm_bindgen(constructor)]
5178    pub fn new<K, V>() -> Map<K, V>;
5179
5180    // Next major: deprecate
5181    /// The Map object holds key-value pairs. Any value (both objects and
5182    /// primitive values) maybe used as either a key or a value.
5183    ///
5184    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map)
5185    #[wasm_bindgen(constructor)]
5186    pub fn new_typed<K, V>() -> Map<K, V>;
5187
5188    /// The Map object holds key-value pairs. Any value (both objects and
5189    /// primitive values) maybe used as either a key or a value.
5190    ///
5191    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map)
5192    #[wasm_bindgen(constructor, js_name = new)]
5193    pub fn new_from_entries<K, V, I: Iterable<Item = ArrayTuple<(K, V)>>>(entries: &I)
5194        -> Map<K, V>;
5195
5196    /// The `clear()` method removes all elements from a Map object.
5197    ///
5198    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/clear)
5199    #[wasm_bindgen(method)]
5200    pub fn clear<K, V>(this: &Map<K, V>);
5201
5202    /// The `delete()` method removes the specified element from a Map object.
5203    ///
5204    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/delete)
5205    #[wasm_bindgen(method)]
5206    pub fn delete<K, V>(this: &Map<K, V>, key: &K) -> bool;
5207
5208    /// The `forEach()` method executes a provided function once per each
5209    /// key/value pair in the Map object, in insertion order.
5210    /// Note that in Javascript land the `Key` and `Value` are reversed compared to normal expectations:
5211    /// # Examples
5212    /// ```
5213    /// let js_map = Map::new();
5214    /// js_map.for_each(&mut |value, key| {
5215    ///     // Do something here...
5216    /// })
5217    /// ```
5218    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/forEach)
5219    #[wasm_bindgen(method, js_name = forEach)]
5220    pub fn for_each<K, V>(this: &Map<K, V>, callback: &mut dyn FnMut(V, K));
5221
5222    /// The `forEach()` method executes a provided function once per each
5223    /// key/value pair in the Map object, in insertion order. _(Fallible variation)_
5224    /// Note that in Javascript land the `Key` and `Value` are reversed compared to normal expectations:
5225    /// # Examples
5226    /// ```
5227    /// let js_map = Map::new();
5228    /// js_map.for_each(&mut |value, key| {
5229    ///     // Do something here...
5230    /// })
5231    /// ```
5232    ///
5233    /// **Note:** Consider using [`Map::try_for_each`] if the callback might throw an error.
5234    ///
5235    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/forEach)
5236    #[wasm_bindgen(method, js_name = forEach, catch)]
5237    pub fn try_for_each<K, V>(
5238        this: &Map<K, V>,
5239        callback: &mut dyn FnMut(V, K) -> Result<(), JsError>,
5240    ) -> Result<(), JsValue>;
5241
5242    /// The `get()` method returns a specified element from a Map object.
5243    /// Returns `undefined` if the key is not found.
5244    ///
5245    /// **Note:** Consider using [`Map::get_checked`] to get an `Option<V>` instead.
5246    ///
5247    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/get)
5248    #[cfg(not(js_sys_unstable_apis))]
5249    #[wasm_bindgen(method)]
5250    pub fn get<K, V>(this: &Map<K, V>, key: &K) -> V;
5251
5252    /// The `get()` method returns a specified element from a Map object.
5253    /// Returns `None` if the key is not found.
5254    ///
5255    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/get)
5256    #[cfg(js_sys_unstable_apis)]
5257    #[wasm_bindgen(method)]
5258    pub fn get<K, V>(this: &Map<K, V>, key: &K) -> Option<V>;
5259
5260    /// The `get()` method returns a specified element from a Map object.
5261    /// Returns `None` if the key is not found.
5262    ///
5263    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/get)
5264    #[wasm_bindgen(method, js_name = get)]
5265    pub fn get_checked<K, V>(this: &Map<K, V>, key: &K) -> Option<V>;
5266
5267    /// The `has()` method returns a boolean indicating whether an element with
5268    /// the specified key exists or not.
5269    ///
5270    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/has)
5271    #[wasm_bindgen(method)]
5272    pub fn has<K, V>(this: &Map<K, V>, key: &K) -> bool;
5273
5274    /// The `set()` method adds or updates an element with a specified key
5275    /// and value to a Map object.
5276    ///
5277    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/set)
5278    #[wasm_bindgen(method)]
5279    pub fn set<K, V>(this: &Map<K, V>, key: &K, value: &V) -> Map<K, V>;
5280
5281    /// The value of size is an integer representing how many entries
5282    /// the Map object has. A set accessor function for size is undefined;
5283    /// you can not change this property.
5284    ///
5285    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/size)
5286    #[wasm_bindgen(method, getter)]
5287    pub fn size<K, V>(this: &Map<K, V>) -> u32;
5288}
5289
5290impl Default for Map<JsValue, JsValue> {
5291    fn default() -> Self {
5292        Self::new()
5293    }
5294}
5295
5296// Map Iterator
5297#[wasm_bindgen]
5298extern "C" {
5299    /// The `entries()` method returns a new Iterator object that contains
5300    /// the [key, value] pairs for each element in the Map object in
5301    /// insertion order.
5302    ///
5303    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/entries)
5304    #[cfg(not(js_sys_unstable_apis))]
5305    #[wasm_bindgen(method)]
5306    pub fn entries<K, V: FromWasmAbi>(this: &Map<K, V>) -> Iterator;
5307
5308    /// The `entries()` method returns a new Iterator object that contains
5309    /// the [key, value] pairs for each element in the Map object in
5310    /// insertion order.
5311    ///
5312    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/entries)
5313    #[cfg(js_sys_unstable_apis)]
5314    #[wasm_bindgen(method, js_name = entries)]
5315    pub fn entries<K: JsGeneric, V: FromWasmAbi + JsGeneric>(
5316        this: &Map<K, V>,
5317    ) -> Iterator<ArrayTuple<(K, V)>>;
5318
5319    // Next major: deprecate
5320    /// The `entries()` method returns a new Iterator object that contains
5321    /// the [key, value] pairs for each element in the Map object in
5322    /// insertion order.
5323    ///
5324    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/entries)
5325    #[wasm_bindgen(method, js_name = entries)]
5326    pub fn entries_typed<K: JsGeneric, V: FromWasmAbi + JsGeneric>(
5327        this: &Map<K, V>,
5328    ) -> Iterator<ArrayTuple<(K, V)>>;
5329
5330    /// The `keys()` method returns a new Iterator object that contains the
5331    /// keys for each element in the Map object in insertion order.
5332    ///
5333    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/keys)
5334    #[wasm_bindgen(method)]
5335    pub fn keys<K: FromWasmAbi, V: FromWasmAbi>(this: &Map<K, V>) -> Iterator<K>;
5336
5337    /// The `values()` method returns a new Iterator object that contains the
5338    /// values for each element in the Map object in insertion order.
5339    ///
5340    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/values)
5341    #[wasm_bindgen(method)]
5342    pub fn values<K, V: FromWasmAbi>(this: &Map<K, V>) -> Iterator<V>;
5343}
5344
5345impl<K, V> Iterable for Map<K, V> {
5346    type Item = ArrayTuple<(K, V)>;
5347}
5348
5349// Iterator
5350#[wasm_bindgen]
5351extern "C" {
5352    /// Any object that conforms to the JS iterator protocol. For example,
5353    /// something returned by `myArray[Symbol.iterator]()`.
5354    ///
5355    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols)
5356    #[derive(Clone, Debug)]
5357    #[wasm_bindgen(is_type_of = Iterator::looks_like_iterator, typescript_type = "Iterator<any>")]
5358    pub type Iterator<T = JsValue>;
5359
5360    /// The `next()` method always has to return an object with appropriate
5361    /// properties including done and value. If a non-object value gets returned
5362    /// (such as false or undefined), a TypeError ("iterator.next() returned a
5363    /// non-object value") will be thrown.
5364    #[wasm_bindgen(catch, method)]
5365    pub fn next<T: FromWasmAbi>(this: &Iterator<T>) -> Result<IteratorNext<T>, JsValue>;
5366}
5367
5368impl<T> UpcastFrom<Iterator<T>> for Object {}
5369
5370impl Iterator {
5371    fn looks_like_iterator(it: &JsValue) -> bool {
5372        #[wasm_bindgen]
5373        extern "C" {
5374            #[derive(Clone, Debug)]
5375            type MaybeIterator;
5376
5377            #[wasm_bindgen(method, getter)]
5378            fn next(this: &MaybeIterator) -> JsValue;
5379        }
5380
5381        if !it.is_object() {
5382            return false;
5383        }
5384
5385        let it = it.unchecked_ref::<MaybeIterator>();
5386
5387        it.next().is_function()
5388    }
5389}
5390
5391// iterators in JS are themselves iterable
5392impl<T> Iterable for Iterator<T> {
5393    type Item = T;
5394}
5395
5396// Async Iterator
5397#[wasm_bindgen]
5398extern "C" {
5399    /// Any object that conforms to the JS async iterator protocol. For example,
5400    /// something returned by `myObject[Symbol.asyncIterator]()`.
5401    ///
5402    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of)
5403    #[derive(Clone, Debug)]
5404    #[wasm_bindgen(is_type_of = Iterator::looks_like_iterator, typescript_type = "AsyncIterator<any>")]
5405    pub type AsyncIterator<T = JsValue>;
5406
5407    /// The `next()` method always has to return a Promise which resolves to an object
5408    /// with appropriate properties including done and value. If a non-object value
5409    /// gets returned (such as false or undefined), a TypeError ("iterator.next()
5410    /// returned a non-object value") will be thrown.
5411    #[cfg(not(js_sys_unstable_apis))]
5412    #[wasm_bindgen(catch, method)]
5413    pub fn next<T>(this: &AsyncIterator<T>) -> Result<Promise, JsValue>;
5414
5415    /// The `next()` method always has to return a Promise which resolves to an object
5416    /// with appropriate properties including done and value. If a non-object value
5417    /// gets returned (such as false or undefined), a TypeError ("iterator.next()
5418    /// returned a non-object value") will be thrown.
5419    #[cfg(js_sys_unstable_apis)]
5420    #[wasm_bindgen(catch, method, js_name = next)]
5421    pub fn next<T: FromWasmAbi>(
5422        this: &AsyncIterator<T>,
5423    ) -> Result<Promise<IteratorNext<T>>, JsValue>;
5424
5425    // Next major: deprecate
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    #[wasm_bindgen(catch, method, js_name = next)]
5431    pub fn next_iterator<T: FromWasmAbi>(
5432        this: &AsyncIterator<T>,
5433    ) -> Result<Promise<IteratorNext<T>>, JsValue>;
5434}
5435
5436impl<T> UpcastFrom<AsyncIterator<T>> for Object {}
5437
5438// iterators in JS are themselves iterable
5439impl<T> AsyncIterable for AsyncIterator<T> {
5440    type Item = T;
5441}
5442
5443/// An iterator over the JS `Symbol.iterator` iteration protocol.
5444///
5445/// Use the `IntoIterator for &js_sys::Iterator` implementation to create this.
5446pub struct Iter<'a, T = JsValue> {
5447    js: &'a Iterator<T>,
5448    state: IterState,
5449}
5450
5451/// An iterator over the JS `Symbol.iterator` iteration protocol.
5452///
5453/// Use the `IntoIterator for js_sys::Iterator` implementation to create this.
5454pub struct IntoIter<T = JsValue> {
5455    js: Iterator<T>,
5456    state: IterState,
5457}
5458
5459struct IterState {
5460    done: bool,
5461}
5462
5463impl<'a, T: FromWasmAbi + JsGeneric> IntoIterator for &'a Iterator<T> {
5464    type Item = Result<T, JsValue>;
5465    type IntoIter = Iter<'a, T>;
5466
5467    fn into_iter(self) -> Iter<'a, T> {
5468        Iter {
5469            js: self,
5470            state: IterState::new(),
5471        }
5472    }
5473}
5474
5475impl<T: FromWasmAbi + JsGeneric> core::iter::Iterator for Iter<'_, T> {
5476    type Item = Result<T, JsValue>;
5477
5478    fn next(&mut self) -> Option<Self::Item> {
5479        self.state.next(self.js)
5480    }
5481}
5482
5483impl<T: FromWasmAbi + JsGeneric> IntoIterator for Iterator<T> {
5484    type Item = Result<T, JsValue>;
5485    type IntoIter = IntoIter<T>;
5486
5487    fn into_iter(self) -> IntoIter<T> {
5488        IntoIter {
5489            js: self,
5490            state: IterState::new(),
5491        }
5492    }
5493}
5494
5495impl<T: FromWasmAbi + JsGeneric> core::iter::Iterator for IntoIter<T> {
5496    type Item = Result<T, JsValue>;
5497
5498    fn next(&mut self) -> Option<Self::Item> {
5499        self.state.next(&self.js)
5500    }
5501}
5502
5503impl IterState {
5504    fn new() -> IterState {
5505        IterState { done: false }
5506    }
5507
5508    fn next<T: FromWasmAbi + JsGeneric>(&mut self, js: &Iterator<T>) -> Option<Result<T, JsValue>> {
5509        if self.done {
5510            return None;
5511        }
5512        let next = match js.next() {
5513            Ok(val) => val,
5514            Err(e) => {
5515                self.done = true;
5516                return Some(Err(e));
5517            }
5518        };
5519        if next.done() {
5520            self.done = true;
5521            None
5522        } else {
5523            Some(Ok(next.value()))
5524        }
5525    }
5526}
5527
5528/// Create an iterator over `val` using the JS iteration protocol and
5529/// `Symbol.iterator`.
5530// #[cfg(not(js_sys_unstable_apis))]
5531pub fn try_iter(val: &JsValue) -> Result<Option<IntoIter<JsValue>>, JsValue> {
5532    let iter_sym = Symbol::iterator();
5533
5534    let iter_fn = Reflect::get_symbol::<Object>(val.unchecked_ref(), iter_sym.as_ref())?;
5535    let iter_fn: Function = match iter_fn.dyn_into() {
5536        Ok(iter_fn) => iter_fn,
5537        Err(_) => return Ok(None),
5538    };
5539
5540    let it: Iterator = match iter_fn.call0(val)?.dyn_into() {
5541        Ok(it) => it,
5542        Err(_) => return Ok(None),
5543    };
5544
5545    Ok(Some(it.into_iter()))
5546}
5547
5548/// Trait for JavaScript types that implement the iterable protocol via `Symbol.iterator`.
5549///
5550/// Types implementing this trait can be iterated over using JavaScript's iteration
5551/// protocol. The `Item` associated type specifies the type of values yielded.
5552///
5553/// ## Built-in Iterables
5554///
5555/// Many `js-sys` collection types implement `Iterable` out of the box:
5556///
5557/// ```ignore
5558/// use js_sys::{Array, Map, Set};
5559///
5560/// // Array<T> yields T
5561/// let arr: Array<Number> = get_numbers();
5562/// for value in arr.iter() {
5563///     let num: Number = value?;
5564/// }
5565///
5566/// // Map<K, V> yields Array (key-value pairs)
5567/// let map: Map<JsString, Number> = get_map();
5568/// for entry in map.iter() {
5569///     let pair: Array = entry?;
5570/// }
5571///
5572/// // Set<T> yields T
5573/// let set: Set<JsString> = get_set();
5574/// for value in set.iter() {
5575///     let s: JsString = value?;
5576/// }
5577/// ```
5578///
5579/// ## Typing Foreign Iterators
5580///
5581/// If you have a JavaScript value that implements the iterator protocol (has a `next()`
5582/// method) but isn't a built-in type, you can use [`JsCast`] to cast it to [`Iterator<T>`]:
5583///
5584/// ```ignore
5585/// use js_sys::Iterator;
5586/// use wasm_bindgen::JsCast;
5587///
5588/// // For a value you know implements the iterator protocol
5589/// fn process_iterator(js_iter: JsValue) {
5590///     // Checked cast - returns None if not an iterator
5591///     if let Some(iter) = js_iter.dyn_ref::<Iterator<Number>>() {
5592///         for value in iter.into_iter() {
5593///             let num: Number = value.unwrap();
5594///             // ...
5595///         }
5596///     }
5597/// }
5598///
5599/// // Or with unchecked cast when you're certain of the type
5600/// fn process_known_iterator(js_iter: JsValue) {
5601///     let iter: &Iterator<JsString> = js_iter.unchecked_ref();
5602///     for value in iter.into_iter() {
5603///         let s: JsString = value.unwrap();
5604///         // ...
5605///     }
5606/// }
5607/// ```
5608///
5609/// ## Using with `JsValue`
5610///
5611/// For dynamic or unknown iterables, use [`try_iter`] which returns an untyped iterator:
5612///
5613/// ```ignore
5614/// fn iterate_unknown(val: &JsValue) -> Result<(), JsValue> {
5615///     if let Some(iter) = js_sys::try_iter(val)? {
5616///         for item in iter {
5617///             let value: JsValue = item?;
5618///             // Handle dynamically...
5619///         }
5620///     }
5621///     Ok(())
5622/// }
5623/// ```
5624///
5625/// [`JsCast`]: wasm_bindgen::JsCast
5626/// [`Iterator<T>`]: Iterator
5627/// [`try_iter`]: crate::try_iter
5628pub trait Iterable {
5629    /// The type of values yielded by this iterable.
5630    type Item;
5631}
5632
5633impl<T: Iterable> Iterable for &T {
5634    type Item = T::Item;
5635}
5636
5637/// Trait for types known to implement the iterator protocol on Symbol.asyncIterator
5638pub trait AsyncIterable {
5639    type Item;
5640}
5641
5642impl<T: AsyncIterable> AsyncIterable for &T {
5643    type Item = T::Item;
5644}
5645
5646impl AsyncIterable for JsValue {
5647    type Item = JsValue;
5648}
5649
5650// IteratorNext
5651#[wasm_bindgen]
5652extern "C" {
5653    /// The result of calling `next()` on a JS iterator.
5654    ///
5655    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols)
5656    #[wasm_bindgen(extends = Object, typescript_type = "IteratorResult<any>")]
5657    #[derive(Clone, Debug, PartialEq, Eq)]
5658    pub type IteratorNext<T = JsValue>;
5659
5660    /// Has the value `true` if the iterator is past the end of the iterated
5661    /// sequence. In this case value optionally specifies the return value of
5662    /// the iterator.
5663    ///
5664    /// Has the value `false` if the iterator was able to produce the next value
5665    /// in the sequence. This is equivalent of not specifying the done property
5666    /// altogether.
5667    #[wasm_bindgen(method, getter)]
5668    pub fn done<T>(this: &IteratorNext<T>) -> bool;
5669
5670    /// Any JavaScript value returned by the iterator. Can be omitted when done
5671    /// is true.
5672    #[wasm_bindgen(method, getter)]
5673    pub fn value<T>(this: &IteratorNext<T>) -> T;
5674}
5675
5676#[allow(non_snake_case)]
5677pub mod Math {
5678    use super::*;
5679
5680    // Math
5681    #[wasm_bindgen]
5682    extern "C" {
5683        /// The `Math.abs()` function returns the absolute value of a number, that is
5684        /// Math.abs(x) = |x|
5685        ///
5686        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/abs)
5687        #[wasm_bindgen(js_namespace = Math)]
5688        pub fn abs(x: f64) -> f64;
5689
5690        /// The `Math.acos()` function returns the arccosine (in radians) of a
5691        /// number, that is ∀x∊[-1;1]
5692        /// Math.acos(x) = arccos(x) = the unique y∊[0;π] such that cos(y)=x
5693        ///
5694        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/acos)
5695        #[wasm_bindgen(js_namespace = Math)]
5696        pub fn acos(x: f64) -> f64;
5697
5698        /// The `Math.acosh()` function returns the hyperbolic arc-cosine of a
5699        /// number, that is ∀x ≥ 1
5700        /// Math.acosh(x) = arcosh(x) = the unique y ≥ 0 such that cosh(y) = x
5701        ///
5702        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/acosh)
5703        #[wasm_bindgen(js_namespace = Math)]
5704        pub fn acosh(x: f64) -> f64;
5705
5706        /// The `Math.asin()` function returns the arcsine (in radians) of a
5707        /// number, that is ∀x ∊ [-1;1]
5708        /// Math.asin(x) = arcsin(x) = the unique y∊[-π2;π2] such that sin(y) = x
5709        ///
5710        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/asin)
5711        #[wasm_bindgen(js_namespace = Math)]
5712        pub fn asin(x: f64) -> f64;
5713
5714        /// The `Math.asinh()` function returns the hyperbolic arcsine of a
5715        /// number, that is Math.asinh(x) = arsinh(x) = the unique y such that sinh(y) = x
5716        ///
5717        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/asinh)
5718        #[wasm_bindgen(js_namespace = Math)]
5719        pub fn asinh(x: f64) -> f64;
5720
5721        /// The `Math.atan()` function returns the arctangent (in radians) of a
5722        /// number, that is Math.atan(x) = arctan(x) = the unique y ∊ [-π2;π2]such that
5723        /// tan(y) = x
5724        #[wasm_bindgen(js_namespace = Math)]
5725        pub fn atan(x: f64) -> f64;
5726
5727        /// The `Math.atan2()` function returns the arctangent of the quotient of
5728        /// its arguments.
5729        ///
5730        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atan2)
5731        #[wasm_bindgen(js_namespace = Math)]
5732        pub fn atan2(y: f64, x: f64) -> f64;
5733
5734        /// The `Math.atanh()` function returns the hyperbolic arctangent of a number,
5735        /// that is ∀x ∊ (-1,1), Math.atanh(x) = arctanh(x) = the unique y such that
5736        /// tanh(y) = x
5737        ///
5738        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atanh)
5739        #[wasm_bindgen(js_namespace = Math)]
5740        pub fn atanh(x: f64) -> f64;
5741
5742        /// The `Math.cbrt() `function returns the cube root of a number, that is
5743        /// Math.cbrt(x) = ∛x = the unique y such that y^3 = x
5744        ///
5745        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cbrt)
5746        #[wasm_bindgen(js_namespace = Math)]
5747        pub fn cbrt(x: f64) -> f64;
5748
5749        /// The `Math.ceil()` function returns the smallest integer greater than
5750        /// or equal to a given number.
5751        ///
5752        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/ceil)
5753        #[wasm_bindgen(js_namespace = Math)]
5754        pub fn ceil(x: f64) -> f64;
5755
5756        /// The `Math.clz32()` function returns the number of leading zero bits in
5757        /// the 32-bit binary representation of a number.
5758        ///
5759        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/clz32)
5760        #[wasm_bindgen(js_namespace = Math)]
5761        pub fn clz32(x: i32) -> u32;
5762
5763        /// The `Math.cos()` static function returns the cosine of the specified angle,
5764        /// which must be specified in radians. This value is length(adjacent)/length(hypotenuse).
5765        ///
5766        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cos)
5767        #[wasm_bindgen(js_namespace = Math)]
5768        pub fn cos(x: f64) -> f64;
5769
5770        /// The `Math.cosh()` function returns the hyperbolic cosine of a number,
5771        /// that can be expressed using the constant e.
5772        ///
5773        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cosh)
5774        #[wasm_bindgen(js_namespace = Math)]
5775        pub fn cosh(x: f64) -> f64;
5776
5777        /// The `Math.exp()` function returns e^x, where x is the argument, and e is Euler's number
5778        /// (also known as Napier's constant), the base of the natural logarithms.
5779        ///
5780        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/exp)
5781        #[wasm_bindgen(js_namespace = Math)]
5782        pub fn exp(x: f64) -> f64;
5783
5784        /// The `Math.expm1()` function returns e^x - 1, where x is the argument, and e the base of the
5785        /// natural logarithms.
5786        ///
5787        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/expm1)
5788        #[wasm_bindgen(js_namespace = Math)]
5789        pub fn expm1(x: f64) -> f64;
5790
5791        /// The `Math.floor()` function returns the largest integer less than or
5792        /// equal to a given number.
5793        ///
5794        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/floor)
5795        #[wasm_bindgen(js_namespace = Math)]
5796        pub fn floor(x: f64) -> f64;
5797
5798        /// The `Math.fround()` function returns the nearest 32-bit single precision float representation
5799        /// of a Number.
5800        ///
5801        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/fround)
5802        #[wasm_bindgen(js_namespace = Math)]
5803        pub fn fround(x: f64) -> f32;
5804
5805        /// The `Math.hypot()` function returns the square root of the sum of squares of its arguments.
5806        ///
5807        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/hypot)
5808        #[wasm_bindgen(js_namespace = Math)]
5809        pub fn hypot(x: f64, y: f64) -> f64;
5810
5811        /// The `Math.imul()` function returns the result of the C-like 32-bit multiplication of the
5812        /// two parameters.
5813        ///
5814        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul)
5815        #[wasm_bindgen(js_namespace = Math)]
5816        pub fn imul(x: i32, y: i32) -> i32;
5817
5818        /// The `Math.log()` function returns the natural logarithm (base e) of a number.
5819        /// The JavaScript `Math.log()` function is equivalent to ln(x) in mathematics.
5820        ///
5821        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log)
5822        #[wasm_bindgen(js_namespace = Math)]
5823        pub fn log(x: f64) -> f64;
5824
5825        /// The `Math.log10()` function returns the base 10 logarithm of a number.
5826        ///
5827        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log10)
5828        #[wasm_bindgen(js_namespace = Math)]
5829        pub fn log10(x: f64) -> f64;
5830
5831        /// The `Math.log1p()` function returns the natural logarithm (base e) of 1 + a number.
5832        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log1p)
5833        #[wasm_bindgen(js_namespace = Math)]
5834        pub fn log1p(x: f64) -> f64;
5835
5836        /// The `Math.log2()` function returns the base 2 logarithm of a number.
5837        ///
5838        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log2)
5839        #[wasm_bindgen(js_namespace = Math)]
5840        pub fn log2(x: f64) -> f64;
5841
5842        /// The `Math.max()` function returns the largest of two numbers.
5843        ///
5844        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/max)
5845        #[wasm_bindgen(js_namespace = Math)]
5846        pub fn max(x: f64, y: f64) -> f64;
5847
5848        /// The static function `Math.min()` returns the lowest-valued number passed into it.
5849        ///
5850        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/min)
5851        #[wasm_bindgen(js_namespace = Math)]
5852        pub fn min(x: f64, y: f64) -> f64;
5853
5854        /// The `Math.pow()` function returns the base to the exponent power, that is, base^exponent.
5855        ///
5856        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/pow)
5857        #[wasm_bindgen(js_namespace = Math)]
5858        pub fn pow(base: f64, exponent: f64) -> f64;
5859
5860        /// The `Math.random()` function returns a floating-point, pseudo-random number
5861        /// in the range 0–1 (inclusive of 0, but not 1) with approximately uniform distribution
5862        /// over that range — which you can then scale to your desired range.
5863        /// The implementation selects the initial seed to the random number generation algorithm;
5864        /// it cannot be chosen or reset by the user.
5865        ///
5866        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random)
5867        #[wasm_bindgen(js_namespace = Math)]
5868        pub fn random() -> f64;
5869
5870        /// The `Math.round()` function returns the value of a number rounded to the nearest integer.
5871        ///
5872        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/round)
5873        #[wasm_bindgen(js_namespace = Math)]
5874        pub fn round(x: f64) -> f64;
5875
5876        /// The `Math.sign()` function returns the sign of a number, indicating whether the number is
5877        /// positive, negative or zero.
5878        ///
5879        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sign)
5880        #[wasm_bindgen(js_namespace = Math)]
5881        pub fn sign(x: f64) -> f64;
5882
5883        /// The `Math.sin()` function returns the sine of a number.
5884        ///
5885        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sin)
5886        #[wasm_bindgen(js_namespace = Math)]
5887        pub fn sin(x: f64) -> f64;
5888
5889        /// The `Math.sinh()` function returns the hyperbolic sine of a number, that can be expressed
5890        /// using the constant e: Math.sinh(x) = (e^x - e^-x)/2
5891        ///
5892        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sinh)
5893        #[wasm_bindgen(js_namespace = Math)]
5894        pub fn sinh(x: f64) -> f64;
5895
5896        /// The `Math.sqrt()` function returns the square root of a number, that is
5897        /// ∀x ≥ 0, Math.sqrt(x) = √x = the unique y ≥ 0 such that y^2 = x
5898        ///
5899        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sqrt)
5900        #[wasm_bindgen(js_namespace = Math)]
5901        pub fn sqrt(x: f64) -> f64;
5902
5903        /// The `Math.tan()` function returns the tangent of a number.
5904        ///
5905        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/tan)
5906        #[wasm_bindgen(js_namespace = Math)]
5907        pub fn tan(x: f64) -> f64;
5908
5909        /// The `Math.tanh()` function returns the hyperbolic tangent of a number, that is
5910        /// tanh x = sinh x / cosh x = (e^x - e^-x)/(e^x + e^-x) = (e^2x - 1)/(e^2x + 1)
5911        ///
5912        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/tanh)
5913        #[wasm_bindgen(js_namespace = Math)]
5914        pub fn tanh(x: f64) -> f64;
5915
5916        /// The `Math.trunc()` function returns the integer part of a number by removing any fractional
5917        /// digits.
5918        ///
5919        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/trunc)
5920        #[wasm_bindgen(js_namespace = Math)]
5921        pub fn trunc(x: f64) -> f64;
5922
5923        /// The `Math.PI` property represents the ratio of the circumference of a circle to its diameter,
5924        /// approximately 3.14159.
5925        ///
5926        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/PI)
5927        #[wasm_bindgen(thread_local_v2, js_namespace = Math)]
5928        pub static PI: f64;
5929    }
5930}
5931
5932// Number.
5933#[wasm_bindgen]
5934extern "C" {
5935    #[wasm_bindgen(extends = Object, is_type_of = |v| v.as_f64().is_some(), typescript_type = "number")]
5936    #[derive(Clone, PartialEq)]
5937    pub type Number;
5938
5939    /// The `Number.isFinite()` method determines whether the passed value is a finite number.
5940    ///
5941    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isFinite)
5942    #[wasm_bindgen(static_method_of = Number, js_name = isFinite)]
5943    pub fn is_finite(value: &JsValue) -> bool;
5944
5945    /// The `Number.isInteger()` method determines whether the passed value is an integer.
5946    ///
5947    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger)
5948    #[wasm_bindgen(static_method_of = Number, js_name = isInteger)]
5949    pub fn is_integer(value: &JsValue) -> bool;
5950
5951    /// The `Number.isNaN()` method determines whether the passed value is `NaN` and its type is Number.
5952    /// It is a more robust version of the original, global isNaN().
5953    ///
5954    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isNaN)
5955    #[wasm_bindgen(static_method_of = Number, js_name = isNaN)]
5956    pub fn is_nan(value: &JsValue) -> bool;
5957
5958    /// The `Number.isSafeInteger()` method determines whether the provided value is a number
5959    /// that is a safe integer.
5960    ///
5961    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger)
5962    #[wasm_bindgen(static_method_of = Number, js_name = isSafeInteger)]
5963    pub fn is_safe_integer(value: &JsValue) -> bool;
5964
5965    /// The `Number` JavaScript object is a wrapper object allowing
5966    /// you to work with numerical values. A `Number` object is
5967    /// created using the `Number()` constructor.
5968    ///
5969    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)
5970    #[cfg(not(js_sys_unstable_apis))]
5971    #[wasm_bindgen(constructor)]
5972    #[deprecated(note = "recommended to use `Number::from` instead")]
5973    #[allow(deprecated)]
5974    pub fn new(value: &JsValue) -> Number;
5975
5976    #[wasm_bindgen(constructor)]
5977    fn new_from_str(value: &str) -> Number;
5978
5979    /// The `Number.parseInt()` method parses a string argument and returns an
5980    /// integer of the specified radix or base.
5981    ///
5982    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/parseInt)
5983    #[wasm_bindgen(static_method_of = Number, js_name = parseInt)]
5984    pub fn parse_int(text: &str, radix: u8) -> f64;
5985
5986    /// The `Number.parseFloat()` method parses a string argument and returns a
5987    /// floating point number.
5988    ///
5989    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/parseFloat)
5990    #[wasm_bindgen(static_method_of = Number, js_name = parseFloat)]
5991    pub fn parse_float(text: &str) -> f64;
5992
5993    /// The `toLocaleString()` method returns a string with a language sensitive
5994    /// representation of this number.
5995    ///
5996    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString)
5997    #[cfg(not(js_sys_unstable_apis))]
5998    #[wasm_bindgen(method, js_name = toLocaleString)]
5999    pub fn to_locale_string(this: &Number, locale: &str) -> JsString;
6000
6001    /// The `toLocaleString()` method returns a string with a language sensitive
6002    /// representation of this number.
6003    ///
6004    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString)
6005    #[cfg(js_sys_unstable_apis)]
6006    #[wasm_bindgen(method, js_name = toLocaleString)]
6007    pub fn to_locale_string(
6008        this: &Number,
6009        locales: &[JsString],
6010        options: &Intl::NumberFormatOptions,
6011    ) -> JsString;
6012
6013    /// The `toPrecision()` method returns a string representing the Number
6014    /// object to the specified precision.
6015    ///
6016    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toPrecision)
6017    #[wasm_bindgen(catch, method, js_name = toPrecision)]
6018    pub fn to_precision(this: &Number, precision: u8) -> Result<JsString, JsValue>;
6019
6020    /// The `toFixed()` method returns a string representing the Number
6021    /// object using fixed-point notation.
6022    ///
6023    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed)
6024    #[wasm_bindgen(catch, method, js_name = toFixed)]
6025    pub fn to_fixed(this: &Number, digits: u8) -> Result<JsString, JsValue>;
6026
6027    /// The `toExponential()` method returns a string representing the Number
6028    /// object in exponential notation.
6029    ///
6030    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toExponential)
6031    #[wasm_bindgen(catch, method, js_name = toExponential)]
6032    pub fn to_exponential(this: &Number, fraction_digits: u8) -> Result<JsString, JsValue>;
6033
6034    /// The `toString()` method returns a string representing the
6035    /// specified Number object.
6036    ///
6037    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString)
6038    #[cfg(not(js_sys_unstable_apis))]
6039    #[deprecated(note = "Use `Number::to_string_with_radix` instead.")]
6040    #[allow(deprecated)]
6041    #[wasm_bindgen(catch, method, js_name = toString)]
6042    pub fn to_string(this: &Number, radix: u8) -> Result<JsString, JsValue>;
6043
6044    /// The `toString()` method returns a string representing the
6045    /// specified Number object.
6046    ///
6047    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString)
6048    #[wasm_bindgen(catch, method, js_name = toString)]
6049    pub fn to_string_with_radix(this: &Number, radix: u8) -> Result<JsString, JsValue>;
6050
6051    /// The `valueOf()` method returns the wrapped primitive value of
6052    /// a Number object.
6053    ///
6054    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/valueOf)
6055    #[wasm_bindgen(method, js_name = valueOf)]
6056    pub fn value_of(this: &Number) -> f64;
6057}
6058
6059impl Number {
6060    /// The smallest interval between two representable numbers.
6061    ///
6062    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/EPSILON)
6063    pub const EPSILON: f64 = f64::EPSILON;
6064    /// The maximum safe integer in JavaScript (2^53 - 1).
6065    ///
6066    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER)
6067    pub const MAX_SAFE_INTEGER: f64 = 9007199254740991.0;
6068    /// The largest positive representable number.
6069    ///
6070    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_VALUE)
6071    pub const MAX_VALUE: f64 = f64::MAX;
6072    /// The minimum safe integer in JavaScript (-(2^53 - 1)).
6073    ///
6074    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MIN_SAFE_INTEGER)
6075    pub const MIN_SAFE_INTEGER: f64 = -9007199254740991.0;
6076    /// The smallest positive representable number—that is, the positive number closest to zero
6077    /// (without actually being zero).
6078    ///
6079    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MIN_VALUE)
6080    // Cannot use f64::MIN_POSITIVE since that is the smallest **normal** positive number.
6081    pub const MIN_VALUE: f64 = 5E-324;
6082    /// Special "Not a Number" value.
6083    ///
6084    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/NaN)
6085    pub const NAN: f64 = f64::NAN;
6086    /// Special value representing negative infinity. Returned on overflow.
6087    ///
6088    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/NEGATIVE_INFINITY)
6089    pub const NEGATIVE_INFINITY: f64 = f64::NEG_INFINITY;
6090    /// Special value representing infinity. Returned on overflow.
6091    ///
6092    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/POSITIVE_INFINITY)
6093    pub const POSITIVE_INFINITY: f64 = f64::INFINITY;
6094
6095    /// Applies the binary `**` JS operator on the two `Number`s.
6096    ///
6097    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Exponentiation)
6098    #[inline]
6099    pub fn pow(&self, rhs: &Self) -> Self {
6100        JsValue::as_ref(self)
6101            .pow(JsValue::as_ref(rhs))
6102            .unchecked_into()
6103    }
6104
6105    /// Applies the binary `>>>` JS operator on the two `Number`s.
6106    ///
6107    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Unsigned_right_shift)
6108    #[inline]
6109    pub fn unsigned_shr(&self, rhs: &Self) -> Self {
6110        Number::from(JsValue::as_ref(self).unsigned_shr(JsValue::as_ref(rhs)))
6111    }
6112}
6113
6114macro_rules! number_from {
6115    ($($x:ident)*) => ($(
6116        impl From<$x> for Number {
6117            #[inline]
6118            fn from(x: $x) -> Number {
6119                Number::unchecked_from_js(JsValue::from(x))
6120            }
6121        }
6122
6123        impl PartialEq<$x> for Number {
6124            #[inline]
6125            fn eq(&self, other: &$x) -> bool {
6126                self.value_of() == f64::from(*other)
6127            }
6128        }
6129
6130        impl UpcastFrom<$x> for Number {}
6131    )*)
6132}
6133number_from!(i8 u8 i16 u16 i32 u32 f32 f64);
6134
6135// The only guarantee for a JS number
6136impl UpcastFrom<Number> for f64 {}
6137
6138/// The error type returned when a checked integral type conversion fails.
6139#[derive(Debug, Copy, Clone, PartialEq, Eq)]
6140pub struct TryFromIntError(());
6141
6142impl fmt::Display for TryFromIntError {
6143    fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
6144        fmt.write_str("out of range integral type conversion attempted")
6145    }
6146}
6147
6148#[cfg(feature = "std")]
6149impl std::error::Error for TryFromIntError {}
6150
6151macro_rules! number_try_from {
6152    ($($x:ident)*) => ($(
6153        impl TryFrom<$x> for Number {
6154            type Error = TryFromIntError;
6155
6156            #[inline]
6157            fn try_from(x: $x) -> Result<Number, Self::Error> {
6158                let x_f64 = x as f64;
6159                if (Number::MIN_SAFE_INTEGER..=Number::MAX_SAFE_INTEGER).contains(&x_f64) {
6160                    Ok(Number::from(x_f64))
6161                } else {
6162                    Err(TryFromIntError(()))
6163                }
6164            }
6165        }
6166    )*)
6167}
6168number_try_from!(i64 u64 i128 u128);
6169
6170impl From<&Number> for f64 {
6171    #[inline]
6172    fn from(n: &Number) -> f64 {
6173        n.value_of()
6174    }
6175}
6176
6177impl From<Number> for f64 {
6178    #[inline]
6179    fn from(n: Number) -> f64 {
6180        <f64 as From<&'_ Number>>::from(&n)
6181    }
6182}
6183
6184impl fmt::Debug for Number {
6185    #[inline]
6186    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
6187        fmt::Debug::fmt(&self.value_of(), f)
6188    }
6189}
6190
6191impl fmt::Display for Number {
6192    #[inline]
6193    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
6194        fmt::Display::fmt(&self.value_of(), f)
6195    }
6196}
6197
6198impl Default for Number {
6199    fn default() -> Self {
6200        Self::from(f64::default())
6201    }
6202}
6203
6204impl PartialEq<BigInt> for Number {
6205    #[inline]
6206    fn eq(&self, other: &BigInt) -> bool {
6207        JsValue::as_ref(self).loose_eq(JsValue::as_ref(other))
6208    }
6209}
6210
6211impl Not for &Number {
6212    type Output = BigInt;
6213
6214    #[inline]
6215    fn not(self) -> Self::Output {
6216        JsValue::as_ref(self).bit_not().unchecked_into()
6217    }
6218}
6219
6220forward_deref_unop!(impl Not, not for Number);
6221forward_js_unop!(impl Neg, neg for Number);
6222forward_js_binop!(impl BitAnd, bitand for Number);
6223forward_js_binop!(impl BitOr, bitor for Number);
6224forward_js_binop!(impl BitXor, bitxor for Number);
6225forward_js_binop!(impl Shl, shl for Number);
6226forward_js_binop!(impl Shr, shr for Number);
6227forward_js_binop!(impl Add, add for Number);
6228forward_js_binop!(impl Sub, sub for Number);
6229forward_js_binop!(impl Div, div for Number);
6230forward_js_binop!(impl Mul, mul for Number);
6231forward_js_binop!(impl Rem, rem for Number);
6232
6233sum_product!(Number);
6234
6235impl PartialOrd for Number {
6236    #[inline]
6237    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
6238        if Number::is_nan(self) || Number::is_nan(other) {
6239            None
6240        } else if self == other {
6241            Some(Ordering::Equal)
6242        } else if self.lt(other) {
6243            Some(Ordering::Less)
6244        } else {
6245            Some(Ordering::Greater)
6246        }
6247    }
6248
6249    #[inline]
6250    fn lt(&self, other: &Self) -> bool {
6251        JsValue::as_ref(self).lt(JsValue::as_ref(other))
6252    }
6253
6254    #[inline]
6255    fn le(&self, other: &Self) -> bool {
6256        JsValue::as_ref(self).le(JsValue::as_ref(other))
6257    }
6258
6259    #[inline]
6260    fn ge(&self, other: &Self) -> bool {
6261        JsValue::as_ref(self).ge(JsValue::as_ref(other))
6262    }
6263
6264    #[inline]
6265    fn gt(&self, other: &Self) -> bool {
6266        JsValue::as_ref(self).gt(JsValue::as_ref(other))
6267    }
6268}
6269
6270#[cfg(not(js_sys_unstable_apis))]
6271impl FromStr for Number {
6272    type Err = Infallible;
6273
6274    #[allow(deprecated)]
6275    #[inline]
6276    fn from_str(s: &str) -> Result<Self, Self::Err> {
6277        Ok(Number::new_from_str(s))
6278    }
6279}
6280
6281// Date.
6282#[wasm_bindgen]
6283extern "C" {
6284    #[wasm_bindgen(extends = Object, typescript_type = "Date")]
6285    #[derive(Clone, Debug, PartialEq, Eq)]
6286    pub type Date;
6287
6288    /// The `getDate()` method returns the day of the month for the
6289    /// specified date according to local time.
6290    ///
6291    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getDate)
6292    #[wasm_bindgen(method, js_name = getDate)]
6293    pub fn get_date(this: &Date) -> u32;
6294
6295    /// The `getDay()` method returns the day of the week for the specified date according to local time,
6296    /// where 0 represents Sunday. For the day of the month see getDate().
6297    ///
6298    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getDay)
6299    #[wasm_bindgen(method, js_name = getDay)]
6300    pub fn get_day(this: &Date) -> u32;
6301
6302    /// The `getFullYear()` method returns the year of the specified date according to local time.
6303    ///
6304    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getFullYear)
6305    #[wasm_bindgen(method, js_name = getFullYear)]
6306    pub fn get_full_year(this: &Date) -> u32;
6307
6308    /// The `getHours()` method returns the hour for the specified date, according to local time.
6309    ///
6310    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getHours)
6311    #[wasm_bindgen(method, js_name = getHours)]
6312    pub fn get_hours(this: &Date) -> u32;
6313
6314    /// The `getMilliseconds()` method returns the milliseconds in the specified date according to local time.
6315    ///
6316    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMilliseconds)
6317    #[wasm_bindgen(method, js_name = getMilliseconds)]
6318    pub fn get_milliseconds(this: &Date) -> u32;
6319
6320    /// The `getMinutes()` method returns the minutes in the specified date according to local time.
6321    ///
6322    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMinutes)
6323    #[wasm_bindgen(method, js_name = getMinutes)]
6324    pub fn get_minutes(this: &Date) -> u32;
6325
6326    /// The `getMonth()` method returns the month in the specified date according to local time,
6327    /// as a zero-based value (where zero indicates the first month of the year).
6328    ///
6329    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMonth)
6330    #[wasm_bindgen(method, js_name = getMonth)]
6331    pub fn get_month(this: &Date) -> u32;
6332
6333    /// The `getSeconds()` method returns the seconds in the specified date according to local time.
6334    ///
6335    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getSeconds)
6336    #[wasm_bindgen(method, js_name = getSeconds)]
6337    pub fn get_seconds(this: &Date) -> u32;
6338
6339    /// The `getTime()` method returns the numeric value corresponding to the time for the specified date
6340    /// according to universal time.
6341    ///
6342    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTime)
6343    #[wasm_bindgen(method, js_name = getTime)]
6344    pub fn get_time(this: &Date) -> f64;
6345
6346    /// The `getTimezoneOffset()` method returns the time zone difference, in minutes,
6347    /// from current locale (host system settings) to UTC.
6348    ///
6349    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset)
6350    #[wasm_bindgen(method, js_name = getTimezoneOffset)]
6351    pub fn get_timezone_offset(this: &Date) -> f64;
6352
6353    /// The `getUTCDate()` method returns the day (date) of the month in the specified date
6354    /// according to universal time.
6355    ///
6356    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCDate)
6357    #[wasm_bindgen(method, js_name = getUTCDate)]
6358    pub fn get_utc_date(this: &Date) -> u32;
6359
6360    /// The `getUTCDay()` method returns the day of the week in the specified date according to universal time,
6361    /// where 0 represents Sunday.
6362    ///
6363    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCDay)
6364    #[wasm_bindgen(method, js_name = getUTCDay)]
6365    pub fn get_utc_day(this: &Date) -> u32;
6366
6367    /// The `getUTCFullYear()` method returns the year in the specified date according to universal time.
6368    ///
6369    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCFullYear)
6370    #[wasm_bindgen(method, js_name = getUTCFullYear)]
6371    pub fn get_utc_full_year(this: &Date) -> u32;
6372
6373    /// The `getUTCHours()` method returns the hours in the specified date according to universal time.
6374    ///
6375    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCHours)
6376    #[wasm_bindgen(method, js_name = getUTCHours)]
6377    pub fn get_utc_hours(this: &Date) -> u32;
6378
6379    /// The `getUTCMilliseconds()` method returns the milliseconds in the specified date
6380    /// according to universal time.
6381    ///
6382    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMilliseconds)
6383    #[wasm_bindgen(method, js_name = getUTCMilliseconds)]
6384    pub fn get_utc_milliseconds(this: &Date) -> u32;
6385
6386    /// The `getUTCMinutes()` method returns the minutes in the specified date according to universal time.
6387    ///
6388    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMinutes)
6389    #[wasm_bindgen(method, js_name = getUTCMinutes)]
6390    pub fn get_utc_minutes(this: &Date) -> u32;
6391
6392    /// The `getUTCMonth()` returns the month of the specified date according to universal time,
6393    /// as a zero-based value (where zero indicates the first month of the year).
6394    ///
6395    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMonth)
6396    #[wasm_bindgen(method, js_name = getUTCMonth)]
6397    pub fn get_utc_month(this: &Date) -> u32;
6398
6399    /// The `getUTCSeconds()` method returns the seconds in the specified date according to universal time.
6400    ///
6401    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCSeconds)
6402    #[wasm_bindgen(method, js_name = getUTCSeconds)]
6403    pub fn get_utc_seconds(this: &Date) -> u32;
6404
6405    /// Creates a JavaScript `Date` instance that represents
6406    /// a single moment in time. `Date` objects are based on a time value that is
6407    /// the number of milliseconds since 1 January 1970 UTC.
6408    ///
6409    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
6410    #[wasm_bindgen(constructor)]
6411    pub fn new(init: &JsValue) -> Date;
6412
6413    /// Creates a JavaScript `Date` instance that represents the current moment in
6414    /// time.
6415    ///
6416    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
6417    #[wasm_bindgen(constructor)]
6418    pub fn new_0() -> Date;
6419
6420    /// Creates a JavaScript `Date` instance that represents
6421    /// a single moment in time. `Date` objects are based on a time value that is
6422    /// the number of milliseconds since 1 January 1970 UTC.
6423    ///
6424    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
6425    #[wasm_bindgen(constructor)]
6426    pub fn new_with_year_month(year: u32, month: i32) -> Date;
6427
6428    /// Creates a JavaScript `Date` instance that represents
6429    /// a single moment in time. `Date` objects are based on a time value that is
6430    /// the number of milliseconds since 1 January 1970 UTC.
6431    ///
6432    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
6433    #[wasm_bindgen(constructor)]
6434    pub fn new_with_year_month_day(year: u32, month: i32, day: i32) -> Date;
6435
6436    /// Creates a JavaScript `Date` instance that represents
6437    /// a single moment in time. `Date` objects are based on a time value that is
6438    /// the number of milliseconds since 1 January 1970 UTC.
6439    ///
6440    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
6441    #[wasm_bindgen(constructor)]
6442    pub fn new_with_year_month_day_hr(year: u32, month: i32, day: i32, hr: i32) -> Date;
6443
6444    /// Creates a JavaScript `Date` instance that represents
6445    /// a single moment in time. `Date` objects are based on a time value that is
6446    /// the number of milliseconds since 1 January 1970 UTC.
6447    ///
6448    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
6449    #[wasm_bindgen(constructor)]
6450    pub fn new_with_year_month_day_hr_min(
6451        year: u32,
6452        month: i32,
6453        day: i32,
6454        hr: i32,
6455        min: i32,
6456    ) -> Date;
6457
6458    /// Creates a JavaScript `Date` instance that represents
6459    /// a single moment in time. `Date` objects are based on a time value that is
6460    /// the number of milliseconds since 1 January 1970 UTC.
6461    ///
6462    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
6463    #[wasm_bindgen(constructor)]
6464    pub fn new_with_year_month_day_hr_min_sec(
6465        year: u32,
6466        month: i32,
6467        day: i32,
6468        hr: i32,
6469        min: i32,
6470        sec: i32,
6471    ) -> Date;
6472
6473    /// Creates a JavaScript `Date` instance that represents
6474    /// a single moment in time. `Date` objects are based on a time value that is
6475    /// the number of milliseconds since 1 January 1970 UTC.
6476    ///
6477    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
6478    #[wasm_bindgen(constructor)]
6479    pub fn new_with_year_month_day_hr_min_sec_milli(
6480        year: u32,
6481        month: i32,
6482        day: i32,
6483        hr: i32,
6484        min: i32,
6485        sec: i32,
6486        milli: i32,
6487    ) -> Date;
6488
6489    /// The `Date.now()` method returns the number of milliseconds
6490    /// elapsed since January 1, 1970 00:00:00 UTC.
6491    ///
6492    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now)
6493    #[wasm_bindgen(static_method_of = Date)]
6494    pub fn now() -> f64;
6495
6496    /// The `Date.parse()` method parses a string representation of a date, and returns the number of milliseconds
6497    /// since January 1, 1970, 00:00:00 UTC or `NaN` if the string is unrecognized or, in some cases,
6498    /// contains illegal date values (e.g. 2015-02-31).
6499    ///
6500    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse)
6501    #[wasm_bindgen(static_method_of = Date)]
6502    pub fn parse(date: &str) -> f64;
6503
6504    /// The `setDate()` method sets the day of the Date object relative to the beginning of the currently set month.
6505    ///
6506    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setDate)
6507    #[wasm_bindgen(method, js_name = setDate)]
6508    pub fn set_date(this: &Date, day: u32) -> f64;
6509
6510    /// The `setFullYear()` method sets the full year for a specified date according to local time.
6511    /// Returns new timestamp.
6512    ///
6513    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setFullYear)
6514    #[wasm_bindgen(method, js_name = setFullYear)]
6515    pub fn set_full_year(this: &Date, year: u32) -> f64;
6516
6517    /// The `setFullYear()` method sets the full year for a specified date according to local time.
6518    /// Returns new timestamp.
6519    ///
6520    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setFullYear)
6521    #[wasm_bindgen(method, js_name = setFullYear)]
6522    pub fn set_full_year_with_month(this: &Date, year: u32, month: i32) -> f64;
6523
6524    /// The `setFullYear()` method sets the full year for a specified date according to local time.
6525    /// Returns new timestamp.
6526    ///
6527    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setFullYear)
6528    #[wasm_bindgen(method, js_name = setFullYear)]
6529    pub fn set_full_year_with_month_date(this: &Date, year: u32, month: i32, date: i32) -> f64;
6530
6531    /// The `setHours()` method sets the hours for a specified date according to local time,
6532    /// and returns the number of milliseconds since January 1, 1970 00:00:00 UTC until the time represented
6533    /// by the updated Date instance.
6534    ///
6535    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setHours)
6536    #[wasm_bindgen(method, js_name = setHours)]
6537    pub fn set_hours(this: &Date, hours: u32) -> f64;
6538
6539    /// The `setMilliseconds()` method sets the milliseconds for a specified date according to local time.
6540    ///
6541    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setMilliseconds)
6542    #[wasm_bindgen(method, js_name = setMilliseconds)]
6543    pub fn set_milliseconds(this: &Date, milliseconds: u32) -> f64;
6544
6545    /// The `setMinutes()` method sets the minutes for a specified date according to local time.
6546    ///
6547    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setMinutes)
6548    #[wasm_bindgen(method, js_name = setMinutes)]
6549    pub fn set_minutes(this: &Date, minutes: u32) -> f64;
6550
6551    /// The `setMonth()` method sets the month for a specified date according to the currently set year.
6552    ///
6553    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setMonth)
6554    #[wasm_bindgen(method, js_name = setMonth)]
6555    pub fn set_month(this: &Date, month: u32) -> f64;
6556
6557    /// The `setSeconds()` method sets the seconds for a specified date according to local time.
6558    ///
6559    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setSeconds)
6560    #[wasm_bindgen(method, js_name = setSeconds)]
6561    pub fn set_seconds(this: &Date, seconds: u32) -> f64;
6562
6563    /// The `setTime()` method sets the Date object to the time represented by a number of milliseconds
6564    /// since January 1, 1970, 00:00:00 UTC.
6565    ///
6566    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setTime)
6567    #[wasm_bindgen(method, js_name = setTime)]
6568    pub fn set_time(this: &Date, time: f64) -> f64;
6569
6570    /// The `setUTCDate()` method sets the day of the month for a specified date
6571    /// according to universal time.
6572    ///
6573    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCDate)
6574    #[wasm_bindgen(method, js_name = setUTCDate)]
6575    pub fn set_utc_date(this: &Date, day: u32) -> f64;
6576
6577    /// The `setUTCFullYear()` method sets the full year for a specified date according to universal time.
6578    ///
6579    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCFullYear)
6580    #[wasm_bindgen(method, js_name = setUTCFullYear)]
6581    pub fn set_utc_full_year(this: &Date, year: u32) -> f64;
6582
6583    /// The `setUTCFullYear()` method sets the full year for a specified date according to universal time.
6584    ///
6585    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCFullYear)
6586    #[wasm_bindgen(method, js_name = setUTCFullYear)]
6587    pub fn set_utc_full_year_with_month(this: &Date, year: u32, month: i32) -> f64;
6588
6589    /// The `setUTCFullYear()` method sets the full year for a specified date according to universal time.
6590    ///
6591    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCFullYear)
6592    #[wasm_bindgen(method, js_name = setUTCFullYear)]
6593    pub fn set_utc_full_year_with_month_date(this: &Date, year: u32, month: i32, date: i32) -> f64;
6594
6595    /// The `setUTCHours()` method sets the hour for a specified date according to universal time,
6596    /// and returns the number of milliseconds since  January 1, 1970 00:00:00 UTC until the time
6597    /// represented by the updated Date instance.
6598    ///
6599    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCHours)
6600    #[wasm_bindgen(method, js_name = setUTCHours)]
6601    pub fn set_utc_hours(this: &Date, hours: u32) -> f64;
6602
6603    /// The `setUTCMilliseconds()` method sets the milliseconds for a specified date
6604    /// according to universal time.
6605    ///
6606    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCMilliseconds)
6607    #[wasm_bindgen(method, js_name = setUTCMilliseconds)]
6608    pub fn set_utc_milliseconds(this: &Date, milliseconds: u32) -> f64;
6609
6610    /// The `setUTCMinutes()` method sets the minutes for a specified date according to universal time.
6611    ///
6612    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCMinutes)
6613    #[wasm_bindgen(method, js_name = setUTCMinutes)]
6614    pub fn set_utc_minutes(this: &Date, minutes: u32) -> f64;
6615
6616    /// The `setUTCMonth()` method sets the month for a specified date according to universal time.
6617    ///
6618    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCMonth)
6619    #[wasm_bindgen(method, js_name = setUTCMonth)]
6620    pub fn set_utc_month(this: &Date, month: u32) -> f64;
6621
6622    /// The `setUTCSeconds()` method sets the seconds for a specified date according to universal time.
6623    ///
6624    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCSeconds)
6625    #[wasm_bindgen(method, js_name = setUTCSeconds)]
6626    pub fn set_utc_seconds(this: &Date, seconds: u32) -> f64;
6627
6628    /// The `toDateString()` method returns the date portion of a Date object
6629    /// in human readable form in American English.
6630    ///
6631    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toDateString)
6632    #[wasm_bindgen(method, js_name = toDateString)]
6633    pub fn to_date_string(this: &Date) -> JsString;
6634
6635    /// The `toISOString()` method returns a string in simplified extended ISO format (ISO
6636    /// 8601), which is always 24 or 27 characters long (YYYY-MM-DDTHH:mm:ss.sssZ or
6637    /// ±YYYYYY-MM-DDTHH:mm:ss.sssZ, respectively). The timezone is always zero UTC offset,
6638    /// as denoted by the suffix "Z"
6639    ///
6640    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
6641    #[wasm_bindgen(method, js_name = toISOString)]
6642    pub fn to_iso_string(this: &Date) -> JsString;
6643
6644    /// The `toJSON()` method returns a string representation of the Date object.
6645    ///
6646    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toJSON)
6647    #[wasm_bindgen(method, js_name = toJSON)]
6648    pub fn to_json(this: &Date) -> JsString;
6649
6650    /// The `toLocaleDateString()` method returns a string with a language sensitive
6651    /// representation of the date portion of this date. The new locales and options
6652    /// arguments let applications specify the language whose formatting conventions
6653    /// should be used and allow to customize the behavior of the function.
6654    /// In older implementations, which ignore the locales and options arguments,
6655    /// the locale used and the form of the string
6656    /// returned are entirely implementation dependent.
6657    ///
6658    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString)
6659    #[cfg(not(js_sys_unstable_apis))]
6660    #[wasm_bindgen(method, js_name = toLocaleDateString)]
6661    pub fn to_locale_date_string(this: &Date, locale: &str, options: &JsValue) -> JsString;
6662
6663    /// The `toLocaleDateString()` method returns a string with a language sensitive
6664    /// representation of the date portion of this date.
6665    ///
6666    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString)
6667    #[cfg(js_sys_unstable_apis)]
6668    #[wasm_bindgen(method, js_name = toLocaleDateString)]
6669    pub fn to_locale_date_string(
6670        this: &Date,
6671        locales: &[JsString],
6672        options: &Intl::DateTimeFormatOptions,
6673    ) -> JsString;
6674
6675    /// The `toLocaleString()` method returns a string with a language sensitive
6676    /// representation of this date. The new locales and options arguments
6677    /// let applications specify the language whose formatting conventions
6678    /// should be used and customize the behavior of the function.
6679    /// In older implementations, which ignore the locales
6680    /// and options arguments, the locale used and the form of the string
6681    /// returned are entirely implementation dependent.
6682    ///
6683    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString)
6684    #[cfg(not(js_sys_unstable_apis))]
6685    #[wasm_bindgen(method, js_name = toLocaleString)]
6686    pub fn to_locale_string(this: &Date, locale: &str, options: &JsValue) -> JsString;
6687
6688    /// The `toLocaleString()` method returns a string with a language sensitive
6689    /// representation of this date.
6690    ///
6691    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString)
6692    #[cfg(js_sys_unstable_apis)]
6693    #[wasm_bindgen(method, js_name = toLocaleString)]
6694    pub fn to_locale_string(
6695        this: &Date,
6696        locales: &[JsString],
6697        options: &Intl::DateTimeFormatOptions,
6698    ) -> JsString;
6699
6700    /// The `toLocaleTimeString()` method returns a string with a language sensitive
6701    /// representation of the time portion of this date. The new locales and options
6702    /// arguments let applications specify the language whose formatting conventions should be
6703    /// used and customize the behavior of the function. In older implementations, which ignore
6704    /// the locales and options arguments, the locale used and the form of the string
6705    /// returned are entirely implementation dependent.
6706    ///
6707    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleTimeString)
6708    #[cfg(not(js_sys_unstable_apis))]
6709    #[wasm_bindgen(method, js_name = toLocaleTimeString)]
6710    pub fn to_locale_time_string(this: &Date, locale: &str) -> JsString;
6711
6712    /// The `toLocaleTimeString()` method returns a string with a language sensitive
6713    /// representation of the time portion of this date.
6714    ///
6715    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleTimeString)
6716    #[cfg(js_sys_unstable_apis)]
6717    #[wasm_bindgen(method, js_name = toLocaleTimeString)]
6718    pub fn to_locale_time_string(
6719        this: &Date,
6720        locales: &[JsString],
6721        options: &Intl::DateTimeFormatOptions,
6722    ) -> JsString;
6723
6724    #[cfg(not(js_sys_unstable_apis))]
6725    #[wasm_bindgen(method, js_name = toLocaleTimeString)]
6726    pub fn to_locale_time_string_with_options(
6727        this: &Date,
6728        locale: &str,
6729        options: &JsValue,
6730    ) -> JsString;
6731
6732    /// The `toString()` method returns a string representing
6733    /// the specified Date object.
6734    ///
6735    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toString)
6736    #[cfg(not(js_sys_unstable_apis))]
6737    #[wasm_bindgen(method, js_name = toString)]
6738    pub fn to_string(this: &Date) -> JsString;
6739
6740    /// The `toTimeString()` method returns the time portion of a Date object in human
6741    /// readable form in American English.
6742    ///
6743    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toTimeString)
6744    #[wasm_bindgen(method, js_name = toTimeString)]
6745    pub fn to_time_string(this: &Date) -> JsString;
6746
6747    /// The `toUTCString()` method converts a date to a string,
6748    /// using the UTC time zone.
6749    ///
6750    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toUTCString)
6751    #[wasm_bindgen(method, js_name = toUTCString)]
6752    pub fn to_utc_string(this: &Date) -> JsString;
6753
6754    /// The `Date.UTC()` method accepts the same parameters as the
6755    /// longest form of the constructor, and returns the number of
6756    /// milliseconds in a `Date` object since January 1, 1970,
6757    /// 00:00:00, universal time.
6758    ///
6759    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/UTC)
6760    #[wasm_bindgen(static_method_of = Date, js_name = UTC)]
6761    pub fn utc(year: f64, month: f64) -> f64;
6762
6763    /// The `valueOf()` method  returns the primitive value of
6764    /// a Date object.
6765    ///
6766    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/valueOf)
6767    #[wasm_bindgen(method, js_name = valueOf)]
6768    pub fn value_of(this: &Date) -> f64;
6769
6770    /// The `toTemporalInstant()` method converts a legacy `Date` object to a
6771    /// `Temporal.Instant` object representing the same moment in time.
6772    ///
6773    /// This method is added by the Temporal proposal to facilitate migration
6774    /// from legacy `Date` to the new Temporal API.
6775    ///
6776    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toTemporalInstant)
6777    #[cfg(js_sys_unstable_apis)]
6778    #[wasm_bindgen(method, js_name = toTemporalInstant)]
6779    pub fn to_temporal_instant(this: &Date) -> Temporal::Instant;
6780}
6781
6782// Property Descriptor.
6783#[wasm_bindgen]
6784extern "C" {
6785    #[wasm_bindgen(extends = Object)]
6786    #[derive(Clone, Debug)]
6787    pub type PropertyDescriptor<T = JsValue>;
6788
6789    #[wasm_bindgen(method, getter = writable)]
6790    pub fn get_writable<T>(this: &PropertyDescriptor<T>) -> Option<bool>;
6791
6792    #[wasm_bindgen(method, setter = writable)]
6793    pub fn set_writable<T>(this: &PropertyDescriptor<T>, writable: bool);
6794
6795    #[wasm_bindgen(method, getter = enumerable)]
6796    pub fn get_enumerable<T>(this: &PropertyDescriptor<T>) -> Option<bool>;
6797
6798    #[wasm_bindgen(method, setter = enumerable)]
6799    pub fn set_enumerable<T>(this: &PropertyDescriptor<T>, enumerable: bool);
6800
6801    #[wasm_bindgen(method, getter = configurable)]
6802    pub fn get_configurable<T>(this: &PropertyDescriptor<T>) -> Option<bool>;
6803
6804    #[wasm_bindgen(method, setter = configurable)]
6805    pub fn set_configurable<T>(this: &PropertyDescriptor<T>, configurable: bool);
6806
6807    #[wasm_bindgen(method, getter = get)]
6808    pub fn get_get<T: JsGeneric>(this: &PropertyDescriptor<T>) -> Option<Function<fn() -> T>>;
6809
6810    #[wasm_bindgen(method, setter = get)]
6811    pub fn set_get<T: JsGeneric>(this: &PropertyDescriptor<T>, get: Function<fn() -> T>);
6812
6813    #[wasm_bindgen(method, getter = set)]
6814    pub fn get_set<T: JsGeneric>(
6815        this: &PropertyDescriptor<T>,
6816    ) -> Option<Function<fn(T) -> JsValue>>;
6817
6818    #[wasm_bindgen(method, setter = set)]
6819    pub fn set_set<T: JsGeneric>(this: &PropertyDescriptor<T>, set: Function<fn(T) -> JsValue>);
6820
6821    #[wasm_bindgen(method, getter = value)]
6822    pub fn get_value<T>(this: &PropertyDescriptor<T>) -> Option<T>;
6823
6824    #[wasm_bindgen(method, setter = value)]
6825    pub fn set_value<T>(this: &PropertyDescriptor<T>, value: &T);
6826}
6827
6828impl PropertyDescriptor {
6829    #[cfg(not(js_sys_unstable_apis))]
6830    pub fn new<T>() -> PropertyDescriptor<T> {
6831        JsCast::unchecked_into(Object::new())
6832    }
6833
6834    #[cfg(js_sys_unstable_apis)]
6835    pub fn new<T>() -> PropertyDescriptor<T> {
6836        JsCast::unchecked_into(Object::<JsValue>::new())
6837    }
6838
6839    #[cfg(not(js_sys_unstable_apis))]
6840    pub fn new_value<T: JsGeneric>(value: &T) -> PropertyDescriptor<T> {
6841        let desc: PropertyDescriptor<T> = JsCast::unchecked_into(Object::new());
6842        desc.set_value(value);
6843        desc
6844    }
6845
6846    #[cfg(js_sys_unstable_apis)]
6847    pub fn new_value<T: JsGeneric>(value: &T) -> PropertyDescriptor<T> {
6848        let desc: PropertyDescriptor<T> = JsCast::unchecked_into(Object::<JsValue>::new());
6849        desc.set_value(value);
6850        desc
6851    }
6852}
6853
6854impl Default for PropertyDescriptor {
6855    fn default() -> Self {
6856        PropertyDescriptor::new()
6857    }
6858}
6859
6860// Object.
6861#[wasm_bindgen]
6862extern "C" {
6863    #[wasm_bindgen(typescript_type = "object")]
6864    #[derive(Clone, Debug)]
6865    pub type Object<T = JsValue>;
6866
6867    // Next major: deprecate
6868    /// The `Object.assign()` method is used to copy the values of all enumerable
6869    /// own properties from one or more source objects to a target object. It
6870    /// will return the target object.
6871    ///
6872    /// **Note:** Consider using [`Object::try_assign`] to support error handling.
6873    ///
6874    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign)
6875    #[wasm_bindgen(static_method_of = Object)]
6876    pub fn assign<T>(target: &Object<T>, source: &Object<T>) -> Object<T>;
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, js_name = assign, catch)]
6887    pub fn try_assign<T>(target: &Object<T>, source: &Object<T>) -> Result<Object<T>, JsValue>;
6888
6889    /// The `Object.assign()` method is used to copy the values of all enumerable
6890    /// own properties from one or more source objects to a target object. It
6891    /// will return the target object.
6892    ///
6893    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign)
6894    #[cfg(not(js_sys_unstable_apis))]
6895    #[wasm_bindgen(static_method_of = Object, js_name = assign)]
6896    #[deprecated(note = "use `assign_many` for arbitrary assign arguments instead")]
6897    #[allow(deprecated)]
6898    pub fn assign2<T>(target: &Object<T>, source1: &Object<T>, source2: &Object<T>) -> Object<T>;
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 assign3<T>(
6910        target: &Object<T>,
6911        source1: &Object<T>,
6912        source2: &Object<T>,
6913        source3: &Object<T>,
6914    ) -> Object<T>;
6915
6916    /// The `Object.assign()` method is used to copy the values of all enumerable
6917    /// own properties from one or more source objects to a target object. It
6918    /// will return the target object.
6919    ///
6920    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign)
6921    #[wasm_bindgen(static_method_of = Object, js_name = assign, catch, variadic)]
6922    pub fn assign_many<T>(target: &Object<T>, sources: &[Object<T>]) -> Result<Object<T>, JsValue>;
6923
6924    /// The constructor property returns a reference to the `Object` constructor
6925    /// function that created the instance object.
6926    ///
6927    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/constructor)
6928    #[wasm_bindgen(method, getter)]
6929    pub fn constructor<T>(this: &Object<T>) -> Function;
6930
6931    /// The `Object.create()` method creates a new object, using an existing
6932    /// object to provide the newly created object's prototype.
6933    ///
6934    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create)
6935    #[wasm_bindgen(static_method_of = Object)]
6936    pub fn create<T>(prototype: &Object<T>) -> Object<T>;
6937
6938    /// The static method `Object.defineProperty()` defines a new
6939    /// property directly on an object, or modifies an existing
6940    /// property on an object, and returns the object.
6941    ///
6942    /// **Note:** Consider using [`Object::define_property_str`] to support typing and error handling.
6943    ///
6944    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty)
6945    #[cfg(not(js_sys_unstable_apis))]
6946    #[wasm_bindgen(static_method_of = Object, js_name = defineProperty)]
6947    pub fn define_property<T>(obj: &Object<T>, prop: &JsValue, descriptor: &Object) -> 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    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty)
6954    #[cfg(js_sys_unstable_apis)]
6955    #[wasm_bindgen(static_method_of = Object, js_name = defineProperty, catch)]
6956    pub fn define_property<T>(
6957        obj: &Object<T>,
6958        prop: &JsString,
6959        descriptor: &PropertyDescriptor<T>,
6960    ) -> Result<Object<T>, JsValue>;
6961
6962    // Next major: deprecate
6963    /// The static method `Object.defineProperty()` defines a new
6964    /// property directly on an object, or modifies an existing
6965    /// property on an object, and returns the object.
6966    ///
6967    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty)
6968    #[wasm_bindgen(static_method_of = Object, js_name = defineProperty, catch)]
6969    pub fn define_property_str<T>(
6970        obj: &Object<T>,
6971        prop: &JsString,
6972        descriptor: &PropertyDescriptor<T>,
6973    ) -> Result<Object<T>, JsValue>;
6974
6975    /// The static method `Object.defineProperty()` defines a new
6976    /// property directly on an object, or modifies an existing
6977    /// property on an object, and returns the object.
6978    ///
6979    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty)
6980    #[wasm_bindgen(static_method_of = Object, js_name = defineProperty, catch)]
6981    pub fn define_property_symbol<T>(
6982        obj: &Object<T>,
6983        prop: &Symbol,
6984        descriptor: &PropertyDescriptor<JsValue>,
6985    ) -> Result<Object<T>, JsValue>;
6986
6987    /// The `Object.defineProperties()` method defines new or modifies
6988    /// existing properties directly on an object, returning the
6989    /// object.
6990    ///
6991    /// **Note:** Consider using [`Object::try_define_properties`] to support typing and error handling.
6992    ///
6993    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperties)
6994    #[wasm_bindgen(static_method_of = Object, js_name = defineProperties)]
6995    pub fn define_properties<T>(obj: &Object<T>, props: &Object) -> Object<T>;
6996
6997    /// The `Object.defineProperties()` method defines new or modifies
6998    /// existing properties directly on an object, returning the
6999    /// object.
7000    ///
7001    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperties)
7002    #[cfg(js_sys_unstable_apis)]
7003    #[wasm_bindgen(static_method_of = Object, js_name = defineProperties, catch)]
7004    pub fn try_define_properties<T>(
7005        obj: &Object<T>,
7006        props: &Object<PropertyDescriptor<T>>,
7007    ) -> Result<Object<T>, JsValue>;
7008
7009    /// The `Object.entries()` method returns an array of a given
7010    /// object's own enumerable property [key, value] pairs, in the
7011    /// same order as that provided by a for...in loop (the difference
7012    /// being that a for-in loop enumerates properties in the
7013    /// prototype chain as well).
7014    ///
7015    /// **Note:** Consider using [`Object::entries_typed`] to support typing and error handling.
7016    ///
7017    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries)
7018    #[cfg(not(js_sys_unstable_apis))]
7019    #[wasm_bindgen(static_method_of = Object)]
7020    pub fn entries(object: &Object) -> Array;
7021
7022    /// The `Object.entries()` method returns an array of a given
7023    /// object's own enumerable property [key, value] pairs, in the
7024    /// same order as that provided by a for...in loop (the difference
7025    /// being that a for-in loop enumerates properties in the
7026    /// prototype chain as well).
7027    ///
7028    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries)
7029    #[cfg(js_sys_unstable_apis)]
7030    #[wasm_bindgen(static_method_of = Object, js_name = entries, catch)]
7031    pub fn entries<T: JsGeneric>(
7032        object: &Object<T>,
7033    ) -> Result<Array<ArrayTuple<(JsString, T)>>, JsValue>;
7034
7035    // Next major: deprecate
7036    /// The `Object.entries()` method returns an array of a given
7037    /// object's own enumerable property [key, value] pairs, in the
7038    /// same order as that provided by a for...in loop (the difference
7039    /// being that a for-in loop enumerates properties in the
7040    /// prototype chain as well).
7041    ///
7042    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries)
7043    #[wasm_bindgen(static_method_of = Object, js_name = entries, catch)]
7044    pub fn entries_typed<T: JsGeneric>(
7045        object: &Object<T>,
7046    ) -> Result<Array<ArrayTuple<(JsString, T)>>, JsValue>;
7047
7048    /// The `Object.freeze()` method freezes an object: that is, prevents new
7049    /// properties from being added to it; prevents existing properties from
7050    /// being removed; and prevents existing properties, or their enumerability,
7051    /// configurability, or writability, from being changed, it also prevents
7052    /// the prototype from being changed. The method returns the passed object.
7053    ///
7054    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze)
7055    #[wasm_bindgen(static_method_of = Object)]
7056    pub fn freeze<T>(value: &Object<T>) -> Object<T>;
7057
7058    /// The `Object.fromEntries()` method transforms a list of key-value pairs
7059    /// into an object.
7060    ///
7061    /// **Note:** Consider using [`Object::from_entries_typed`] to support typing and error handling.
7062    ///
7063    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/fromEntries)
7064    #[cfg(not(js_sys_unstable_apis))]
7065    #[wasm_bindgen(static_method_of = Object, catch, js_name = fromEntries)]
7066    pub fn from_entries(entries: &JsValue) -> Result<Object, JsValue>;
7067
7068    /// The `Object.fromEntries()` method transforms a list of key-value pairs
7069    /// into an object.
7070    ///
7071    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/fromEntries)
7072    #[cfg(js_sys_unstable_apis)]
7073    #[wasm_bindgen(static_method_of = Object, catch, js_name = fromEntries)]
7074    pub fn from_entries<T: JsGeneric, I: Iterable<Item = ArrayTuple<(JsString, T)>>>(
7075        entries: &I,
7076    ) -> Result<Object<T>, JsValue>;
7077
7078    // Next major: deprecate
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    #[wasm_bindgen(static_method_of = Object, catch, js_name = fromEntries)]
7084    pub fn from_entries_typed<T: JsGeneric, I: Iterable<Item = ArrayTuple<(JsString, T)>>>(
7085        entries: &I,
7086    ) -> Result<Object<T>, JsValue>;
7087
7088    /// The `Object.getOwnPropertyDescriptor()` method returns a
7089    /// property descriptor for an own property (that is, one directly
7090    /// present on an object and not in the object's prototype chain)
7091    /// of a given object.
7092    ///
7093    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor)
7094    #[cfg(not(js_sys_unstable_apis))]
7095    #[wasm_bindgen(static_method_of = Object, js_name = getOwnPropertyDescriptor)]
7096    pub fn get_own_property_descriptor<T>(obj: &Object<T>, prop: &JsValue) -> JsValue;
7097
7098    /// The `Object.getOwnPropertyDescriptor()` method returns a
7099    /// property descriptor for an own property (that is, one directly
7100    /// present on an object and not in the object's prototype chain)
7101    /// of a given object.
7102    ///
7103    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor)
7104    #[cfg(js_sys_unstable_apis)]
7105    #[wasm_bindgen(static_method_of = Object, js_name = getOwnPropertyDescriptor, catch)]
7106    pub fn get_own_property_descriptor<T>(
7107        obj: &Object<T>,
7108        prop: &JsString,
7109    ) -> Result<PropertyDescriptor<T>, JsValue>;
7110
7111    // Next major: deprecate
7112    /// The `Object.getOwnPropertyDescriptor()` method returns a
7113    /// property descriptor for an own property (that is, one directly
7114    /// present on an object and not in the object's prototype chain)
7115    /// of a given object.
7116    ///
7117    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor)
7118    #[wasm_bindgen(static_method_of = Object, js_name = getOwnPropertyDescriptor, catch)]
7119    pub fn get_own_property_descriptor_str<T>(
7120        obj: &Object<T>,
7121        prop: &JsString,
7122    ) -> Result<PropertyDescriptor<T>, JsValue>;
7123
7124    /// The `Object.getOwnPropertyDescriptor()` method returns a
7125    /// property descriptor for an own property (that is, one directly
7126    /// present on an object and not in the object's prototype chain)
7127    /// of a given object.
7128    ///
7129    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor)
7130    #[wasm_bindgen(static_method_of = Object, js_name = getOwnPropertyDescriptor, catch)]
7131    pub fn get_own_property_descriptor_symbol<T>(
7132        obj: &Object<T>,
7133        prop: &Symbol,
7134    ) -> Result<PropertyDescriptor<JsValue>, JsValue>;
7135
7136    /// The `Object.getOwnPropertyDescriptors()` method returns all own
7137    /// property descriptors of a given object.
7138    ///
7139    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptors)
7140    #[cfg(not(js_sys_unstable_apis))]
7141    #[wasm_bindgen(static_method_of = Object, js_name = getOwnPropertyDescriptors)]
7142    pub fn get_own_property_descriptors<T>(obj: &Object<T>) -> JsValue;
7143
7144    /// The `Object.getOwnPropertyDescriptors()` method returns all own
7145    /// property descriptors of a given object.
7146    ///
7147    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptors)
7148    #[cfg(js_sys_unstable_apis)]
7149    #[wasm_bindgen(static_method_of = Object, js_name = getOwnPropertyDescriptors, catch)]
7150    pub fn get_own_property_descriptors<T>(
7151        obj: &Object<T>,
7152    ) -> Result<Object<PropertyDescriptor<T>>, JsValue>;
7153
7154    /// The `Object.getOwnPropertyNames()` method returns an array of
7155    /// all properties (including non-enumerable properties except for
7156    /// those which use Symbol) found directly upon a given object.
7157    ///
7158    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames)
7159    #[cfg(not(js_sys_unstable_apis))]
7160    #[wasm_bindgen(static_method_of = Object, js_name = getOwnPropertyNames)]
7161    pub fn get_own_property_names<T>(obj: &Object<T>) -> Array;
7162
7163    /// The `Object.getOwnPropertyNames()` method returns an array of
7164    /// all properties (including non-enumerable properties except for
7165    /// those which use Symbol) found directly upon a given object.
7166    ///
7167    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames)
7168    #[cfg(js_sys_unstable_apis)]
7169    #[wasm_bindgen(static_method_of = Object, js_name = getOwnPropertyNames, catch)]
7170    pub fn get_own_property_names<T>(obj: &Object<T>) -> Result<Array<JsString>, JsValue>;
7171
7172    /// The `Object.getOwnPropertySymbols()` method returns an array of
7173    /// all symbol properties found directly upon a given object.
7174    ///
7175    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertySymbols)
7176    #[cfg(not(js_sys_unstable_apis))]
7177    #[wasm_bindgen(static_method_of = Object, js_name = getOwnPropertySymbols)]
7178    pub fn get_own_property_symbols<T>(obj: &Object<T>) -> Array;
7179
7180    /// The `Object.getOwnPropertySymbols()` method returns an array of
7181    /// all symbol properties found directly upon a given object.
7182    ///
7183    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertySymbols)
7184    #[cfg(js_sys_unstable_apis)]
7185    #[wasm_bindgen(static_method_of = Object, js_name = getOwnPropertySymbols, catch)]
7186    pub fn get_own_property_symbols<T>(obj: &Object<T>) -> Result<Array<Symbol>, JsValue>;
7187
7188    /// The `Object.getPrototypeOf()` method returns the prototype
7189    /// (i.e. the value of the internal [[Prototype]] property) of the
7190    /// specified object.
7191    ///
7192    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getPrototypeOf)
7193    #[wasm_bindgen(static_method_of = Object, js_name = getPrototypeOf)]
7194    pub fn get_prototype_of(obj: &JsValue) -> Object;
7195
7196    /// The `hasOwnProperty()` method returns a boolean indicating whether the
7197    /// object has the specified property as its own property (as opposed to
7198    /// inheriting it).
7199    ///
7200    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty)
7201    #[deprecated(note = "Use `Object::hasOwn` instead.")]
7202    #[allow(deprecated)]
7203    #[wasm_bindgen(method, js_name = hasOwnProperty)]
7204    pub fn has_own_property<T>(this: &Object<T>, property: &JsValue) -> bool;
7205
7206    /// The `Object.hasOwn()` method returns a boolean indicating whether the
7207    /// object passed in has the specified property as its own property (as
7208    /// opposed to inheriting it).
7209    ///
7210    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwn)
7211    #[cfg(not(js_sys_unstable_apis))]
7212    #[wasm_bindgen(static_method_of = Object, js_name = hasOwn)]
7213    pub fn has_own<T>(instance: &Object<T>, property: &JsValue) -> bool;
7214
7215    /// The `Object.hasOwn()` method returns a boolean indicating whether the
7216    /// object passed in has the specified property as its own property (as
7217    /// opposed to inheriting it).
7218    ///
7219    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwn)
7220    #[cfg(js_sys_unstable_apis)]
7221    #[wasm_bindgen(static_method_of = Object, js_name = hasOwn, catch)]
7222    pub fn has_own<T>(instance: &Object<T>, property: &JsString) -> Result<bool, JsValue>;
7223
7224    // Next major: deprecate
7225    /// The `Object.hasOwn()` method returns a boolean indicating whether the
7226    /// object passed in has the specified property as its own property (as
7227    /// opposed to inheriting it).
7228    ///
7229    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwn)
7230    #[wasm_bindgen(static_method_of = Object, js_name = hasOwn, catch)]
7231    pub fn has_own_str<T>(instance: &Object<T>, property: &JsString) -> Result<bool, JsValue>;
7232
7233    /// The `Object.hasOwn()` method returns a boolean indicating whether the
7234    /// object passed in has the specified property as its own property (as
7235    /// opposed to inheriting it).
7236    ///
7237    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwn)
7238    #[wasm_bindgen(static_method_of = Object, js_name = hasOwn, catch)]
7239    pub fn has_own_symbol<T>(instance: &Object<T>, property: &Symbol) -> Result<bool, JsValue>;
7240
7241    /// The `Object.is()` method determines whether two values are the same value.
7242    ///
7243    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is)
7244    #[wasm_bindgen(static_method_of = Object)]
7245    pub fn is(value1: &JsValue, value_2: &JsValue) -> bool;
7246
7247    /// The `Object.isExtensible()` method determines if an object is extensible
7248    /// (whether it can have new properties added to it).
7249    ///
7250    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isExtensible)
7251    #[wasm_bindgen(static_method_of = Object, js_name = isExtensible)]
7252    pub fn is_extensible<T>(object: &Object<T>) -> bool;
7253
7254    /// The `Object.isFrozen()` determines if an object is frozen.
7255    ///
7256    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isFrozen)
7257    #[wasm_bindgen(static_method_of = Object, js_name = isFrozen)]
7258    pub fn is_frozen<T>(object: &Object<T>) -> bool;
7259
7260    /// The `Object.isSealed()` method determines if an object is sealed.
7261    ///
7262    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isSealed)
7263    #[wasm_bindgen(static_method_of = Object, js_name = isSealed)]
7264    pub fn is_sealed<T>(object: &Object<T>) -> bool;
7265
7266    /// The `isPrototypeOf()` method checks if an object exists in another
7267    /// object's prototype chain.
7268    ///
7269    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isPrototypeOf)
7270    #[wasm_bindgen(method, js_name = isPrototypeOf)]
7271    pub fn is_prototype_of<T>(this: &Object<T>, value: &JsValue) -> bool;
7272
7273    /// The `Object.keys()` method returns an array of a given object's property
7274    /// names, in the same order as we get with a normal loop.
7275    ///
7276    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys)
7277    #[cfg(not(js_sys_unstable_apis))]
7278    #[wasm_bindgen(static_method_of = Object)]
7279    pub fn keys<T>(object: &Object<T>) -> Array;
7280
7281    /// The `Object.keys()` method returns an array of a given object's property
7282    /// names, in the same order as we get with a normal loop.
7283    ///
7284    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys)
7285    #[cfg(js_sys_unstable_apis)]
7286    #[wasm_bindgen(static_method_of = Object)]
7287    pub fn keys<T>(object: &Object<T>) -> Array<JsString>;
7288
7289    /// The [`Object`] constructor creates an object wrapper.
7290    ///
7291    /// **Note:** Consider using [`Object::new_typed`] for typed object records.
7292    ///
7293    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)
7294    #[wasm_bindgen(constructor)]
7295    pub fn new() -> Object;
7296
7297    // Next major: deprecate
7298    /// The [`Object`] constructor creates an object wrapper.
7299    ///
7300    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)
7301    #[wasm_bindgen(constructor)]
7302    pub fn new_typed<T>() -> Object<T>;
7303
7304    /// The `Object.preventExtensions()` method prevents new properties from
7305    /// ever being added to an object (i.e. prevents future extensions to the
7306    /// object).
7307    ///
7308    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/preventExtensions)
7309    #[wasm_bindgen(static_method_of = Object, js_name = preventExtensions)]
7310    pub fn prevent_extensions<T>(object: &Object<T>);
7311
7312    /// The `propertyIsEnumerable()` method returns a Boolean indicating
7313    /// whether the specified property is enumerable.
7314    ///
7315    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/propertyIsEnumerable)
7316    #[wasm_bindgen(method, js_name = propertyIsEnumerable)]
7317    pub fn property_is_enumerable<T>(this: &Object<T>, property: &JsValue) -> bool;
7318
7319    /// The `Object.seal()` method seals an object, preventing new properties
7320    /// from being added to it and marking all existing properties as
7321    /// non-configurable.  Values of present properties can still be changed as
7322    /// long as they are writable.
7323    ///
7324    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/seal)
7325    #[wasm_bindgen(static_method_of = Object)]
7326    pub fn seal<T>(value: &Object<T>) -> Object<T>;
7327
7328    /// The `Object.setPrototypeOf()` method sets the prototype (i.e., the
7329    /// internal `[[Prototype]]` property) of a specified object to another
7330    /// object or `null`.
7331    ///
7332    /// **Note:** Consider using [`Object::try_set_prototype_of`] to support errors.
7333    ///
7334    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/setPrototypeOf)
7335    #[wasm_bindgen(static_method_of = Object, js_name = setPrototypeOf)]
7336    pub fn set_prototype_of<T>(object: &Object<T>, prototype: &Object) -> Object<T>;
7337
7338    /// The `Object.setPrototypeOf()` method sets the prototype (i.e., the
7339    /// internal `[[Prototype]]` property) of a specified object to another
7340    /// object or `null`.
7341    ///
7342    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/setPrototypeOf)
7343    #[wasm_bindgen(static_method_of = Object, js_name = setPrototypeOf, catch)]
7344    pub fn try_set_prototype_of<T>(
7345        object: &Object<T>,
7346        prototype: &Object,
7347    ) -> Result<Object<T>, JsValue>;
7348
7349    /// The `toLocaleString()` method returns a string representing the object.
7350    /// This method is meant to be overridden by derived objects for
7351    /// locale-specific purposes.
7352    ///
7353    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toLocaleString)
7354    #[wasm_bindgen(method, js_name = toLocaleString)]
7355    pub fn to_locale_string<T>(this: &Object<T>) -> JsString;
7356
7357    // Next major: deprecate
7358    /// The `toString()` method returns a string representing the object.
7359    ///
7360    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString)
7361    #[wasm_bindgen(method, js_name = toString)]
7362    pub fn to_string<T>(this: &Object<T>) -> JsString;
7363
7364    /// The `toString()` method returns a string representing the object.
7365    ///
7366    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString)
7367    #[wasm_bindgen(method, js_name = toString)]
7368    pub fn to_js_string<T>(this: &Object<T>) -> JsString;
7369
7370    /// The `valueOf()` method returns the primitive value of the
7371    /// specified object.
7372    ///
7373    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/valueOf)
7374    #[wasm_bindgen(method, js_name = valueOf)]
7375    pub fn value_of<T>(this: &Object<T>) -> Object;
7376
7377    /// The `Object.values()` method returns an array of a given object's own
7378    /// enumerable property values, in the same order as that provided by a
7379    /// `for...in` loop (the difference being that a for-in loop enumerates
7380    /// properties in the prototype chain as well).
7381    ///
7382    /// **Note:** Consider using [`Object::try_values`] to support errors.
7383    ///
7384    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/values)
7385    #[cfg(not(js_sys_unstable_apis))]
7386    #[wasm_bindgen(static_method_of = Object)]
7387    pub fn values<T>(object: &Object<T>) -> Array<T>;
7388
7389    /// The `Object.values()` method returns an array of a given object's own
7390    /// enumerable property values, in the same order as that provided by a
7391    /// `for...in` loop (the difference being that a for-in loop enumerates
7392    /// properties in the prototype chain as well).
7393    ///
7394    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/values)
7395    #[cfg(js_sys_unstable_apis)]
7396    #[wasm_bindgen(static_method_of = Object, catch, js_name = values)]
7397    pub fn values<T>(object: &Object<T>) -> Result<Array<T>, JsValue>;
7398
7399    // Next major: deprecate
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(not(js_sys_unstable_apis))]
7407    #[wasm_bindgen(static_method_of = Object, catch, js_name = values)]
7408    pub fn try_values<T>(object: &Object<T>) -> Result<Array<T>, JsValue>;
7409}
7410
7411impl Object {
7412    /// Returns the `Object` value of this JS value if it's an instance of an
7413    /// object.
7414    ///
7415    /// If this JS value is not an instance of an object then this returns
7416    /// `None`.
7417    pub fn try_from(val: &JsValue) -> Option<&Object> {
7418        if val.is_object() {
7419            Some(val.unchecked_ref())
7420        } else {
7421            None
7422        }
7423    }
7424}
7425
7426impl PartialEq for Object {
7427    #[inline]
7428    fn eq(&self, other: &Object) -> bool {
7429        Object::is(self.as_ref(), other.as_ref())
7430    }
7431}
7432
7433impl Eq for Object {}
7434
7435impl Default for Object<JsValue> {
7436    fn default() -> Self {
7437        Self::new()
7438    }
7439}
7440
7441// Proxy
7442#[wasm_bindgen]
7443extern "C" {
7444    #[wasm_bindgen(typescript_type = "ProxyConstructor")]
7445    #[derive(Clone, Debug)]
7446    pub type Proxy;
7447
7448    /// The [`Proxy`] object is used to define custom behavior for fundamental
7449    /// operations (e.g. property lookup, assignment, enumeration, function
7450    /// invocation, etc).
7451    ///
7452    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy)
7453    #[wasm_bindgen(constructor)]
7454    pub fn new(target: &JsValue, handler: &Object) -> Proxy;
7455
7456    /// The `Proxy.revocable()` method is used to create a revocable [`Proxy`]
7457    /// object.
7458    ///
7459    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/revocable)
7460    #[wasm_bindgen(static_method_of = Proxy)]
7461    pub fn revocable(target: &JsValue, handler: &Object) -> Object;
7462}
7463
7464// RangeError
7465#[wasm_bindgen]
7466extern "C" {
7467    /// The `RangeError` object indicates an error when a value is not in the set
7468    /// or range of allowed values.
7469    ///
7470    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError)
7471    #[wasm_bindgen(extends = Error, extends = Object, typescript_type = "RangeError")]
7472    #[derive(Clone, Debug, PartialEq, Eq)]
7473    pub type RangeError;
7474
7475    /// The `RangeError` object indicates an error when a value is not in the set
7476    /// or range of allowed values.
7477    ///
7478    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError)
7479    #[wasm_bindgen(constructor)]
7480    pub fn new(message: &str) -> RangeError;
7481
7482    /// Creates a new `RangeError` with the given message and a typed
7483    /// [`ErrorOptions`] dictionary whose `cause` property indicates the
7484    /// original cause of the error.
7485    ///
7486    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError/RangeError)
7487    #[wasm_bindgen(constructor)]
7488    pub fn new_with_options(message: &str, options: &ErrorOptions) -> RangeError;
7489}
7490
7491// ReferenceError
7492#[wasm_bindgen]
7493extern "C" {
7494    /// The `ReferenceError` object represents an error when a non-existent
7495    /// variable is referenced.
7496    ///
7497    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError)
7498    #[wasm_bindgen(extends = Error, extends = Object, typescript_type = "ReferenceError")]
7499    #[derive(Clone, Debug, PartialEq, Eq)]
7500    pub type ReferenceError;
7501
7502    /// The `ReferenceError` object represents an error when a non-existent
7503    /// variable is referenced.
7504    ///
7505    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError)
7506    #[wasm_bindgen(constructor)]
7507    pub fn new(message: &str) -> ReferenceError;
7508
7509    /// Creates a new `ReferenceError` with the given message and a typed
7510    /// [`ErrorOptions`] dictionary whose `cause` property indicates the
7511    /// original cause of the error.
7512    ///
7513    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError/ReferenceError)
7514    #[wasm_bindgen(constructor)]
7515    pub fn new_with_options(message: &str, options: &ErrorOptions) -> ReferenceError;
7516}
7517
7518#[allow(non_snake_case)]
7519pub mod Reflect {
7520    use super::*;
7521
7522    // Reflect
7523    #[wasm_bindgen]
7524    extern "C" {
7525        /// The static `Reflect.apply()` method calls a target function with
7526        /// arguments as specified.
7527        ///
7528        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/apply)
7529        #[wasm_bindgen(js_namespace = Reflect, catch)]
7530        pub fn apply<T: JsFunction = fn() -> JsValue>(
7531            target: &Function<T>,
7532            this_argument: &JsValue,
7533            arguments_list: &Array,
7534        ) -> Result<<T as JsFunction>::Ret, JsValue>;
7535
7536        /// The static `Reflect.construct()` method acts like the new operator, but
7537        /// as a function.  It is equivalent to calling `new target(...args)`. It
7538        /// gives also the added option to specify a different prototype.
7539        ///
7540        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/construct)
7541        #[cfg(not(js_sys_unstable_apis))]
7542        #[wasm_bindgen(js_namespace = Reflect, catch)]
7543        pub fn construct<T: JsFunction = fn() -> JsValue>(
7544            target: &Function<T>,
7545            arguments_list: &Array,
7546        ) -> Result<JsValue, JsValue>;
7547
7548        /// The static `Reflect.construct()` method acts like the new operator, but
7549        /// as a function.  It is equivalent to calling `new target(...args)`. It
7550        /// gives also the added option to specify a different prototype.
7551        ///
7552        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/construct)
7553        #[cfg(js_sys_unstable_apis)]
7554        #[wasm_bindgen(js_namespace = Reflect, catch)]
7555        pub fn construct<T: JsFunction = fn() -> JsValue>(
7556            target: &Function<T>,
7557            arguments_list: &ArrayTuple, // DOTO: <A1, A2, A3, A4, A5, A6, A7, A8>,
7558        ) -> Result<JsValue, JsValue>;
7559
7560        /// The static `Reflect.construct()` method acts like the new operator, but
7561        /// as a function.  It is equivalent to calling `new target(...args)`. It
7562        /// gives also the added option to specify a different prototype.
7563        ///
7564        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/construct)
7565        #[wasm_bindgen(js_namespace = Reflect, js_name = construct, catch)]
7566        pub fn construct_with_new_target(
7567            target: &Function,
7568            arguments_list: &Array,
7569            new_target: &Function,
7570        ) -> Result<JsValue, JsValue>;
7571
7572        /// The static `Reflect.defineProperty()` method is like
7573        /// `Object.defineProperty()` but returns a `Boolean`.
7574        ///
7575        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/defineProperty)
7576        #[cfg(not(js_sys_unstable_apis))]
7577        #[wasm_bindgen(js_namespace = Reflect, js_name = defineProperty, catch)]
7578        pub fn define_property<T>(
7579            target: &Object<T>,
7580            property_key: &JsValue,
7581            attributes: &Object,
7582        ) -> Result<bool, JsValue>;
7583
7584        /// The static `Reflect.defineProperty()` method is like
7585        /// `Object.defineProperty()` but returns a `Boolean`.
7586        ///
7587        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/defineProperty)
7588        #[cfg(js_sys_unstable_apis)]
7589        #[wasm_bindgen(js_namespace = Reflect, js_name = defineProperty, catch)]
7590        pub fn define_property<T>(
7591            target: &Object<T>,
7592            property_key: &JsValue,
7593            attributes: &PropertyDescriptor<T>,
7594        ) -> Result<bool, JsValue>;
7595
7596        /// The static `Reflect.defineProperty()` method is like
7597        /// `Object.defineProperty()` but returns a `Boolean`.
7598        ///
7599        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/defineProperty)
7600        #[wasm_bindgen(js_namespace = Reflect, js_name = defineProperty, catch)]
7601        pub fn define_property_str<T>(
7602            target: &Object<T>,
7603            property_key: &JsString,
7604            attributes: &PropertyDescriptor<T>,
7605        ) -> Result<bool, JsValue>;
7606
7607        /// The static `Reflect.deleteProperty()` method allows to delete
7608        /// properties.  It is like the `delete` operator as a function.
7609        ///
7610        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/deleteProperty)
7611        #[wasm_bindgen(js_namespace = Reflect, js_name = deleteProperty, catch)]
7612        pub fn delete_property<T>(target: &Object<T>, key: &JsValue) -> Result<bool, JsValue>;
7613
7614        /// The static `Reflect.deleteProperty()` method allows to delete
7615        /// properties.  It is like the `delete` operator as a function.
7616        ///
7617        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/deleteProperty)
7618        #[wasm_bindgen(js_namespace = Reflect, js_name = deleteProperty, catch)]
7619        pub fn delete_property_str<T>(target: &Object<T>, key: &JsString) -> Result<bool, JsValue>;
7620
7621        /// The static `Reflect.get()` method works like getting a property from
7622        /// an object (`target[propertyKey]`) as a function.
7623        ///
7624        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/get)
7625        #[cfg(not(js_sys_unstable_apis))]
7626        #[wasm_bindgen(js_namespace = Reflect, catch)]
7627        pub fn get(target: &JsValue, key: &JsValue) -> Result<JsValue, JsValue>;
7628
7629        /// The static `Reflect.get()` method works like getting a property from
7630        /// an object (`target[propertyKey]`) as a function.
7631        ///
7632        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/get)
7633        #[cfg(js_sys_unstable_apis)]
7634        #[wasm_bindgen(js_namespace = Reflect, catch)]
7635        pub fn get<T>(target: &Object<T>, key: &JsString) -> Result<Option<T>, JsValue>;
7636
7637        /// The static `Reflect.get()` method works like getting a property from
7638        /// an object (`target[propertyKey]`) as a function.
7639        ///
7640        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/get)
7641        #[wasm_bindgen(js_namespace = Reflect, js_name = get, catch)]
7642        pub fn get_str<T>(target: &Object<T>, key: &JsString) -> Result<Option<T>, JsValue>;
7643
7644        /// The static `Reflect.get()` method works like getting a property from
7645        /// an object (`target[propertyKey]`) as a function.
7646        ///
7647        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/get)
7648        #[wasm_bindgen(js_namespace = Reflect, js_name = get, catch)]
7649        pub fn get_symbol<T>(target: &Object<T>, key: &Symbol) -> Result<JsValue, JsValue>;
7650
7651        /// The same as [`get`](fn.get.html)
7652        /// except the key is an `f64`, which is slightly faster.
7653        #[wasm_bindgen(js_namespace = Reflect, js_name = get, catch)]
7654        pub fn get_f64(target: &JsValue, key: f64) -> Result<JsValue, JsValue>;
7655
7656        /// The same as [`get`](fn.get.html)
7657        /// except the key is a `u32`, which is slightly faster.
7658        #[wasm_bindgen(js_namespace = Reflect, js_name = get, catch)]
7659        pub fn get_u32(target: &JsValue, key: u32) -> Result<JsValue, JsValue>;
7660
7661        /// The static `Reflect.getOwnPropertyDescriptor()` method is similar to
7662        /// `Object.getOwnPropertyDescriptor()`. It returns a property descriptor
7663        /// of the given property if it exists on the object, `undefined` otherwise.
7664        ///
7665        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/getOwnPropertyDescriptor)
7666        #[wasm_bindgen(js_namespace = Reflect, js_name = getOwnPropertyDescriptor, catch)]
7667        pub fn get_own_property_descriptor<T>(
7668            target: &Object<T>,
7669            property_key: &JsValue,
7670        ) -> 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_str<T>(
7679            target: &Object<T>,
7680            property_key: &JsString,
7681        ) -> Result<PropertyDescriptor<T>, JsValue>;
7682
7683        /// The static `Reflect.getPrototypeOf()` method is almost the same
7684        /// method as `Object.getPrototypeOf()`. It returns the prototype
7685        /// (i.e. the value of the internal `[[Prototype]]` property) of
7686        /// the specified object.
7687        ///
7688        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/getPrototypeOf)
7689        #[cfg(not(js_sys_unstable_apis))]
7690        #[wasm_bindgen(js_namespace = Reflect, js_name = getPrototypeOf, catch)]
7691        pub fn get_prototype_of(target: &JsValue) -> Result<Object, JsValue>;
7692
7693        /// The static `Reflect.getPrototypeOf()` method is almost the same
7694        /// method as `Object.getPrototypeOf()`. It returns the prototype
7695        /// (i.e. the value of the internal `[[Prototype]]` property) of
7696        /// the specified object.
7697        ///
7698        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/getPrototypeOf)
7699        #[cfg(js_sys_unstable_apis)]
7700        #[wasm_bindgen(js_namespace = Reflect, js_name = getPrototypeOf, catch)]
7701        pub fn get_prototype_of(target: &Object) -> Result<Object, JsValue>;
7702
7703        /// The static `Reflect.has()` method works like the in operator as a
7704        /// function.
7705        ///
7706        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/has)
7707        #[cfg(not(js_sys_unstable_apis))]
7708        #[wasm_bindgen(js_namespace = Reflect, catch)]
7709        pub fn has(target: &JsValue, property_key: &JsValue) -> Result<bool, JsValue>;
7710
7711        /// The static `Reflect.has()` method works like the in operator as a
7712        /// function.
7713        ///
7714        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/has)
7715        #[cfg(js_sys_unstable_apis)]
7716        #[wasm_bindgen(js_namespace = Reflect, catch)]
7717        pub fn has(target: &JsValue, property_key: &Symbol) -> Result<bool, JsValue>;
7718
7719        // Next major: deprecate
7720        /// The static `Reflect.has()` method works like the in operator as a
7721        /// function.
7722        ///
7723        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/has)
7724        #[wasm_bindgen(js_namespace = Reflect, js_name = has, catch)]
7725        pub fn has_str<T>(target: &Object<T>, property_key: &JsString) -> Result<bool, JsValue>;
7726
7727        /// The static `Reflect.has()` method works like the in operator as a
7728        /// function.
7729        ///
7730        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/has)
7731        #[wasm_bindgen(js_namespace = Reflect, js_name = has, catch)]
7732        pub fn has_symbol<T>(target: &Object<T>, property_key: &Symbol) -> Result<bool, JsValue>;
7733
7734        /// The static `Reflect.isExtensible()` method determines if an object is
7735        /// extensible (whether it can have new properties added to it). It is
7736        /// similar to `Object.isExtensible()`, but with some differences.
7737        ///
7738        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/isExtensible)
7739        #[wasm_bindgen(js_namespace = Reflect, js_name = isExtensible, catch)]
7740        pub fn is_extensible<T>(target: &Object<T>) -> Result<bool, JsValue>;
7741
7742        /// The static `Reflect.ownKeys()` method returns an array of the
7743        /// target object's own property keys.
7744        ///
7745        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/ownKeys)
7746        #[wasm_bindgen(js_namespace = Reflect, js_name = ownKeys, catch)]
7747        pub fn own_keys(target: &JsValue) -> Result<Array, JsValue>;
7748
7749        /// The static `Reflect.preventExtensions()` method prevents new
7750        /// properties from ever being added to an object (i.e. prevents
7751        /// future extensions to the object). It is similar to
7752        /// `Object.preventExtensions()`, but with some differences.
7753        ///
7754        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/preventExtensions)
7755        #[wasm_bindgen(js_namespace = Reflect, js_name = preventExtensions, catch)]
7756        pub fn prevent_extensions<T>(target: &Object<T>) -> Result<bool, JsValue>;
7757
7758        /// The static `Reflect.set()` method works like setting a
7759        /// property on an object.
7760        ///
7761        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/set)
7762        #[cfg(not(js_sys_unstable_apis))]
7763        #[wasm_bindgen(js_namespace = Reflect, catch)]
7764        pub fn set(
7765            target: &JsValue,
7766            property_key: &JsValue,
7767            value: &JsValue,
7768        ) -> Result<bool, JsValue>;
7769
7770        /// The static `Reflect.set()` method works like setting a
7771        /// property on an object.
7772        ///
7773        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/set)
7774        #[cfg(js_sys_unstable_apis)]
7775        #[wasm_bindgen(js_namespace = Reflect, catch)]
7776        pub fn set<T>(
7777            target: &Object<T>,
7778            property_key: &JsString,
7779            value: &T,
7780        ) -> Result<bool, JsValue>;
7781
7782        /// The static `Reflect.set()` method works like setting a
7783        /// property on an object.
7784        ///
7785        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/set)
7786        #[cfg(js_sys_unstable_apis)]
7787        #[wasm_bindgen(js_namespace = Reflect, catch)]
7788        pub fn set_symbol<T>(
7789            target: &Object<T>,
7790            property_key: &Symbol,
7791            value: &JsValue,
7792        ) -> Result<bool, JsValue>;
7793
7794        // Next major: deprecate
7795        /// The static `Reflect.set()` method works like setting a
7796        /// property on an object.
7797        ///
7798        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/set)
7799        #[wasm_bindgen(js_namespace = Reflect, js_name = set, catch)]
7800        pub fn set_str<T>(
7801            target: &Object<T>,
7802            property_key: &JsString,
7803            value: &T,
7804        ) -> Result<bool, JsValue>;
7805
7806        /// The same as [`set`](fn.set.html)
7807        /// except the key is an `f64`, which is slightly faster.
7808        #[wasm_bindgen(js_namespace = Reflect, js_name = set, catch)]
7809        pub fn set_f64(
7810            target: &JsValue,
7811            property_key: f64,
7812            value: &JsValue,
7813        ) -> Result<bool, JsValue>;
7814
7815        /// The same as [`set`](fn.set.html)
7816        /// except the key is a `u32`, which is slightly faster.
7817        #[wasm_bindgen(js_namespace = Reflect, js_name = set, catch)]
7818        pub fn set_u32(
7819            target: &JsValue,
7820            property_key: u32,
7821            value: &JsValue,
7822        ) -> Result<bool, JsValue>;
7823
7824        /// The static `Reflect.set()` method works like setting a
7825        /// property on an object.
7826        ///
7827        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/set)
7828        #[wasm_bindgen(js_namespace = Reflect, js_name = set, catch)]
7829        pub fn set_with_receiver(
7830            target: &JsValue,
7831            property_key: &JsValue,
7832            value: &JsValue,
7833            receiver: &JsValue,
7834        ) -> Result<bool, JsValue>;
7835
7836        /// The static `Reflect.setPrototypeOf()` method is the same
7837        /// method as `Object.setPrototypeOf()`. It sets the prototype
7838        /// (i.e., the internal `[[Prototype]]` property) of a specified
7839        /// object to another object or to null.
7840        ///
7841        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/setPrototypeOf)
7842        #[wasm_bindgen(js_namespace = Reflect, js_name = setPrototypeOf, catch)]
7843        pub fn set_prototype_of<T>(
7844            target: &Object<T>,
7845            prototype: &JsValue,
7846        ) -> Result<bool, JsValue>;
7847    }
7848}
7849
7850// RegExp
7851#[wasm_bindgen]
7852extern "C" {
7853    #[wasm_bindgen(extends = Object, typescript_type = "RegExp")]
7854    #[derive(Clone, Debug, PartialEq, Eq)]
7855    pub type RegExp;
7856
7857    /// The `exec()` method executes a search for a match in a specified
7858    /// string. Returns a result array, or null.
7859    ///
7860    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec)
7861    #[cfg(not(js_sys_unstable_apis))]
7862    #[wasm_bindgen(method)]
7863    pub fn exec(this: &RegExp, text: &str) -> Option<Array<JsString>>;
7864
7865    /// The `exec()` method executes a search for a match in a specified
7866    /// string. Returns a result array, or null.
7867    ///
7868    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec)
7869    #[cfg(js_sys_unstable_apis)]
7870    #[wasm_bindgen(method)]
7871    pub fn exec(this: &RegExp, text: &str) -> Option<RegExpMatchArray>;
7872
7873    /// The flags property returns a string consisting of the flags of
7874    /// the current regular expression object.
7875    ///
7876    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/flags)
7877    #[wasm_bindgen(method, getter)]
7878    pub fn flags(this: &RegExp) -> JsString;
7879
7880    /// The global property indicates whether or not the "g" flag is
7881    /// used with the regular expression. global is a read-only
7882    /// property of an individual regular expression instance.
7883    ///
7884    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/global)
7885    #[wasm_bindgen(method, getter)]
7886    pub fn global(this: &RegExp) -> bool;
7887
7888    /// The ignoreCase property indicates whether or not the "i" flag
7889    /// is used with the regular expression. ignoreCase is a read-only
7890    /// property of an individual regular expression instance.
7891    ///
7892    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/ignoreCase)
7893    #[wasm_bindgen(method, getter, js_name = ignoreCase)]
7894    pub fn ignore_case(this: &RegExp) -> bool;
7895
7896    /// The non-standard input property is a static property of
7897    /// regular expressions that contains the string against which a
7898    /// regular expression is matched. RegExp.$_ is an alias for this
7899    /// property.
7900    ///
7901    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/input)
7902    #[wasm_bindgen(static_method_of = RegExp, getter)]
7903    pub fn input() -> JsString;
7904
7905    /// The lastIndex is a read/write integer property of regular expression
7906    /// instances that specifies the index at which to start the next match.
7907    ///
7908    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastIndex)
7909    #[wasm_bindgen(structural, getter = lastIndex, method)]
7910    pub fn last_index(this: &RegExp) -> u32;
7911
7912    /// The lastIndex is a read/write integer property of regular expression
7913    /// instances that specifies the index at which to start the next match.
7914    ///
7915    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastIndex)
7916    #[wasm_bindgen(structural, setter = lastIndex, method)]
7917    pub fn set_last_index(this: &RegExp, index: u32);
7918
7919    /// The non-standard lastMatch property is a static and read-only
7920    /// property of regular expressions that contains the last matched
7921    /// characters. `RegExp.$&` is an alias for this property.
7922    ///
7923    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastMatch)
7924    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = lastMatch)]
7925    pub fn last_match() -> JsString;
7926
7927    /// The non-standard lastParen property is a static and read-only
7928    /// property of regular expressions that contains the last
7929    /// parenthesized substring match, if any. `RegExp.$+` is an alias
7930    /// for this property.
7931    ///
7932    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastParen)
7933    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = lastParen)]
7934    pub fn last_paren() -> JsString;
7935
7936    /// The non-standard leftContext property is a static and
7937    /// read-only property of regular expressions that contains the
7938    /// substring preceding the most recent match. `RegExp.$`` is an
7939    /// alias for this property.
7940    ///
7941    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/leftContext)
7942    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = leftContext)]
7943    pub fn left_context() -> JsString;
7944
7945    /// The multiline property indicates whether or not the "m" flag
7946    /// is used with the regular expression. multiline is a read-only
7947    /// property of an individual regular expression instance.
7948    ///
7949    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/multiline)
7950    #[wasm_bindgen(method, getter)]
7951    pub fn multiline(this: &RegExp) -> bool;
7952
7953    /// The non-standard $1, $2, $3, $4, $5, $6, $7, $8, $9 properties
7954    /// are static and read-only properties of regular expressions
7955    /// that contain parenthesized substring matches.
7956    ///
7957    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/n)
7958    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$1")]
7959    pub fn n1() -> JsString;
7960    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$2")]
7961    pub fn n2() -> JsString;
7962    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$3")]
7963    pub fn n3() -> JsString;
7964    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$4")]
7965    pub fn n4() -> JsString;
7966    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$5")]
7967    pub fn n5() -> JsString;
7968    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$6")]
7969    pub fn n6() -> JsString;
7970    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$7")]
7971    pub fn n7() -> JsString;
7972    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$8")]
7973    pub fn n8() -> JsString;
7974    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$9")]
7975    pub fn n9() -> JsString;
7976
7977    /// The `RegExp` constructor creates a regular expression object for matching text with a pattern.
7978    ///
7979    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp)
7980    #[wasm_bindgen(constructor)]
7981    pub fn new(pattern: &str, flags: &str) -> RegExp;
7982    #[wasm_bindgen(constructor)]
7983    pub fn new_regexp(pattern: &RegExp, flags: &str) -> RegExp;
7984
7985    /// The non-standard rightContext property is a static and
7986    /// read-only property of regular expressions that contains the
7987    /// substring following the most recent match. `RegExp.$'` is an
7988    /// alias for this property.
7989    ///
7990    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/rightContext)
7991    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = rightContext)]
7992    pub fn right_context() -> JsString;
7993
7994    /// The source property returns a String containing the source
7995    /// text of the regexp object, and it doesn't contain the two
7996    /// forward slashes on both sides and any flags.
7997    ///
7998    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/source)
7999    #[wasm_bindgen(method, getter)]
8000    pub fn source(this: &RegExp) -> JsString;
8001
8002    /// The sticky property reflects whether or not the search is
8003    /// sticky (searches in strings only from the index indicated by
8004    /// the lastIndex property of this regular expression). sticky is
8005    /// a read-only property of an individual regular expression
8006    /// object.
8007    ///
8008    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/sticky)
8009    #[wasm_bindgen(method, getter)]
8010    pub fn sticky(this: &RegExp) -> bool;
8011
8012    /// The `test()` method executes a search for a match between a
8013    /// regular expression and a specified string. Returns true or
8014    /// false.
8015    ///
8016    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test)
8017    #[wasm_bindgen(method)]
8018    pub fn test(this: &RegExp, text: &str) -> bool;
8019
8020    /// The `toString()` method returns a string representing the
8021    /// regular expression.
8022    ///
8023    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/toString)
8024    #[cfg(not(js_sys_unstable_apis))]
8025    #[wasm_bindgen(method, js_name = toString)]
8026    pub fn to_string(this: &RegExp) -> JsString;
8027
8028    /// The unicode property indicates whether or not the "u" flag is
8029    /// used with a regular expression. unicode is a read-only
8030    /// property of an individual regular expression instance.
8031    ///
8032    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/unicode)
8033    #[wasm_bindgen(method, getter)]
8034    pub fn unicode(this: &RegExp) -> bool;
8035}
8036
8037// RegExpMatchArray
8038#[wasm_bindgen]
8039extern "C" {
8040    /// The result array from `RegExp.exec()` or `String.matchAll()`.
8041    ///
8042    /// This is an array of strings with additional properties `index`, `input`, and `groups`.
8043    ///
8044    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec#return_value)
8045    #[wasm_bindgen(extends = Object, extends = Array, typescript_type = "RegExpMatchArray")]
8046    #[derive(Clone, Debug, PartialEq, Eq)]
8047    pub type RegExpMatchArray;
8048
8049    /// The 0-based index of the match in the string.
8050    #[wasm_bindgen(method, getter)]
8051    pub fn index(this: &RegExpMatchArray) -> u32;
8052
8053    /// The original string that was matched against.
8054    #[wasm_bindgen(method, getter)]
8055    pub fn input(this: &RegExpMatchArray) -> JsString;
8056
8057    /// An object of named capturing groups whose keys are the names and valuestype Array
8058    /// are the capturing groups, or `undefined` if no named capturing groups were defined.
8059    #[wasm_bindgen(method, getter)]
8060    pub fn groups(this: &RegExpMatchArray) -> Option<Object>;
8061
8062    /// The number of elements in the match array (full match + capture groups).
8063    #[wasm_bindgen(method, getter)]
8064    pub fn length(this: &RegExpMatchArray) -> u32;
8065
8066    /// Gets the matched string or capture group at the given index.
8067    /// Index 0 is the full match, indices 1+ are capture groups.
8068    #[wasm_bindgen(method, indexing_getter)]
8069    pub fn get(this: &RegExpMatchArray, index: u32) -> Option<JsString>;
8070}
8071
8072// Set
8073#[wasm_bindgen]
8074extern "C" {
8075    #[wasm_bindgen(extends = Object, typescript_type = "Set<any>")]
8076    #[derive(Clone, Debug, PartialEq, Eq)]
8077    pub type Set<T = JsValue>;
8078
8079    /// The [`Set`] object lets you store unique values of any type, whether
8080    /// primitive values or object references.
8081    ///
8082    /// **Note:** Consider using [`Set::new_typed`] to support typing.
8083    ///
8084    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set)
8085    #[cfg(not(js_sys_unstable_apis))]
8086    #[wasm_bindgen(constructor)]
8087    pub fn new(init: &JsValue) -> Set;
8088
8089    /// The [`Set`] object lets you store unique values of any type, whether
8090    /// primitive values or object references.
8091    ///
8092    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set)
8093    #[cfg(js_sys_unstable_apis)]
8094    #[wasm_bindgen(constructor)]
8095    pub fn new<T>() -> Set<T>;
8096
8097    // Next major: deprecate
8098    /// The [`Set`] object lets you store unique values of any type, whether
8099    /// primitive values or object references.
8100    ///
8101    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set)
8102    #[wasm_bindgen(constructor)]
8103    pub fn new_typed<T>() -> Set<T>;
8104
8105    /// The [`Set`] object lets you store unique values of any type, whether
8106    /// primitive values or object references.
8107    ///
8108    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set)
8109    #[wasm_bindgen(constructor, js_name = new)]
8110    pub fn new_empty<T>() -> Set<T>;
8111
8112    /// The [`Set`] object lets you store unique values of any type, whether
8113    /// primitive values or object references.
8114    ///
8115    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set)
8116    #[wasm_bindgen(constructor, js_name = new)]
8117    pub fn new_from_items<T>(items: &[T]) -> Set<T>;
8118
8119    /// The [`Set`] object lets you store unique values of any type, whether
8120    /// primitive values or object references.
8121    ///
8122    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set)
8123    #[wasm_bindgen(constructor, js_name = new, catch)]
8124    pub fn new_from_iterable<T, I: Iterable<Item = T>>(iterable: I) -> Result<Set<T>, JsValue>;
8125
8126    /// The `add()` method appends a new element with a specified value to the
8127    /// end of a [`Set`] object.
8128    ///
8129    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/add)
8130    #[wasm_bindgen(method)]
8131    pub fn add<T>(this: &Set<T>, value: &T) -> Set<T>;
8132
8133    /// The `clear()` method removes all elements from a [`Set`] object.
8134    ///
8135    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/clear)
8136    #[wasm_bindgen(method)]
8137    pub fn clear<T>(this: &Set<T>);
8138
8139    /// The `delete()` method removes the specified element from a [`Set`]
8140    /// object.
8141    ///
8142    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/delete)
8143    #[wasm_bindgen(method)]
8144    pub fn delete<T>(this: &Set<T>, value: &T) -> bool;
8145
8146    /// The `forEach()` method executes a provided function once for each value
8147    /// in the Set object, in insertion order.
8148    ///
8149    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/forEach)
8150    #[cfg(not(js_sys_unstable_apis))]
8151    #[wasm_bindgen(method, js_name = forEach)]
8152    pub fn for_each<T>(this: &Set<T>, callback: &mut dyn FnMut(T, T, Set<T>));
8153
8154    /// The `forEach()` method executes a provided function once for each value
8155    /// in the Set object, in insertion order.
8156    ///
8157    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/forEach)
8158    #[cfg(js_sys_unstable_apis)]
8159    #[wasm_bindgen(method, js_name = forEach)]
8160    pub fn for_each<T>(this: &Set<T>, callback: &mut dyn FnMut(T));
8161
8162    /// The `forEach()` method executes a provided function once for each value
8163    /// in the Set object, in insertion order.
8164    ///
8165    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/forEach)
8166    #[wasm_bindgen(method, js_name = forEach, catch)]
8167    pub fn try_for_each<T>(
8168        this: &Set<T>,
8169        callback: &mut dyn FnMut(T) -> Result<(), JsError>,
8170    ) -> Result<(), JsValue>;
8171
8172    /// The `has()` method returns a boolean indicating whether an element with
8173    /// the specified value exists in a [`Set`] object or not.
8174    ///
8175    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/has)
8176    #[wasm_bindgen(method)]
8177    pub fn has<T>(this: &Set<T>, value: &T) -> bool;
8178
8179    /// The size accessor property returns the number of elements in a [`Set`]
8180    /// object.
8181    ///
8182    /// [MDN documentation](https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Set/size)
8183    #[wasm_bindgen(method, getter)]
8184    pub fn size<T>(this: &Set<T>) -> u32;
8185
8186    /// The `union()` method returns a new set containing elements which are in
8187    /// either or both of this set and the given set.
8188    ///
8189    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/union)
8190    #[wasm_bindgen(method)]
8191    pub fn union<T>(this: &Set<T>, other: &Set<T>) -> Set<T>;
8192
8193    /// The `intersection()` method returns a new set containing elements which are
8194    /// in both this set and the given set.
8195    ///
8196    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/intersection)
8197    #[wasm_bindgen(method)]
8198    pub fn intersection<T>(this: &Set<T>, other: &Set<T>) -> Set<T>;
8199
8200    /// The `difference()` method returns a new set containing elements which are
8201    /// in this set but not in the given set.
8202    ///
8203    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/difference)
8204    #[wasm_bindgen(method)]
8205    pub fn difference<T>(this: &Set<T>, other: &Set<T>) -> Set<T>;
8206
8207    /// The `symmetricDifference()` method returns a new set containing elements
8208    /// which are in either this set or the given set, but not in both.
8209    ///
8210    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/symmetricDifference)
8211    #[wasm_bindgen(method, js_name = symmetricDifference)]
8212    pub fn symmetric_difference<T>(this: &Set<T>, other: &Set<T>) -> Set<T>;
8213
8214    /// The `isSubsetOf()` method returns a boolean indicating whether all elements
8215    /// of this set are in the given set.
8216    ///
8217    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/isSubsetOf)
8218    #[wasm_bindgen(method, js_name = isSubsetOf)]
8219    pub fn is_subset_of<T>(this: &Set<T>, other: &Set<T>) -> bool;
8220
8221    /// The `isSupersetOf()` method returns a boolean indicating whether all elements
8222    /// of the given set are in this set.
8223    ///
8224    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/isSupersetOf)
8225    #[wasm_bindgen(method, js_name = isSupersetOf)]
8226    pub fn is_superset_of<T>(this: &Set<T>, other: &Set<T>) -> bool;
8227
8228    /// The `isDisjointFrom()` method returns a boolean indicating whether this set
8229    /// has no elements in common with the given set.
8230    ///
8231    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/isDisjointFrom)
8232    #[wasm_bindgen(method, js_name = isDisjointFrom)]
8233    pub fn is_disjoint_from<T>(this: &Set<T>, other: &Set<T>) -> bool;
8234}
8235
8236impl Default for Set<JsValue> {
8237    fn default() -> Self {
8238        Self::new_typed()
8239    }
8240}
8241
8242impl<T> Iterable for Set<T> {
8243    type Item = T;
8244}
8245
8246// SetIterator
8247#[wasm_bindgen]
8248extern "C" {
8249    /// The `entries()` method returns a new Iterator object that contains an
8250    /// array of [value, value] for each element in the Set object, in insertion
8251    /// order. For Set objects there is no key like in Map objects. However, to
8252    /// keep the API similar to the Map object, each entry has the same value
8253    /// for its key and value here, so that an array [value, value] is returned.
8254    ///
8255    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/entries)
8256    #[cfg(not(js_sys_unstable_apis))]
8257    #[wasm_bindgen(method)]
8258    pub fn entries<T>(set: &Set<T>) -> Iterator;
8259
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(js_sys_unstable_apis)]
8268    #[wasm_bindgen(method, js_name = entries)]
8269    pub fn entries<T: JsGeneric>(set: &Set<T>) -> Iterator<ArrayTuple<(T, T)>>;
8270
8271    // Next major: deprecate
8272    /// The `entries()` method returns a new Iterator object that contains an
8273    /// array of [value, value] for each element in the Set object, in insertion
8274    /// order. For Set objects there is no key like in Map objects. However, to
8275    /// keep the API similar to the Map object, each entry has the same value
8276    /// for its key and value here, so that an array [value, value] is returned.
8277    ///
8278    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/entries)
8279    #[wasm_bindgen(method, js_name = entries)]
8280    pub fn entries_typed<T: JsGeneric>(set: &Set<T>) -> Iterator<ArrayTuple<(T, T)>>;
8281
8282    /// The `keys()` method is an alias for this method (for similarity with
8283    /// Map objects); it behaves exactly the same and returns values
8284    /// of Set elements.
8285    ///
8286    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/values)
8287    #[wasm_bindgen(method)]
8288    pub fn keys<T>(set: &Set<T>) -> Iterator<T>;
8289
8290    /// The `values()` method returns a new Iterator object that contains the
8291    /// values for each element in the Set object in insertion order.
8292    ///
8293    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/values)
8294    #[wasm_bindgen(method)]
8295    pub fn values<T>(set: &Set<T>) -> Iterator<T>;
8296}
8297
8298// SyntaxError
8299#[wasm_bindgen]
8300extern "C" {
8301    /// A `SyntaxError` is thrown when the JavaScript engine encounters tokens or
8302    /// token order that does not conform to the syntax of the language when
8303    /// parsing code.
8304    ///
8305    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError)
8306    #[wasm_bindgen(extends = Error, extends = Object, typescript_type = "SyntaxError")]
8307    #[derive(Clone, Debug, PartialEq, Eq)]
8308    pub type SyntaxError;
8309
8310    /// A `SyntaxError` is thrown when the JavaScript engine encounters tokens or
8311    /// token order that does not conform to the syntax of the language when
8312    /// parsing code.
8313    ///
8314    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError)
8315    #[wasm_bindgen(constructor)]
8316    pub fn new(message: &str) -> SyntaxError;
8317
8318    /// Creates a new `SyntaxError` with the given message and a typed
8319    /// [`ErrorOptions`] dictionary whose `cause` property indicates the
8320    /// original cause of the error.
8321    ///
8322    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError/SyntaxError)
8323    #[wasm_bindgen(constructor)]
8324    pub fn new_with_options(message: &str, options: &ErrorOptions) -> SyntaxError;
8325}
8326
8327// TypeError
8328#[wasm_bindgen]
8329extern "C" {
8330    /// The `TypeError` object represents an error when a value is not of the
8331    /// expected type.
8332    ///
8333    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError)
8334    #[wasm_bindgen(extends = Error, extends = Object, typescript_type = "TypeError")]
8335    #[derive(Clone, Debug, PartialEq, Eq)]
8336    pub type TypeError;
8337
8338    /// The `TypeError` object represents an error when a value is not of the
8339    /// expected type.
8340    ///
8341    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError)
8342    #[wasm_bindgen(constructor)]
8343    pub fn new(message: &str) -> TypeError;
8344
8345    /// Creates a new `TypeError` with the given message and a typed
8346    /// [`ErrorOptions`] dictionary whose `cause` property indicates the
8347    /// original cause of the error.
8348    ///
8349    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError/TypeError)
8350    #[wasm_bindgen(constructor)]
8351    pub fn new_with_options(message: &str, options: &ErrorOptions) -> TypeError;
8352}
8353
8354// URIError
8355#[wasm_bindgen]
8356extern "C" {
8357    /// The `URIError` object represents an error when a global URI handling
8358    /// function was used in a wrong way.
8359    ///
8360    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError)
8361    #[wasm_bindgen(extends = Error, extends = Object, js_name = URIError, typescript_type = "URIError")]
8362    #[derive(Clone, Debug, PartialEq, Eq)]
8363    pub type UriError;
8364
8365    /// The `URIError` object represents an error when a global URI handling
8366    /// function was used in a wrong way.
8367    ///
8368    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError)
8369    #[wasm_bindgen(constructor, js_class = "URIError")]
8370    pub fn new(message: &str) -> UriError;
8371
8372    /// Creates a new `URIError` with the given message and a typed
8373    /// [`ErrorOptions`] dictionary whose `cause` property indicates the
8374    /// original cause of the error.
8375    ///
8376    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError/URIError)
8377    #[wasm_bindgen(constructor, js_class = "URIError")]
8378    pub fn new_with_options(message: &str, options: &ErrorOptions) -> UriError;
8379}
8380
8381// WeakMap
8382#[wasm_bindgen]
8383extern "C" {
8384    #[wasm_bindgen(extends = Object, typescript_type = "WeakMap<object, any>")]
8385    #[derive(Clone, Debug, PartialEq, Eq)]
8386    pub type WeakMap<K = Object, V = JsValue>;
8387
8388    /// The [`WeakMap`] object is a collection of key/value pairs in which the
8389    /// keys are weakly referenced.  The keys must be objects and the values can
8390    /// be arbitrary values.
8391    ///
8392    /// **Note:** Consider using [`WeakMap::new_typed`] to support typing.
8393    ///
8394    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap)
8395    #[cfg(not(js_sys_unstable_apis))]
8396    #[wasm_bindgen(constructor)]
8397    pub fn new() -> WeakMap;
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    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap)
8404    #[cfg(js_sys_unstable_apis)]
8405    #[wasm_bindgen(constructor)]
8406    pub fn new<K: JsGeneric = Object, V: JsGeneric = Object>() -> WeakMap<K, V>;
8407
8408    // Next major: deprecate
8409    /// The [`WeakMap`] object is a collection of key/value pairs in which the
8410    /// keys are weakly referenced.  The keys must be objects and the values can
8411    /// be arbitrary values.
8412    ///
8413    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap)
8414    #[wasm_bindgen(constructor)]
8415    pub fn new_typed<K: JsGeneric = Object, V: JsGeneric = Object>() -> WeakMap<K, V>;
8416
8417    /// The `set()` method sets the value for the key in the [`WeakMap`] object.
8418    /// Returns the [`WeakMap`] object.
8419    ///
8420    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/set)
8421    #[wasm_bindgen(method, js_class = "WeakMap")]
8422    pub fn set<K, V>(this: &WeakMap<K, V>, key: &K, value: &V) -> WeakMap<K, V>;
8423
8424    /// The `get()` method returns a specified by key element
8425    /// from a [`WeakMap`] object. Returns `undefined` if the key is not found.
8426    ///
8427    /// **Note:** Consider using [`WeakMap::get_checked`] to get an `Option<V>` instead.
8428    ///
8429    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/get)
8430    #[cfg(not(js_sys_unstable_apis))]
8431    #[wasm_bindgen(method)]
8432    pub fn get<K, V>(this: &WeakMap<K, V>, key: &K) -> V;
8433
8434    /// The `get()` method returns a specified by key element
8435    /// from a [`WeakMap`] object. Returns `None` if the key is not found.
8436    ///
8437    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/get)
8438    #[cfg(js_sys_unstable_apis)]
8439    #[wasm_bindgen(method)]
8440    pub fn get<K, V>(this: &WeakMap<K, V>, key: &K) -> Option<V>;
8441
8442    /// The `get()` method returns a specified by key element
8443    /// from a [`WeakMap`] object. Returns `None` if the key is not found.
8444    ///
8445    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/get)
8446    #[wasm_bindgen(method, js_name = get)]
8447    pub fn get_checked<K, V>(this: &WeakMap<K, V>, key: &K) -> Option<V>;
8448
8449    /// The `has()` method returns a boolean indicating whether an element with
8450    /// the specified key exists in the [`WeakMap`] object or not.
8451    ///
8452    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/has)
8453    #[wasm_bindgen(method)]
8454    pub fn has<K, V>(this: &WeakMap<K, V>, key: &K) -> bool;
8455
8456    /// The `delete()` method removes the specified element from a [`WeakMap`]
8457    /// object.
8458    ///
8459    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/delete)
8460    #[wasm_bindgen(method)]
8461    pub fn delete<K, V>(this: &WeakMap<K, V>, key: &K) -> bool;
8462}
8463
8464impl Default for WeakMap {
8465    fn default() -> Self {
8466        Self::new()
8467    }
8468}
8469
8470// WeakSet
8471#[wasm_bindgen]
8472extern "C" {
8473    #[wasm_bindgen(extends = Object, typescript_type = "WeakSet<object>")]
8474    #[derive(Clone, Debug, PartialEq, Eq)]
8475    pub type WeakSet<T = Object>;
8476
8477    /// The `WeakSet` object lets you store weakly held objects in a collection.
8478    ///
8479    /// **Note:** Consider using [`WeakSet::new_typed`] for typed sets.
8480    ///
8481    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet)
8482    #[cfg(not(js_sys_unstable_apis))]
8483    #[wasm_bindgen(constructor)]
8484    pub fn new() -> WeakSet;
8485
8486    /// The `WeakSet` object lets you store weakly held objects in a collection.
8487    ///
8488    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet)
8489    #[cfg(js_sys_unstable_apis)]
8490    #[wasm_bindgen(constructor)]
8491    pub fn new<T = Object>() -> WeakSet<T>;
8492
8493    // Next major: deprecate
8494    /// The `WeakSet` object lets you store weakly held objects in a collection.
8495    ///
8496    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet)
8497    #[wasm_bindgen(constructor)]
8498    pub fn new_typed<T = Object>() -> WeakSet<T>;
8499
8500    /// The `has()` method returns a boolean indicating whether an object exists
8501    /// in a WeakSet or not.
8502    ///
8503    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet/has)
8504    #[wasm_bindgen(method)]
8505    pub fn has<T>(this: &WeakSet<T>, value: &T) -> bool;
8506
8507    /// The `add()` method appends a new object to the end of a WeakSet object.
8508    ///
8509    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet/add)
8510    #[wasm_bindgen(method)]
8511    pub fn add<T>(this: &WeakSet<T>, value: &T) -> WeakSet<T>;
8512
8513    /// The `delete()` method removes the specified element from a WeakSet
8514    /// object.
8515    ///
8516    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet/delete)
8517    #[wasm_bindgen(method)]
8518    pub fn delete<T>(this: &WeakSet<T>, value: &T) -> bool;
8519}
8520
8521impl Default for WeakSet {
8522    fn default() -> Self {
8523        Self::new()
8524    }
8525}
8526
8527// WeakRef
8528#[wasm_bindgen]
8529extern "C" {
8530    #[wasm_bindgen(extends = Object, typescript_type = "WeakRef<object>")]
8531    #[derive(Clone, Debug, PartialEq, Eq)]
8532    pub type WeakRef<T = Object>;
8533
8534    /// The `WeakRef` object contains a weak reference to an object. A weak
8535    /// reference to an object is a reference that does not prevent the object
8536    /// from being reclaimed by the garbage collector.
8537    ///
8538    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakRef)
8539    #[wasm_bindgen(constructor)]
8540    pub fn new<T = Object>(target: &T) -> WeakRef<T>;
8541
8542    /// Returns the `Object` this `WeakRef` points to, or `None` if the
8543    /// object has been garbage collected.
8544    ///
8545    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakRef/deref)
8546    #[wasm_bindgen(method)]
8547    pub fn deref<T>(this: &WeakRef<T>) -> Option<T>;
8548}
8549
8550#[cfg(js_sys_unstable_apis)]
8551#[allow(non_snake_case)]
8552pub mod Temporal;
8553
8554#[allow(non_snake_case)]
8555pub mod WebAssembly {
8556    use super::*;
8557
8558    // WebAssembly
8559    #[wasm_bindgen]
8560    extern "C" {
8561        /// The `WebAssembly.compile()` function compiles a `WebAssembly.Module`
8562        /// from WebAssembly binary code.  This function is useful if it is
8563        /// necessary to a compile a module before it can be instantiated
8564        /// (otherwise, the `WebAssembly.instantiate()` function should be used).
8565        ///
8566        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/compile)
8567        #[cfg(not(js_sys_unstable_apis))]
8568        #[wasm_bindgen(js_namespace = WebAssembly)]
8569        pub fn compile(buffer_source: &JsValue) -> Promise<JsValue>;
8570
8571        /// The `WebAssembly.compile()` function compiles a `WebAssembly.Module`
8572        /// from WebAssembly binary code.  This function is useful if it is
8573        /// necessary to a compile a module before it can be instantiated
8574        /// (otherwise, the `WebAssembly.instantiate()` function should be used).
8575        ///
8576        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/compile)
8577        #[cfg(js_sys_unstable_apis)]
8578        #[wasm_bindgen(js_namespace = WebAssembly)]
8579        pub fn compile(buffer_source: &JsValue) -> Promise<Module>;
8580
8581        /// The `WebAssembly.compileStreaming()` function compiles a
8582        /// `WebAssembly.Module` module directly from a streamed underlying
8583        /// source. This function is useful if it is necessary to a compile a
8584        /// module before it can be instantiated (otherwise, the
8585        /// `WebAssembly.instantiateStreaming()` function should be used).
8586        ///
8587        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/compileStreaming)
8588        #[cfg(not(js_sys_unstable_apis))]
8589        #[wasm_bindgen(js_namespace = WebAssembly, js_name = compileStreaming)]
8590        pub fn compile_streaming(response: &Promise) -> Promise<JsValue>;
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(js_sys_unstable_apis)]
8600        #[wasm_bindgen(js_namespace = WebAssembly, js_name = compileStreaming)]
8601        pub fn compile_streaming(response: &Promise) -> Promise<Module>;
8602
8603        /// The `WebAssembly.instantiate()` function allows you to compile and
8604        /// instantiate WebAssembly code.
8605        ///
8606        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiate)
8607        #[cfg(not(js_sys_unstable_apis))]
8608        #[wasm_bindgen(js_namespace = WebAssembly, js_name = instantiate)]
8609        pub fn instantiate_buffer(buffer: &[u8], imports: &Object) -> Promise<JsValue>;
8610
8611        /// The `WebAssembly.instantiate()` function allows you to compile and
8612        /// instantiate WebAssembly code.
8613        ///
8614        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiate)
8615        #[cfg(js_sys_unstable_apis)]
8616        #[wasm_bindgen(js_namespace = WebAssembly, js_name = instantiate)]
8617        pub fn instantiate_buffer(buffer: &[u8], imports: &Object) -> Promise<Instance>;
8618
8619        /// The `WebAssembly.instantiate()` function allows you to compile and
8620        /// instantiate WebAssembly code.
8621        ///
8622        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiate)
8623        #[cfg(not(js_sys_unstable_apis))]
8624        #[wasm_bindgen(js_namespace = WebAssembly, js_name = instantiate)]
8625        pub fn instantiate_module(module: &Module, imports: &Object) -> Promise<JsValue>;
8626
8627        /// The `WebAssembly.instantiate()` function allows you to compile and
8628        /// instantiate WebAssembly code.
8629        ///
8630        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiate)
8631        #[cfg(js_sys_unstable_apis)]
8632        #[wasm_bindgen(js_namespace = WebAssembly, js_name = instantiate)]
8633        pub fn instantiate_module(module: &Module, imports: &Object) -> Promise<Instance>;
8634
8635        /// The `WebAssembly.instantiateStreaming()` function compiles and
8636        /// instantiates a WebAssembly module directly from a streamed
8637        /// underlying source. This is the most efficient, optimized way to load
8638        /// Wasm code.
8639        ///
8640        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiateStreaming)
8641        #[cfg(not(js_sys_unstable_apis))]
8642        #[wasm_bindgen(js_namespace = WebAssembly, js_name = instantiateStreaming)]
8643        pub fn instantiate_streaming(response: &JsValue, imports: &Object) -> Promise<JsValue>;
8644
8645        /// The `WebAssembly.instantiateStreaming()` function compiles and
8646        /// instantiates a WebAssembly module directly from a streamed
8647        /// underlying source. This is the most efficient, optimized way to load
8648        /// Wasm code.
8649        ///
8650        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiateStreaming)
8651        #[cfg(js_sys_unstable_apis)]
8652        #[wasm_bindgen(js_namespace = WebAssembly, js_name = instantiateStreaming)]
8653        pub fn instantiate_streaming(response: &JsValue, imports: &Object) -> Promise<Instance>;
8654
8655        /// The `WebAssembly.validate()` function validates a given typed
8656        /// array of WebAssembly binary code, returning whether the bytes
8657        /// form a valid Wasm module (`true`) or not (`false`).
8658        ///
8659        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/validate)
8660        #[wasm_bindgen(js_namespace = WebAssembly, catch)]
8661        pub fn validate(buffer_source: &JsValue) -> Result<bool, JsValue>;
8662    }
8663
8664    // WebAssembly.CompileError
8665    #[wasm_bindgen]
8666    extern "C" {
8667        /// The `WebAssembly.CompileError()` constructor creates a new
8668        /// WebAssembly `CompileError` object, which indicates an error during
8669        /// WebAssembly decoding or validation.
8670        ///
8671        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/CompileError)
8672        #[wasm_bindgen(extends = Error, js_namespace = WebAssembly, typescript_type = "WebAssembly.CompileError")]
8673        #[derive(Clone, Debug, PartialEq, Eq)]
8674        pub type CompileError;
8675
8676        /// The `WebAssembly.CompileError()` constructor creates a new
8677        /// WebAssembly `CompileError` object, which indicates an error during
8678        /// WebAssembly decoding or validation.
8679        ///
8680        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/CompileError)
8681        #[wasm_bindgen(constructor, js_namespace = WebAssembly)]
8682        pub fn new(message: &str) -> CompileError;
8683
8684        /// Creates a new `WebAssembly.CompileError` with the given message and
8685        /// a typed [`ErrorOptions`] dictionary whose `cause` property
8686        /// indicates the original cause of the error.
8687        ///
8688        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/CompileError/CompileError)
8689        #[wasm_bindgen(constructor, js_namespace = WebAssembly)]
8690        pub fn new_with_options(message: &str, options: &ErrorOptions) -> CompileError;
8691    }
8692
8693    // WebAssembly.Instance
8694    #[wasm_bindgen]
8695    extern "C" {
8696        /// A `WebAssembly.Instance` object is a stateful, executable instance
8697        /// of a `WebAssembly.Module`. Instance objects contain all the exported
8698        /// WebAssembly functions that allow calling into WebAssembly code from
8699        /// JavaScript.
8700        ///
8701        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance)
8702        #[wasm_bindgen(extends = Object, js_namespace = WebAssembly, typescript_type = "WebAssembly.Instance")]
8703        #[derive(Clone, Debug, PartialEq, Eq)]
8704        pub type Instance;
8705
8706        /// The `WebAssembly.Instance()` constructor function can be called to
8707        /// synchronously instantiate a given `WebAssembly.Module`
8708        /// object. However, the primary way to get an `Instance` is through the
8709        /// asynchronous `WebAssembly.instantiateStreaming()` function.
8710        ///
8711        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance)
8712        #[wasm_bindgen(catch, constructor, js_namespace = WebAssembly)]
8713        pub fn new(module: &Module, imports: &Object) -> Result<Instance, JsValue>;
8714
8715        /// The `exports` readonly property of the `WebAssembly.Instance` object
8716        /// prototype returns an object containing as its members all the
8717        /// functions exported from the WebAssembly module instance, to allow
8718        /// them to be accessed and used by JavaScript.
8719        ///
8720        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance/exports)
8721        #[wasm_bindgen(getter, method, js_namespace = WebAssembly)]
8722        pub fn exports(this: &Instance) -> Object;
8723    }
8724
8725    // WebAssembly.LinkError
8726    #[wasm_bindgen]
8727    extern "C" {
8728        /// The `WebAssembly.LinkError()` constructor creates a new WebAssembly
8729        /// LinkError object, which indicates an error during module
8730        /// instantiation (besides traps from the start function).
8731        ///
8732        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/LinkError)
8733        #[wasm_bindgen(extends = Error, js_namespace = WebAssembly, typescript_type = "WebAssembly.LinkError")]
8734        #[derive(Clone, Debug, PartialEq, Eq)]
8735        pub type LinkError;
8736
8737        /// The `WebAssembly.LinkError()` constructor creates a new WebAssembly
8738        /// LinkError object, which indicates an error during module
8739        /// instantiation (besides traps from the start function).
8740        ///
8741        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/LinkError)
8742        #[wasm_bindgen(constructor, js_namespace = WebAssembly)]
8743        pub fn new(message: &str) -> LinkError;
8744
8745        /// Creates a new `WebAssembly.LinkError` with the given message and a
8746        /// typed [`ErrorOptions`] dictionary whose `cause` property indicates
8747        /// the original cause of the error.
8748        ///
8749        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/LinkError/LinkError)
8750        #[wasm_bindgen(constructor, js_namespace = WebAssembly)]
8751        pub fn new_with_options(message: &str, options: &ErrorOptions) -> LinkError;
8752    }
8753
8754    // WebAssembly.RuntimeError
8755    #[wasm_bindgen]
8756    extern "C" {
8757        /// The `WebAssembly.RuntimeError()` constructor creates a new WebAssembly
8758        /// `RuntimeError` object — the type that is thrown whenever WebAssembly
8759        /// specifies a trap.
8760        ///
8761        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/RuntimeError)
8762        #[wasm_bindgen(extends = Error, js_namespace = WebAssembly, typescript_type = "WebAssembly.RuntimeError")]
8763        #[derive(Clone, Debug, PartialEq, Eq)]
8764        pub type RuntimeError;
8765
8766        /// The `WebAssembly.RuntimeError()` constructor creates a new WebAssembly
8767        /// `RuntimeError` object — the type that is thrown whenever WebAssembly
8768        /// specifies a trap.
8769        ///
8770        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/RuntimeError)
8771        #[wasm_bindgen(constructor, js_namespace = WebAssembly)]
8772        pub fn new(message: &str) -> RuntimeError;
8773
8774        /// Creates a new `WebAssembly.RuntimeError` with the given message
8775        /// and a typed [`ErrorOptions`] dictionary whose `cause` property
8776        /// indicates the original cause of the error.
8777        ///
8778        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/RuntimeError/RuntimeError)
8779        #[wasm_bindgen(constructor, js_namespace = WebAssembly)]
8780        pub fn new_with_options(message: &str, options: &ErrorOptions) -> RuntimeError;
8781    }
8782
8783    // WebAssembly.Module
8784    #[wasm_bindgen]
8785    extern "C" {
8786        /// A `WebAssembly.Module` object contains stateless WebAssembly code
8787        /// that has already been compiled by the browser and can be
8788        /// efficiently shared with Workers, and instantiated multiple times.
8789        ///
8790        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module)
8791        #[wasm_bindgen(js_namespace = WebAssembly, extends = Object, typescript_type = "WebAssembly.Module")]
8792        #[derive(Clone, Debug, PartialEq, Eq)]
8793        pub type Module;
8794
8795        /// A `WebAssembly.Module` object contains stateless WebAssembly code
8796        /// that has already been compiled by the browser and can be
8797        /// efficiently shared with Workers, and instantiated multiple times.
8798        ///
8799        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module)
8800        #[wasm_bindgen(constructor, js_namespace = WebAssembly, catch)]
8801        pub fn new(buffer_source: &JsValue) -> Result<Module, JsValue>;
8802
8803        /// The `WebAssembly.customSections()` function returns a copy of the
8804        /// contents of all custom sections in the given module with the given
8805        /// string name.
8806        ///
8807        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module/customSections)
8808        #[wasm_bindgen(static_method_of = Module, js_namespace = WebAssembly, js_name = customSections)]
8809        pub fn custom_sections(module: &Module, sectionName: &str) -> Array;
8810
8811        /// The `WebAssembly.exports()` function returns an array containing
8812        /// descriptions of all the declared exports of the given `Module`.
8813        ///
8814        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module/exports)
8815        #[wasm_bindgen(static_method_of = Module, js_namespace = WebAssembly)]
8816        pub fn exports(module: &Module) -> Array;
8817
8818        /// The `WebAssembly.imports()` function returns an array containing
8819        /// descriptions of all the declared imports of the given `Module`.
8820        ///
8821        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module/imports)
8822        #[wasm_bindgen(static_method_of = Module, js_namespace = WebAssembly)]
8823        pub fn imports(module: &Module) -> Array;
8824    }
8825
8826    // WebAssembly.Table
8827    #[wasm_bindgen]
8828    extern "C" {
8829        /// The `WebAssembly.Table()` constructor creates a new `Table` object
8830        /// of the given size and element type.
8831        ///
8832        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table)
8833        #[wasm_bindgen(js_namespace = WebAssembly, extends = Object, typescript_type = "WebAssembly.Table")]
8834        #[derive(Clone, Debug, PartialEq, Eq)]
8835        pub type Table;
8836
8837        /// The `WebAssembly.Table()` constructor creates a new `Table` object
8838        /// of the given size and element type.
8839        ///
8840        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table)
8841        #[wasm_bindgen(constructor, js_namespace = WebAssembly, catch)]
8842        pub fn new(table_descriptor: &Object) -> Result<Table, JsValue>;
8843
8844        /// The `WebAssembly.Table()` constructor creates a new `Table` object
8845        /// of the given size and element type.
8846        ///
8847        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table)
8848        #[wasm_bindgen(constructor, js_namespace = WebAssembly, catch)]
8849        pub fn new_with_value(table_descriptor: &Object, value: JsValue) -> Result<Table, JsValue>;
8850
8851        /// The length prototype property of the `WebAssembly.Table` object
8852        /// returns the length of the table, i.e. the number of elements in the
8853        /// table.
8854        ///
8855        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/length)
8856        #[wasm_bindgen(method, getter, js_namespace = WebAssembly)]
8857        pub fn length(this: &Table) -> u32;
8858
8859        /// The `get()` prototype method of the `WebAssembly.Table()` object
8860        /// retrieves a function reference stored at a given index.
8861        ///
8862        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/get)
8863        #[wasm_bindgen(method, catch, js_namespace = WebAssembly)]
8864        pub fn get(this: &Table, index: u32) -> Result<Function, JsValue>;
8865
8866        /// The `get()` prototype method of the `WebAssembly.Table()` object
8867        /// retrieves a function reference stored at a given index.
8868        ///
8869        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/get)
8870        #[wasm_bindgen(method, catch, js_namespace = WebAssembly, js_name = get)]
8871        pub fn get_raw(this: &Table, index: u32) -> Result<JsValue, JsValue>;
8872
8873        /// The `grow()` prototype method of the `WebAssembly.Table` object
8874        /// increases the size of the `Table` instance by a specified number of
8875        /// elements.
8876        ///
8877        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/grow)
8878        #[wasm_bindgen(method, catch, js_namespace = WebAssembly)]
8879        pub fn grow(this: &Table, additional_capacity: u32) -> Result<u32, JsValue>;
8880
8881        /// The `grow()` prototype method of the `WebAssembly.Table` object
8882        /// increases the size of the `Table` instance by a specified number of
8883        /// elements.
8884        ///
8885        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/grow)
8886        #[wasm_bindgen(method, catch, js_namespace = WebAssembly, js_name = grow)]
8887        pub fn grow_with_value(
8888            this: &Table,
8889            additional_capacity: u32,
8890            value: JsValue,
8891        ) -> Result<u32, JsValue>;
8892
8893        /// The `set()` prototype method of the `WebAssembly.Table` object mutates a
8894        /// reference stored at a given index to a different value.
8895        ///
8896        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/set)
8897        #[wasm_bindgen(method, catch, js_namespace = WebAssembly)]
8898        pub fn set(this: &Table, index: u32, function: &Function) -> Result<(), JsValue>;
8899
8900        /// The `set()` prototype method of the `WebAssembly.Table` object mutates a
8901        /// reference stored at a given index to a different value.
8902        ///
8903        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/set)
8904        #[wasm_bindgen(method, catch, js_namespace = WebAssembly, js_name = set)]
8905        pub fn set_raw(this: &Table, index: u32, value: &JsValue) -> Result<(), JsValue>;
8906    }
8907
8908    // WebAssembly.Tag
8909    #[wasm_bindgen]
8910    extern "C" {
8911        /// The `WebAssembly.Tag()` constructor creates a new `Tag` object
8912        ///
8913        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Tag)
8914        #[wasm_bindgen(js_namespace = WebAssembly, extends = Object, typescript_type = "WebAssembly.Tag")]
8915        #[derive(Clone, Debug, PartialEq, Eq)]
8916        pub type Tag;
8917
8918        /// The `WebAssembly.Tag()` constructor creates a new `Tag` object
8919        ///
8920        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Tag)
8921        #[wasm_bindgen(constructor, js_namespace = WebAssembly, catch)]
8922        pub fn new(tag_descriptor: &Object) -> Result<Tag, JsValue>;
8923    }
8924
8925    // WebAssembly.Exception
8926    #[wasm_bindgen]
8927    extern "C" {
8928        /// The `WebAssembly.Exception()` constructor creates a new `Exception` object
8929        ///
8930        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Exception)
8931        #[wasm_bindgen(js_namespace = WebAssembly, extends = Object, typescript_type = "WebAssembly.Exception")]
8932        #[derive(Clone, Debug, PartialEq, Eq)]
8933        pub type Exception;
8934
8935        /// The `WebAssembly.Exception()` constructor creates a new `Exception` object
8936        ///
8937        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Exception)
8938        #[wasm_bindgen(constructor, js_namespace = WebAssembly, catch)]
8939        pub fn new(tag: &Tag, payload: &Array) -> Result<Exception, JsValue>;
8940
8941        /// The `WebAssembly.Exception()` constructor creates a new `Exception` object
8942        ///
8943        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Exception)
8944        #[wasm_bindgen(constructor, js_namespace = WebAssembly, catch)]
8945        pub fn new_with_options(
8946            tag: &Tag,
8947            payload: &Array,
8948            options: &Object,
8949        ) -> Result<Exception, JsValue>;
8950
8951        /// The `is()` prototype method of the `WebAssembly.Exception` can be used to
8952        /// test if the Exception matches a given tag.
8953        ///
8954        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Exception/is)
8955        #[wasm_bindgen(method, js_namespace = WebAssembly)]
8956        pub fn is(this: &Exception, tag: &Tag) -> bool;
8957
8958        /// The `getArg()` prototype method of the `WebAssembly.Exception` can be used
8959        /// to get the value of a specified item in the exception's data arguments
8960        ///
8961        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Exception/getArg)
8962        #[wasm_bindgen(method, js_namespace = WebAssembly, js_name = getArg, catch)]
8963        pub fn get_arg(this: &Exception, tag: &Tag, index: u32) -> Result<JsValue, JsValue>;
8964    }
8965
8966    // WebAssembly.Global
8967    #[wasm_bindgen]
8968    extern "C" {
8969        /// The `WebAssembly.Global()` constructor creates a new `Global` object
8970        /// of the given type and value.
8971        ///
8972        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Global)
8973        #[wasm_bindgen(js_namespace = WebAssembly, extends = Object, typescript_type = "WebAssembly.Global")]
8974        #[derive(Clone, Debug, PartialEq, Eq)]
8975        pub type Global;
8976
8977        /// The `WebAssembly.Global()` constructor creates a new `Global` object
8978        /// of the given type and value.
8979        ///
8980        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Global)
8981        #[wasm_bindgen(constructor, js_namespace = WebAssembly, catch)]
8982        pub fn new(global_descriptor: &Object, value: &JsValue) -> Result<Global, JsValue>;
8983
8984        /// The value prototype property of the `WebAssembly.Global` object
8985        /// returns the value of the global.
8986        ///
8987        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Global)
8988        #[wasm_bindgen(method, getter, js_namespace = WebAssembly)]
8989        pub fn value(this: &Global) -> JsValue;
8990        #[wasm_bindgen(method, setter = value, js_namespace = WebAssembly)]
8991        pub fn set_value(this: &Global, value: &JsValue);
8992    }
8993
8994    // WebAssembly.Memory
8995    #[wasm_bindgen]
8996    extern "C" {
8997        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory)
8998        #[wasm_bindgen(js_namespace = WebAssembly, extends = Object, typescript_type = "WebAssembly.Memory")]
8999        #[derive(Clone, Debug, PartialEq, Eq)]
9000        pub type Memory;
9001
9002        /// The `WebAssembly.Memory()` constructor creates a new `Memory` object
9003        /// which is a resizable `ArrayBuffer` that holds the raw bytes of
9004        /// memory accessed by a WebAssembly `Instance`.
9005        ///
9006        /// A memory created by JavaScript or in WebAssembly code will be
9007        /// accessible and mutable from both JavaScript and WebAssembly.
9008        ///
9009        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory)
9010        #[wasm_bindgen(constructor, js_namespace = WebAssembly, catch)]
9011        pub fn new(descriptor: &Object) -> Result<Memory, JsValue>;
9012
9013        /// An accessor property that returns the buffer contained in the
9014        /// memory.
9015        ///
9016        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory/buffer)
9017        #[wasm_bindgen(method, getter, js_namespace = WebAssembly)]
9018        pub fn buffer(this: &Memory) -> JsValue;
9019
9020        /// The `grow()` prototype method of the `Memory` object increases the
9021        /// size of the memory instance by a specified number of WebAssembly
9022        /// pages.
9023        ///
9024        /// Takes the number of pages to grow (64KiB in size) and returns the
9025        /// previous size of memory, in pages.
9026        ///
9027        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory/grow)
9028        #[wasm_bindgen(method, js_namespace = WebAssembly)]
9029        pub fn grow(this: &Memory, pages: u32) -> u32;
9030    }
9031}
9032
9033/// The `JSON` object contains methods for parsing [JavaScript Object
9034/// Notation (JSON)](https://json.org/) and converting values to JSON. It
9035/// can't be called or constructed, and aside from its two method
9036/// properties, it has no interesting functionality of its own.
9037#[allow(non_snake_case)]
9038pub mod JSON {
9039    use super::*;
9040
9041    // JSON
9042    #[wasm_bindgen]
9043    extern "C" {
9044        /// The `JSON.parse()` method parses a JSON string, constructing the
9045        /// JavaScript value or object described by the string.
9046        ///
9047        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse)
9048        #[wasm_bindgen(catch, js_namespace = JSON)]
9049        pub fn parse(text: &str) -> Result<JsValue, JsValue>;
9050
9051        /// The `JSON.stringify()` method converts a JavaScript value to a JSON string.
9052        ///
9053        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)
9054        #[wasm_bindgen(catch, js_namespace = JSON)]
9055        pub fn stringify(obj: &JsValue) -> Result<JsString, JsValue>;
9056
9057        /// The `JSON.stringify()` method converts a JavaScript value to a JSON string.
9058        ///
9059        /// The `replacer` argument is a function that alters the behavior of the stringification
9060        /// process, or an array of String and Number objects that serve as a whitelist
9061        /// for selecting/filtering the properties of the value object to be included
9062        /// in the JSON string. If this value is null or not provided, all properties
9063        /// of the object are included in the resulting JSON string.
9064        ///
9065        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)
9066        #[cfg(not(js_sys_unstable_apis))]
9067        #[wasm_bindgen(catch, js_namespace = JSON, js_name = stringify)]
9068        pub fn stringify_with_replacer(
9069            obj: &JsValue,
9070            replacer: &JsValue,
9071        ) -> Result<JsString, JsValue>;
9072
9073        /// The `JSON.stringify()` method converts a JavaScript value to a JSON string.
9074        ///
9075        /// The `replacer` argument is a function that alters the behavior of the stringification
9076        /// process, or an array of String and Number objects that serve as a whitelist
9077        /// for selecting/filtering the properties of the value object to be included
9078        /// in the JSON string. If this value is null or not provided, all properties
9079        /// of the object are included in the resulting JSON string.
9080        ///
9081        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)
9082        #[cfg(js_sys_unstable_apis)]
9083        #[wasm_bindgen(catch, js_namespace = JSON, js_name = stringify)]
9084        pub fn stringify_with_replacer<'a>(
9085            obj: &JsValue,
9086            replacer: &mut dyn FnMut(JsString, JsValue) -> Result<Option<JsValue>, JsError>,
9087            space: Option<u32>,
9088        ) -> Result<JsString, JsValue>;
9089
9090        // Next major: deprecate
9091        /// The `JSON.stringify()` method converts a JavaScript value to a JSON string.
9092        ///
9093        /// The `replacer` argument is a function that alters the behavior of the stringification
9094        /// process, or an array of String and Number objects that serve as a whitelist
9095        /// for selecting/filtering the properties of the value object to be included
9096        /// in the JSON string. If this value is null or not provided, all properties
9097        /// of the object are included in the resulting JSON string.
9098        ///
9099        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)
9100        #[wasm_bindgen(catch, js_namespace = JSON, js_name = stringify)]
9101        pub fn stringify_with_replacer_func<'a>(
9102            obj: &JsValue,
9103            replacer: &mut dyn FnMut(JsString, JsValue) -> Result<Option<JsValue>, JsError>,
9104            space: Option<u32>,
9105        ) -> Result<JsString, JsValue>;
9106
9107        /// The `JSON.stringify()` method converts a JavaScript value to a JSON string.
9108        ///
9109        /// The `replacer` argument is a function that alters the behavior of the stringification
9110        /// process, or an array of String and Number objects that serve as a whitelist
9111        /// for selecting/filtering the properties of the value object to be included
9112        /// in the JSON string. If this value is null or not provided, all properties
9113        /// of the object are included in the resulting JSON string.
9114        ///
9115        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)
9116        #[wasm_bindgen(catch, js_namespace = JSON, js_name = stringify)]
9117        pub fn stringify_with_replacer_list(
9118            obj: &JsValue,
9119            replacer: Vec<String>,
9120            space: Option<u32>,
9121        ) -> Result<JsString, JsValue>;
9122
9123        // Next major: deprecate
9124        /// The `JSON.stringify()` method converts a JavaScript value to a JSON string.
9125        ///
9126        /// The `replacer` argument is a function that alters the behavior of the stringification
9127        /// process, or an array of String and Number objects that serve as a whitelist
9128        /// for selecting/filtering the properties of the value object to be included
9129        /// in the JSON string. If this value is null or not provided, all properties
9130        /// of the object are included in the resulting JSON string.
9131        ///
9132        /// The `space` argument is a String or Number object that's used to insert white space into
9133        /// the output JSON string for readability purposes. If this is a Number, it
9134        /// indicates the number of space characters to use as white space; this number
9135        /// is capped at 10 (if it is greater, the value is just 10). Values less than
9136        /// 1 indicate that no space should be used. If this is a String, the string
9137        /// (or the first 10 characters of the string, if it's longer than that) is
9138        /// used as white space. If this parameter is not provided (or is null), no
9139        /// white space is used.
9140        ///
9141        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)
9142        #[wasm_bindgen(catch, js_namespace = JSON, js_name = stringify)]
9143        pub fn stringify_with_replacer_and_space(
9144            obj: &JsValue,
9145            replacer: &JsValue,
9146            space: &JsValue,
9147        ) -> Result<JsString, JsValue>;
9148    }
9149}
9150// JsString
9151#[wasm_bindgen]
9152extern "C" {
9153    #[wasm_bindgen(js_name = String, extends = Object, is_type_of = JsValue::is_string, typescript_type = "string")]
9154    #[derive(Clone, PartialEq, Eq)]
9155    pub type JsString;
9156
9157    /// The length property of a String object indicates the length of a string,
9158    /// in UTF-16 code units.
9159    ///
9160    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length)
9161    #[wasm_bindgen(method, getter)]
9162    pub fn length(this: &JsString) -> u32;
9163
9164    /// The 'at()' method returns a new string consisting of the single UTF-16
9165    /// code unit located at the specified offset into the string, counting from
9166    /// the end if it's negative.
9167    ///
9168    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/at)
9169    #[wasm_bindgen(method, js_class = "String")]
9170    pub fn at(this: &JsString, index: i32) -> Option<JsString>;
9171
9172    /// The String object's `charAt()` method returns a new string consisting of
9173    /// the single UTF-16 code unit located at the specified offset into the
9174    /// string.
9175    ///
9176    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charAt)
9177    #[wasm_bindgen(method, js_class = "String", js_name = charAt)]
9178    pub fn char_at(this: &JsString, index: u32) -> JsString;
9179
9180    /// The `charCodeAt()` method returns an integer between 0 and 65535
9181    /// representing the UTF-16 code unit at the given index (the UTF-16 code
9182    /// unit matches the Unicode code point for code points representable in a
9183    /// single UTF-16 code unit, but might also be the first code unit of a
9184    /// surrogate pair for code points not representable in a single UTF-16 code
9185    /// unit, e.g. Unicode code points > 0x10000).  If you want the entire code
9186    /// point value, use `codePointAt()`.
9187    ///
9188    /// Returns `NaN` if index is out of range.
9189    ///
9190    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charCodeAt)
9191    #[wasm_bindgen(method, js_class = "String", js_name = charCodeAt)]
9192    pub fn char_code_at(this: &JsString, index: u32) -> f64;
9193
9194    /// The `codePointAt()` method returns a non-negative integer that is the
9195    /// Unicode code point value.
9196    ///
9197    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt)
9198    #[cfg(not(js_sys_unstable_apis))]
9199    #[wasm_bindgen(method, js_class = "String", js_name = codePointAt)]
9200    pub fn code_point_at(this: &JsString, pos: u32) -> JsValue;
9201
9202    /// The `codePointAt()` method returns a non-negative integer that is the
9203    /// Unicode code point value.
9204    ///
9205    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt)
9206    #[cfg(js_sys_unstable_apis)]
9207    #[wasm_bindgen(method, js_class = "String", js_name = codePointAt)]
9208    pub fn code_point_at(this: &JsString, pos: u32) -> Option<u32>;
9209
9210    // Next major: deprecate
9211    /// The `codePointAt()` method returns a non-negative integer that is the
9212    /// Unicode code point value.
9213    ///
9214    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt)
9215    #[wasm_bindgen(method, js_class = "String", js_name = codePointAt)]
9216    pub fn try_code_point_at(this: &JsString, pos: u32) -> Option<u16>;
9217
9218    /// The `concat()` method concatenates the string arguments to the calling
9219    /// string and returns a new string.
9220    ///
9221    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/concat)
9222    #[cfg(not(js_sys_unstable_apis))]
9223    #[wasm_bindgen(method, js_class = "String")]
9224    pub fn concat(this: &JsString, string_2: &JsValue) -> JsString;
9225
9226    /// The `concat()` method concatenates the string arguments to the calling
9227    /// string and returns a new string.
9228    ///
9229    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/concat)
9230    #[cfg(js_sys_unstable_apis)]
9231    #[wasm_bindgen(method, js_class = "String")]
9232    pub fn concat(this: &JsString, string: &JsString) -> JsString;
9233
9234    /// The `concat()` method concatenates the string arguments to the calling
9235    /// string and returns a new string.
9236    ///
9237    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/concat)
9238    #[wasm_bindgen(method, js_class = "String")]
9239    pub fn concat_many(this: &JsString, strings: &[JsString]) -> JsString;
9240
9241    /// The `endsWith()` method determines whether a string ends with the characters of a
9242    /// specified string, returning true or false as appropriate.
9243    ///
9244    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith)
9245    #[cfg(not(js_sys_unstable_apis))]
9246    #[wasm_bindgen(method, js_class = "String", js_name = endsWith)]
9247    pub fn ends_with(this: &JsString, search_string: &str, length: i32) -> bool;
9248
9249    /// The `endsWith()` method determines whether a string ends with the characters of a
9250    /// specified string, returning true or false as appropriate.
9251    ///
9252    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith)
9253    #[cfg(js_sys_unstable_apis)]
9254    #[wasm_bindgen(method, js_class = "String", js_name = endsWith)]
9255    pub fn ends_with(this: &JsString, search_string: &str) -> bool;
9256
9257    /// The static `String.fromCharCode()` method returns a string created from
9258    /// the specified sequence of UTF-16 code units.
9259    ///
9260    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
9261    ///
9262    /// # Notes
9263    ///
9264    /// There are a few bindings to `from_char_code` in `js-sys`: `from_char_code1`, `from_char_code2`, etc...
9265    /// with different arities.
9266    #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode, variadic)]
9267    pub fn from_char_code(char_codes: &[u16]) -> JsString;
9268
9269    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
9270    #[cfg(not(js_sys_unstable_apis))]
9271    #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)]
9272    pub fn from_char_code1(a: u32) -> JsString;
9273
9274    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
9275    #[cfg(js_sys_unstable_apis)]
9276    #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)]
9277    pub fn from_char_code1(a: u16) -> JsString;
9278
9279    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
9280    #[cfg(not(js_sys_unstable_apis))]
9281    #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)]
9282    pub fn from_char_code2(a: u32, b: u32) -> JsString;
9283
9284    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
9285    #[cfg(js_sys_unstable_apis)]
9286    #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)]
9287    pub fn from_char_code2(a: u16, b: u16) -> JsString;
9288
9289    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
9290    #[cfg(not(js_sys_unstable_apis))]
9291    #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)]
9292    pub fn from_char_code3(a: u32, b: u32, c: u32) -> JsString;
9293
9294    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
9295    #[cfg(js_sys_unstable_apis)]
9296    #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)]
9297    pub fn from_char_code3(a: u16, b: u16, c: u16) -> JsString;
9298
9299    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
9300    #[cfg(not(js_sys_unstable_apis))]
9301    #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)]
9302    pub fn from_char_code4(a: u32, b: u32, c: u32, d: u32) -> JsString;
9303
9304    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
9305    #[cfg(js_sys_unstable_apis)]
9306    #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)]
9307    pub fn from_char_code4(a: u16, b: u16, c: u16, d: u16) -> JsString;
9308
9309    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
9310    #[cfg(not(js_sys_unstable_apis))]
9311    #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)]
9312    pub fn from_char_code5(a: u32, b: u32, c: u32, d: u32, e: u32) -> JsString;
9313
9314    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
9315    #[cfg(js_sys_unstable_apis)]
9316    #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)]
9317    pub fn from_char_code5(a: u16, b: u16, c: u16, d: u16, e: u16) -> JsString;
9318
9319    /// The static `String.fromCodePoint()` method returns a string created by
9320    /// using the specified sequence of code points.
9321    ///
9322    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)
9323    ///
9324    /// # Exceptions
9325    ///
9326    /// A RangeError is thrown if an invalid Unicode code point is given
9327    ///
9328    /// # Notes
9329    ///
9330    /// There are a few bindings to `from_code_point` in `js-sys`: `from_code_point1`, `from_code_point2`, etc...
9331    /// with different arities.
9332    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = fromCodePoint, variadic)]
9333    pub fn from_code_point(code_points: &[u32]) -> Result<JsString, JsValue>;
9334
9335    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)
9336    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = fromCodePoint)]
9337    pub fn from_code_point1(a: u32) -> Result<JsString, JsValue>;
9338
9339    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)
9340    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = fromCodePoint)]
9341    pub fn from_code_point2(a: u32, b: u32) -> Result<JsString, JsValue>;
9342
9343    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)
9344    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = fromCodePoint)]
9345    pub fn from_code_point3(a: u32, b: u32, c: u32) -> Result<JsString, JsValue>;
9346
9347    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)
9348    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = fromCodePoint)]
9349    pub fn from_code_point4(a: u32, b: u32, c: u32, d: u32) -> Result<JsString, JsValue>;
9350
9351    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)
9352    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = fromCodePoint)]
9353    pub fn from_code_point5(a: u32, b: u32, c: u32, d: u32, e: u32) -> Result<JsString, JsValue>;
9354
9355    /// The `includes()` method determines whether one string may be found
9356    /// within another string, returning true or false as appropriate.
9357    ///
9358    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes)
9359    #[wasm_bindgen(method, js_class = "String")]
9360    pub fn includes(this: &JsString, search_string: &str, position: i32) -> bool;
9361
9362    /// The `indexOf()` method returns the index within the calling String
9363    /// object of the first occurrence of the specified value, starting the
9364    /// search at fromIndex.  Returns -1 if the value is not found.
9365    ///
9366    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf)
9367    #[wasm_bindgen(method, js_class = "String", js_name = indexOf)]
9368    pub fn index_of(this: &JsString, search_value: &str, from_index: i32) -> i32;
9369
9370    /// The `lastIndexOf()` method returns the index within the calling String
9371    /// object of the last occurrence of the specified value, searching
9372    /// backwards from fromIndex.  Returns -1 if the value is not found.
9373    ///
9374    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/lastIndexOf)
9375    #[wasm_bindgen(method, js_class = "String", js_name = lastIndexOf)]
9376    pub fn last_index_of(this: &JsString, search_value: &str, from_index: i32) -> i32;
9377
9378    /// The `localeCompare()` method returns a number indicating whether
9379    /// a reference string comes before or after or is the same as
9380    /// the given string in sort order.
9381    ///
9382    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare)
9383    #[cfg(not(js_sys_unstable_apis))]
9384    #[wasm_bindgen(method, js_class = "String", js_name = localeCompare)]
9385    pub fn locale_compare(
9386        this: &JsString,
9387        compare_string: &str,
9388        locales: &Array,
9389        options: &Object,
9390    ) -> i32;
9391
9392    /// The `localeCompare()` method returns a number indicating whether
9393    /// a reference string comes before or after or is the same as
9394    /// the given string in sort order.
9395    ///
9396    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare)
9397    #[cfg(js_sys_unstable_apis)]
9398    #[wasm_bindgen(method, js_class = "String", js_name = localeCompare)]
9399    pub fn locale_compare(
9400        this: &JsString,
9401        compare_string: &str,
9402        locales: &[JsString],
9403        options: &Intl::CollatorOptions,
9404    ) -> i32;
9405
9406    /// The `match()` method retrieves the matches when matching a string against a regular expression.
9407    ///
9408    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match)
9409    #[wasm_bindgen(method, js_class = "String", js_name = match)]
9410    pub fn match_(this: &JsString, pattern: &RegExp) -> Option<Object>;
9411
9412    /// The `match_all()` method is similar to `match()`, but gives an iterator of `exec()` arrays, which preserve capture groups.
9413    ///
9414    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/matchAll)
9415    #[cfg(not(js_sys_unstable_apis))]
9416    #[wasm_bindgen(method, js_class = "String", js_name = matchAll)]
9417    pub fn match_all(this: &JsString, pattern: &RegExp) -> Iterator;
9418
9419    /// The `match_all()` method is similar to `match()`, but gives an iterator of `exec()` arrays, which preserve capture groups.
9420    ///
9421    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/matchAll)
9422    #[cfg(js_sys_unstable_apis)]
9423    #[wasm_bindgen(method, js_class = "String", js_name = matchAll)]
9424    pub fn match_all(this: &JsString, pattern: &RegExp) -> Iterator<RegExpMatchArray>;
9425
9426    /// The `normalize()` method returns the Unicode Normalization Form
9427    /// of a given string (if the value isn't a string, it will be converted to one first).
9428    ///
9429    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize)
9430    #[wasm_bindgen(method, js_class = "String")]
9431    pub fn normalize(this: &JsString, form: &str) -> JsString;
9432
9433    /// The `padEnd()` method pads the current string with a given string
9434    /// (repeated, if needed) so that the resulting string reaches a given
9435    /// length. The padding is applied from the end (right) of the current
9436    /// string.
9437    ///
9438    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padEnd)
9439    #[wasm_bindgen(method, js_class = "String", js_name = padEnd)]
9440    pub fn pad_end(this: &JsString, target_length: u32, pad_string: &str) -> JsString;
9441
9442    /// The `padStart()` method pads the current string with another string
9443    /// (repeated, if needed) so that the resulting string reaches the given
9444    /// length. The padding is applied from the start (left) of the current
9445    /// string.
9446    ///
9447    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padStart)
9448    #[wasm_bindgen(method, js_class = "String", js_name = padStart)]
9449    pub fn pad_start(this: &JsString, target_length: u32, pad_string: &str) -> JsString;
9450
9451    /// The `repeat()` method constructs and returns a new string which contains the specified
9452    /// number of copies of the string on which it was called, concatenated together.
9453    ///
9454    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat)
9455    #[wasm_bindgen(method, js_class = "String")]
9456    pub fn repeat(this: &JsString, count: i32) -> JsString;
9457
9458    /// The `replace()` method returns a new string with some or all matches of a pattern
9459    /// replaced by a replacement. The pattern can be a string or a RegExp, and
9460    /// the replacement can be a string or a function to be called for each match.
9461    ///
9462    /// Note: The original string will remain unchanged.
9463    ///
9464    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace)
9465    #[wasm_bindgen(method, js_class = "String")]
9466    pub fn replace(this: &JsString, pattern: &str, replacement: &str) -> JsString;
9467
9468    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace)
9469    #[cfg(not(js_sys_unstable_apis))]
9470    #[wasm_bindgen(method, js_class = "String", js_name = replace)]
9471    pub fn replace_with_function(
9472        this: &JsString,
9473        pattern: &str,
9474        replacement: &Function,
9475    ) -> JsString;
9476
9477    /// The replacer function signature is `(match, offset, string) -> replacement`
9478    /// for patterns without capture groups, or `(match, p1, p2, ..., pN, offset, string, groups) -> replacement`
9479    /// when capture groups are present.
9480    ///
9481    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace)
9482    #[cfg(js_sys_unstable_apis)]
9483    #[wasm_bindgen(method, js_class = "String", js_name = replace)]
9484    pub fn replace_with_function(
9485        this: &JsString,
9486        pattern: &str,
9487        replacement: &Function<fn(JsString) -> JsString>,
9488    ) -> JsString;
9489
9490    #[wasm_bindgen(method, js_class = "String", js_name = replace)]
9491    pub fn replace_by_pattern(this: &JsString, pattern: &RegExp, replacement: &str) -> JsString;
9492
9493    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace)
9494    #[cfg(not(js_sys_unstable_apis))]
9495    #[wasm_bindgen(method, js_class = "String", js_name = replace)]
9496    pub fn replace_by_pattern_with_function(
9497        this: &JsString,
9498        pattern: &RegExp,
9499        replacement: &Function,
9500    ) -> JsString;
9501
9502    /// The replacer function signature is `(match, offset, string) -> replacement`
9503    /// for patterns without capture groups, or `(match, p1, p2, ..., pN, offset, string, groups) -> replacement`
9504    /// when capture groups are present.
9505    ///
9506    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace)
9507    #[cfg(js_sys_unstable_apis)]
9508    #[wasm_bindgen(method, js_class = "String", js_name = replace)]
9509    pub fn replace_by_pattern_with_function(
9510        this: &JsString,
9511        pattern: &RegExp,
9512        replacement: &Function<fn(JsString) -> JsString>,
9513    ) -> JsString;
9514
9515    /// The `replace_all()` method returns a new string with all matches of a pattern
9516    /// replaced by a replacement. The pattern can be a string or a global RegExp, and
9517    /// the replacement can be a string or a function to be called for each match.
9518    ///
9519    /// Note: The original string will remain unchanged.
9520    ///
9521    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replaceAll)
9522    #[wasm_bindgen(method, js_class = "String", js_name = replaceAll)]
9523    pub fn replace_all(this: &JsString, pattern: &str, replacement: &str) -> JsString;
9524
9525    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replaceAll)
9526    #[cfg(not(js_sys_unstable_apis))]
9527    #[wasm_bindgen(method, js_class = "String", js_name = replaceAll)]
9528    pub fn replace_all_with_function(
9529        this: &JsString,
9530        pattern: &str,
9531        replacement: &Function,
9532    ) -> JsString;
9533
9534    /// The replacer function signature is `(match, offset, string) -> replacement`
9535    /// for patterns without capture groups, or `(match, p1, p2, ..., pN, offset, string, groups) -> replacement`
9536    /// when capture groups are present.
9537    ///
9538    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replaceAll)
9539    #[cfg(js_sys_unstable_apis)]
9540    #[wasm_bindgen(method, js_class = "String", js_name = replaceAll)]
9541    pub fn replace_all_with_function(
9542        this: &JsString,
9543        pattern: &str,
9544        replacement: &Function<fn(JsString) -> JsString>,
9545    ) -> JsString;
9546
9547    #[wasm_bindgen(method, js_class = "String", js_name = replaceAll)]
9548    pub fn replace_all_by_pattern(this: &JsString, pattern: &RegExp, replacement: &str)
9549        -> JsString;
9550
9551    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replaceAll)
9552    #[cfg(not(js_sys_unstable_apis))]
9553    #[wasm_bindgen(method, js_class = "String", js_name = replaceAll)]
9554    pub fn replace_all_by_pattern_with_function(
9555        this: &JsString,
9556        pattern: &RegExp,
9557        replacement: &Function,
9558    ) -> JsString;
9559
9560    /// The replacer function signature is `(match, offset, string) -> replacement`
9561    /// for patterns without capture groups, or `(match, p1, p2, ..., pN, offset, string, groups) -> replacement`
9562    /// when capture groups are present.
9563    ///
9564    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replaceAll)
9565    #[cfg(js_sys_unstable_apis)]
9566    #[wasm_bindgen(method, js_class = "String", js_name = replaceAll)]
9567    pub fn replace_all_by_pattern_with_function(
9568        this: &JsString,
9569        pattern: &RegExp,
9570        replacement: &Function<fn(JsString) -> JsString>,
9571    ) -> JsString;
9572
9573    /// The `search()` method executes a search for a match between
9574    /// a regular expression and this String object.
9575    ///
9576    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/search)
9577    #[wasm_bindgen(method, js_class = "String")]
9578    pub fn search(this: &JsString, pattern: &RegExp) -> i32;
9579
9580    /// The `slice()` method extracts a section of a string and returns it as a
9581    /// new string, without modifying the original string.
9582    ///
9583    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice)
9584    #[wasm_bindgen(method, js_class = "String")]
9585    pub fn slice(this: &JsString, start: u32, end: u32) -> JsString;
9586
9587    /// The `split()` method splits a String object into an array of strings by separating the string
9588    /// into substrings, using a specified separator string to determine where to make each split.
9589    ///
9590    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split)
9591    #[wasm_bindgen(method, js_class = "String")]
9592    pub fn split(this: &JsString, separator: &str) -> Array;
9593
9594    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split)
9595    #[wasm_bindgen(method, js_class = "String", js_name = split)]
9596    pub fn split_limit(this: &JsString, separator: &str, limit: u32) -> Array;
9597
9598    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split)
9599    #[wasm_bindgen(method, js_class = "String", js_name = split)]
9600    pub fn split_by_pattern(this: &JsString, pattern: &RegExp) -> Array;
9601
9602    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split)
9603    #[wasm_bindgen(method, js_class = "String", js_name = split)]
9604    pub fn split_by_pattern_limit(this: &JsString, pattern: &RegExp, limit: u32) -> Array;
9605
9606    /// The `startsWith()` method determines whether a string begins with the
9607    /// characters of a specified string, returning true or false as
9608    /// appropriate.
9609    ///
9610    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith)
9611    #[wasm_bindgen(method, js_class = "String", js_name = startsWith)]
9612    pub fn starts_with(this: &JsString, search_string: &str, position: u32) -> bool;
9613
9614    /// The `substring()` method returns the part of the string between the
9615    /// start and end indexes, or to the end of the string.
9616    ///
9617    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring)
9618    #[wasm_bindgen(method, js_class = "String")]
9619    pub fn substring(this: &JsString, index_start: u32, index_end: u32) -> JsString;
9620
9621    /// The `substr()` method returns the part of a string between
9622    /// the start index and a number of characters after it.
9623    ///
9624    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr)
9625    #[wasm_bindgen(method, js_class = "String")]
9626    pub fn substr(this: &JsString, start: i32, length: i32) -> JsString;
9627
9628    /// The `toLocaleLowerCase()` method returns the calling string value converted to lower case,
9629    /// according to any locale-specific case mappings.
9630    ///
9631    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase)
9632    #[wasm_bindgen(method, js_class = "String", js_name = toLocaleLowerCase)]
9633    pub fn to_locale_lower_case(this: &JsString, locale: Option<&str>) -> JsString;
9634
9635    /// The `toLocaleUpperCase()` method returns the calling string value converted to upper case,
9636    /// according to any locale-specific case mappings.
9637    ///
9638    /// [MDN documentation](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleUpperCase)
9639    #[wasm_bindgen(method, js_class = "String", js_name = toLocaleUpperCase)]
9640    pub fn to_locale_upper_case(this: &JsString, locale: Option<&str>) -> JsString;
9641
9642    /// The `toLowerCase()` method returns the calling string value
9643    /// converted to lower case.
9644    ///
9645    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLowerCase)
9646    #[wasm_bindgen(method, js_class = "String", js_name = toLowerCase)]
9647    pub fn to_lower_case(this: &JsString) -> JsString;
9648
9649    /// The `toString()` method returns a string representing the specified
9650    /// object.
9651    ///
9652    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toString)
9653    #[cfg(not(js_sys_unstable_apis))]
9654    #[wasm_bindgen(method, js_class = "String", js_name = toString)]
9655    pub fn to_string(this: &JsString) -> JsString;
9656
9657    /// The `toUpperCase()` method returns the calling string value converted to
9658    /// uppercase (the value will be converted to a string if it isn't one).
9659    ///
9660    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase)
9661    #[wasm_bindgen(method, js_class = "String", js_name = toUpperCase)]
9662    pub fn to_upper_case(this: &JsString) -> JsString;
9663
9664    /// The `trim()` method removes whitespace from both ends of a string.
9665    /// Whitespace in this context is all the whitespace characters (space, tab,
9666    /// no-break space, etc.) and all the line terminator characters (LF, CR,
9667    /// etc.).
9668    ///
9669    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trim)
9670    #[wasm_bindgen(method, js_class = "String")]
9671    pub fn trim(this: &JsString) -> JsString;
9672
9673    /// The `trimEnd()` method removes whitespace from the end of a string.
9674    /// `trimRight()` is an alias of this method.
9675    ///
9676    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimEnd)
9677    #[wasm_bindgen(method, js_class = "String", js_name = trimEnd)]
9678    pub fn trim_end(this: &JsString) -> JsString;
9679
9680    /// The `trimEnd()` method removes whitespace from the end of a string.
9681    /// `trimRight()` is an alias of this method.
9682    ///
9683    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimEnd)
9684    #[wasm_bindgen(method, js_class = "String", js_name = trimRight)]
9685    pub fn trim_right(this: &JsString) -> JsString;
9686
9687    /// The `trimStart()` method removes whitespace from the beginning of a
9688    /// string. `trimLeft()` is an alias of this method.
9689    ///
9690    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimStart)
9691    #[wasm_bindgen(method, js_class = "String", js_name = trimStart)]
9692    pub fn trim_start(this: &JsString) -> JsString;
9693
9694    /// The `trimStart()` method removes whitespace from the beginning of a
9695    /// string. `trimLeft()` is an alias of this method.
9696    ///
9697    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimStart)
9698    #[wasm_bindgen(method, js_class = "String", js_name = trimLeft)]
9699    pub fn trim_left(this: &JsString) -> JsString;
9700
9701    /// The `valueOf()` method returns the primitive value of a `String` object.
9702    ///
9703    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/valueOf)
9704    #[wasm_bindgen(method, js_class = "String", js_name = valueOf)]
9705    pub fn value_of(this: &JsString) -> JsString;
9706
9707    /// The static `raw()` method is a tag function of template literals,
9708    /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
9709    ///
9710    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
9711    #[wasm_bindgen(catch, variadic, static_method_of = JsString, js_class = "String")]
9712    pub fn raw(call_site: &Object, substitutions: &Array) -> Result<JsString, JsValue>;
9713
9714    /// The static `raw()` method is a tag function of template literals,
9715    /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
9716    ///
9717    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
9718    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = raw)]
9719    pub fn raw_0(call_site: &Object) -> Result<JsString, JsValue>;
9720
9721    /// The static `raw()` method is a tag function of template literals,
9722    /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
9723    ///
9724    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
9725    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = raw)]
9726    pub fn raw_1(call_site: &Object, substitutions_1: &str) -> Result<JsString, JsValue>;
9727
9728    /// The static `raw()` method is a tag function of template literals,
9729    /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
9730    ///
9731    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
9732    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = raw)]
9733    pub fn raw_2(
9734        call_site: &Object,
9735        substitutions1: &str,
9736        substitutions2: &str,
9737    ) -> Result<JsString, JsValue>;
9738
9739    /// The static `raw()` method is a tag function of template literals,
9740    /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
9741    ///
9742    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
9743    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = raw)]
9744    pub fn raw_3(
9745        call_site: &Object,
9746        substitutions1: &str,
9747        substitutions2: &str,
9748        substitutions3: &str,
9749    ) -> Result<JsString, JsValue>;
9750
9751    /// The static `raw()` method is a tag function of template literals,
9752    /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
9753    ///
9754    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
9755    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = raw)]
9756    pub fn raw_4(
9757        call_site: &Object,
9758        substitutions1: &str,
9759        substitutions2: &str,
9760        substitutions3: &str,
9761        substitutions4: &str,
9762    ) -> Result<JsString, JsValue>;
9763
9764    /// The static `raw()` method is a tag function of template literals,
9765    /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
9766    ///
9767    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
9768    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = raw)]
9769    pub fn raw_5(
9770        call_site: &Object,
9771        substitutions1: &str,
9772        substitutions2: &str,
9773        substitutions3: &str,
9774        substitutions4: &str,
9775        substitutions5: &str,
9776    ) -> Result<JsString, JsValue>;
9777
9778    /// The static `raw()` method is a tag function of template literals,
9779    /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
9780    ///
9781    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
9782    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = raw)]
9783    pub fn raw_6(
9784        call_site: &Object,
9785        substitutions1: &str,
9786        substitutions2: &str,
9787        substitutions3: &str,
9788        substitutions4: &str,
9789        substitutions5: &str,
9790        substitutions6: &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_7(
9799        call_site: &Object,
9800        substitutions1: &str,
9801        substitutions2: &str,
9802        substitutions3: &str,
9803        substitutions4: &str,
9804        substitutions5: &str,
9805        substitutions6: &str,
9806        substitutions7: &str,
9807    ) -> Result<JsString, JsValue>;
9808}
9809
9810// These upcasts are non-castable due to the constraints on the function
9811// but the UpcastFrom covariance must still extend through closure types.
9812// (impl UpcastFrom really just means CovariantGeneric relation)
9813impl UpcastFrom<String> for JsString {}
9814impl UpcastFrom<JsString> for String {}
9815
9816impl UpcastFrom<&str> for JsString {}
9817impl UpcastFrom<JsString> for &str {}
9818
9819impl UpcastFrom<char> for JsString {}
9820impl UpcastFrom<JsString> for char {}
9821
9822impl JsString {
9823    /// Returns the `JsString` value of this JS value if it's an instance of a
9824    /// string.
9825    ///
9826    /// If this JS value is not an instance of a string then this returns
9827    /// `None`.
9828    #[cfg(not(js_sys_unstable_apis))]
9829    #[deprecated(note = "recommended to use dyn_ref instead which is now equivalent")]
9830    pub fn try_from(val: &JsValue) -> Option<&JsString> {
9831        val.dyn_ref()
9832    }
9833
9834    /// Returns whether this string is a valid UTF-16 string.
9835    ///
9836    /// This is useful for learning whether `String::from(..)` will return a
9837    /// lossless representation of the JS string. If this string contains
9838    /// unpaired surrogates then `String::from` will succeed but it will be a
9839    /// lossy representation of the JS string because unpaired surrogates will
9840    /// become replacement characters.
9841    ///
9842    /// If this function returns `false` then to get a lossless representation
9843    /// of the string you'll need to manually use the `iter` method (or the
9844    /// `char_code_at` accessor) to view the raw character codes.
9845    ///
9846    /// For more information, see the documentation on [JS strings vs Rust
9847    /// strings][docs]
9848    ///
9849    /// [docs]: https://wasm-bindgen.github.io/wasm-bindgen/reference/types/str.html
9850    pub fn is_valid_utf16(&self) -> bool {
9851        core::char::decode_utf16(self.iter()).all(|i| i.is_ok())
9852    }
9853
9854    /// Returns an iterator over the `u16` character codes that make up this JS
9855    /// string.
9856    ///
9857    /// This method will call `char_code_at` for each code in this JS string,
9858    /// returning an iterator of the codes in sequence.
9859    pub fn iter(
9860        &self,
9861    ) -> impl ExactSizeIterator<Item = u16> + DoubleEndedIterator<Item = u16> + '_ {
9862        (0..self.length()).map(move |i| self.char_code_at(i) as u16)
9863    }
9864
9865    /// If this string consists of a single Unicode code point, then this method
9866    /// converts it into a Rust `char` without doing any allocations.
9867    ///
9868    /// If this JS value is not a valid UTF-8 or consists of more than a single
9869    /// codepoint, then this returns `None`.
9870    ///
9871    /// Note that a single Unicode code point might be represented as more than
9872    /// one code unit on the JavaScript side. For example, a JavaScript string
9873    /// `"\uD801\uDC37"` is actually a single Unicode code point U+10437 which
9874    /// corresponds to a character '𐐷'.
9875    pub fn as_char(&self) -> Option<char> {
9876        let len = self.length();
9877
9878        if len == 0 || len > 2 {
9879            return None;
9880        }
9881
9882        #[cfg(not(js_sys_unstable_apis))]
9883        let cp = self.code_point_at(0).as_f64().unwrap_throw() as u32;
9884        #[cfg(js_sys_unstable_apis)]
9885        let cp = self.code_point_at(0)?;
9886
9887        let c = core::char::from_u32(cp)?;
9888
9889        if c.len_utf16() as u32 == len {
9890            Some(c)
9891        } else {
9892            None
9893        }
9894    }
9895}
9896
9897impl PartialEq<str> for JsString {
9898    #[allow(clippy::cmp_owned)] // prevent infinite recursion
9899    fn eq(&self, other: &str) -> bool {
9900        String::from(self) == other
9901    }
9902}
9903
9904impl<'a> PartialEq<&'a str> for JsString {
9905    fn eq(&self, other: &&'a str) -> bool {
9906        <JsString as PartialEq<str>>::eq(self, other)
9907    }
9908}
9909
9910impl PartialEq<String> for JsString {
9911    fn eq(&self, other: &String) -> bool {
9912        <JsString as PartialEq<str>>::eq(self, other)
9913    }
9914}
9915
9916impl<'a> PartialEq<&'a String> for JsString {
9917    fn eq(&self, other: &&'a String) -> bool {
9918        <JsString as PartialEq<str>>::eq(self, other)
9919    }
9920}
9921
9922impl Default for JsString {
9923    fn default() -> Self {
9924        Self::from("")
9925    }
9926}
9927
9928impl<'a> From<&'a str> for JsString {
9929    fn from(s: &'a str) -> Self {
9930        JsString::unchecked_from_js(JsValue::from_str(s))
9931    }
9932}
9933
9934impl From<String> for JsString {
9935    fn from(s: String) -> Self {
9936        From::from(&*s)
9937    }
9938}
9939
9940impl From<char> for JsString {
9941    #[inline]
9942    fn from(c: char) -> Self {
9943        JsString::from_code_point1(c as u32).unwrap_throw()
9944    }
9945}
9946
9947impl<'a> From<&'a JsString> for String {
9948    fn from(s: &'a JsString) -> Self {
9949        s.obj.as_string().unwrap_throw()
9950    }
9951}
9952
9953impl From<JsString> for String {
9954    fn from(s: JsString) -> Self {
9955        From::from(&s)
9956    }
9957}
9958
9959impl fmt::Debug for JsString {
9960    #[inline]
9961    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
9962        fmt::Debug::fmt(&String::from(self), f)
9963    }
9964}
9965
9966impl fmt::Display for JsString {
9967    #[inline]
9968    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
9969        fmt::Display::fmt(&String::from(self), f)
9970    }
9971}
9972
9973impl str::FromStr for JsString {
9974    type Err = convert::Infallible;
9975    fn from_str(s: &str) -> Result<Self, Self::Err> {
9976        Ok(JsString::from(s))
9977    }
9978}
9979
9980// Symbol
9981#[wasm_bindgen]
9982extern "C" {
9983    #[wasm_bindgen(is_type_of = JsValue::is_symbol, typescript_type = "Symbol")]
9984    #[derive(Clone, Debug)]
9985    pub type Symbol;
9986
9987    /// The `Symbol.hasInstance` well-known symbol is used to determine
9988    /// if a constructor object recognizes an object as its instance.
9989    /// The `instanceof` operator's behavior can be customized by this symbol.
9990    ///
9991    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/hasInstance)
9992    #[wasm_bindgen(static_method_of = Symbol, getter, js_name = hasInstance)]
9993    pub fn has_instance() -> Symbol;
9994
9995    /// The `Symbol.isConcatSpreadable` well-known symbol is used to configure
9996    /// if an object should be flattened to its array elements when using the
9997    /// `Array.prototype.concat()` method.
9998    ///
9999    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/isConcatSpreadable)
10000    #[wasm_bindgen(static_method_of = Symbol, getter, js_name = isConcatSpreadable)]
10001    pub fn is_concat_spreadable() -> Symbol;
10002
10003    /// The `Symbol.asyncIterator` well-known symbol specifies the default AsyncIterator for an object.
10004    /// If this property is set on an object, it is an async iterable and can be used in a `for await...of` loop.
10005    ///
10006    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/asyncIterator)
10007    #[wasm_bindgen(static_method_of = Symbol, getter, js_name = asyncIterator)]
10008    pub fn async_iterator() -> Symbol;
10009
10010    /// The `Symbol.iterator` well-known symbol specifies the default iterator
10011    /// for an object.  Used by `for...of`.
10012    ///
10013    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/iterator)
10014    #[wasm_bindgen(static_method_of = Symbol, getter)]
10015    pub fn iterator() -> Symbol;
10016
10017    /// The `Symbol.match` well-known symbol specifies the matching of a regular
10018    /// expression against a string. This function is called by the
10019    /// `String.prototype.match()` method.
10020    ///
10021    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/match)
10022    #[wasm_bindgen(static_method_of = Symbol, getter, js_name = match)]
10023    pub fn match_() -> Symbol;
10024
10025    /// The `Symbol.replace` well-known symbol specifies the method that
10026    /// replaces matched substrings of a string.  This function is called by the
10027    /// `String.prototype.replace()` method.
10028    ///
10029    /// For more information, see `RegExp.prototype[@@replace]()` and
10030    /// `String.prototype.replace()`.
10031    ///
10032    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/replace)
10033    #[wasm_bindgen(static_method_of = Symbol, getter)]
10034    pub fn replace() -> Symbol;
10035
10036    /// The `Symbol.search` well-known symbol specifies the method that returns
10037    /// the index within a string that matches the regular expression.  This
10038    /// function is called by the `String.prototype.search()` method.
10039    ///
10040    /// For more information, see `RegExp.prototype[@@search]()` and
10041    /// `String.prototype.search()`.
10042    ///
10043    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/search)
10044    #[wasm_bindgen(static_method_of = Symbol, getter)]
10045    pub fn search() -> Symbol;
10046
10047    /// The well-known symbol `Symbol.species` specifies a function-valued
10048    /// property that the constructor function uses to create derived objects.
10049    ///
10050    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/species)
10051    #[wasm_bindgen(static_method_of = Symbol, getter)]
10052    pub fn species() -> Symbol;
10053
10054    /// The `Symbol.split` well-known symbol specifies the method that splits a
10055    /// string at the indices that match a regular expression.  This function is
10056    /// called by the `String.prototype.split()` method.
10057    ///
10058    /// For more information, see `RegExp.prototype[@@split]()` and
10059    /// `String.prototype.split()`.
10060    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/split)
10061    #[wasm_bindgen(static_method_of = Symbol, getter)]
10062    pub fn split() -> Symbol;
10063
10064    /// The `Symbol.toPrimitive` is a symbol that specifies a function valued
10065    /// property that is called to convert an object to a corresponding
10066    /// primitive value.
10067    ///
10068    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toPrimitive)
10069    #[wasm_bindgen(static_method_of = Symbol, getter, js_name = toPrimitive)]
10070    pub fn to_primitive() -> Symbol;
10071
10072    /// The `Symbol.toStringTag` well-known symbol is a string valued property
10073    /// that is used in the creation of the default string description of an
10074    /// object.  It is accessed internally by the `Object.prototype.toString()`
10075    /// method.
10076    ///
10077    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toString)
10078    #[wasm_bindgen(static_method_of = Symbol, getter, js_name = toStringTag)]
10079    pub fn to_string_tag() -> Symbol;
10080
10081    /// The `Symbol.for(key)` method searches for existing symbols in a runtime-wide symbol registry with
10082    /// the given key and returns it if found.
10083    /// Otherwise a new symbol gets created in the global symbol registry with this key.
10084    ///
10085    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/for)
10086    #[wasm_bindgen(static_method_of = Symbol, js_name = for)]
10087    pub fn for_(key: &str) -> Symbol;
10088
10089    /// The `Symbol.keyFor(sym)` method retrieves a shared symbol key from the global symbol registry for the given symbol.
10090    ///
10091    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/keyFor)
10092    #[wasm_bindgen(static_method_of = Symbol, js_name = keyFor)]
10093    pub fn key_for(sym: &Symbol) -> JsValue;
10094
10095    // Next major: deprecate
10096    /// The `toString()` method returns a string representing the specified Symbol object.
10097    ///
10098    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toString)
10099    #[wasm_bindgen(method, js_name = toString)]
10100    pub fn to_string(this: &Symbol) -> JsString;
10101
10102    /// The `toString()` method returns a string representing the specified Symbol object.
10103    ///
10104    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toString)
10105    #[wasm_bindgen(method, js_name = toString)]
10106    pub fn to_js_string(this: &Symbol) -> JsString;
10107
10108    /// The `Symbol.unscopables` well-known symbol is used to specify an object
10109    /// value of whose own and inherited property names are excluded from the
10110    /// with environment bindings of the associated object.
10111    ///
10112    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/unscopables)
10113    #[wasm_bindgen(static_method_of = Symbol, getter)]
10114    pub fn unscopables() -> Symbol;
10115
10116    /// The `valueOf()` method returns the primitive value of a Symbol object.
10117    ///
10118    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/valueOf)
10119    #[wasm_bindgen(method, js_name = valueOf)]
10120    pub fn value_of(this: &Symbol) -> Symbol;
10121}
10122
10123#[allow(non_snake_case)]
10124pub mod Intl {
10125    use super::*;
10126
10127    // Intl
10128    #[wasm_bindgen]
10129    extern "C" {
10130        /// The `Intl.getCanonicalLocales()` method returns an array containing
10131        /// the canonical locale names. Duplicates will be omitted and elements
10132        /// will be validated as structurally valid language tags.
10133        ///
10134        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/getCanonicalLocales)
10135        #[cfg(not(js_sys_unstable_apis))]
10136        #[wasm_bindgen(js_name = getCanonicalLocales, js_namespace = Intl)]
10137        pub fn get_canonical_locales(s: &JsValue) -> Array;
10138
10139        /// The `Intl.getCanonicalLocales()` method returns an array containing
10140        /// the canonical locale names. Duplicates will be omitted and elements
10141        /// will be validated as structurally valid language tags.
10142        ///
10143        /// Throws a `RangeError` if any of the strings are not valid locale identifiers.
10144        ///
10145        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/getCanonicalLocales)
10146        #[cfg(js_sys_unstable_apis)]
10147        #[wasm_bindgen(js_name = getCanonicalLocales, js_namespace = Intl, catch)]
10148        pub fn get_canonical_locales(s: &[JsString]) -> Result<Array<JsString>, JsValue>;
10149
10150        /// The `Intl.supportedValuesOf()` method returns an array containing the
10151        /// supported calendar, collation, currency, numbering system, or unit values
10152        /// supported by the implementation.
10153        ///
10154        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/supportedValuesOf)
10155        #[wasm_bindgen(js_name = supportedValuesOf, js_namespace = Intl)]
10156        pub fn supported_values_of(key: SupportedValuesKey) -> Array<JsString>;
10157    }
10158
10159    // Intl string enums
10160
10161    /// Key for `Intl.supportedValuesOf()`.
10162    #[wasm_bindgen]
10163    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10164    pub enum SupportedValuesKey {
10165        Calendar = "calendar",
10166        Collation = "collation",
10167        Currency = "currency",
10168        NumberingSystem = "numberingSystem",
10169        TimeZone = "timeZone",
10170        Unit = "unit",
10171    }
10172
10173    /// Locale matching algorithm for Intl constructors.
10174    #[wasm_bindgen]
10175    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10176    pub enum LocaleMatcher {
10177        Lookup = "lookup",
10178        BestFit = "best fit",
10179    }
10180
10181    /// Usage for `Intl.Collator`.
10182    #[wasm_bindgen]
10183    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10184    pub enum CollatorUsage {
10185        Sort = "sort",
10186        Search = "search",
10187    }
10188
10189    /// Sensitivity for `Intl.Collator`.
10190    #[wasm_bindgen]
10191    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10192    pub enum CollatorSensitivity {
10193        Base = "base",
10194        Accent = "accent",
10195        Case = "case",
10196        Variant = "variant",
10197    }
10198
10199    /// Case first option for `Intl.Collator`.
10200    #[wasm_bindgen]
10201    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10202    pub enum CollatorCaseFirst {
10203        Upper = "upper",
10204        Lower = "lower",
10205        False = "false",
10206    }
10207
10208    /// Style for `Intl.NumberFormat`.
10209    #[wasm_bindgen]
10210    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10211    pub enum NumberFormatStyle {
10212        Decimal = "decimal",
10213        Currency = "currency",
10214        Percent = "percent",
10215        Unit = "unit",
10216    }
10217
10218    /// Currency display for `Intl.NumberFormat`.
10219    #[wasm_bindgen]
10220    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10221    pub enum CurrencyDisplay {
10222        Code = "code",
10223        Symbol = "symbol",
10224        NarrowSymbol = "narrowSymbol",
10225        Name = "name",
10226    }
10227
10228    /// Currency sign for `Intl.NumberFormat`.
10229    #[wasm_bindgen]
10230    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10231    pub enum CurrencySign {
10232        Standard = "standard",
10233        Accounting = "accounting",
10234    }
10235
10236    /// Unit display for `Intl.NumberFormat`.
10237    #[wasm_bindgen]
10238    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10239    pub enum UnitDisplay {
10240        Short = "short",
10241        Narrow = "narrow",
10242        Long = "long",
10243    }
10244
10245    /// Notation for `Intl.NumberFormat`.
10246    #[wasm_bindgen]
10247    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10248    pub enum NumberFormatNotation {
10249        Standard = "standard",
10250        Scientific = "scientific",
10251        Engineering = "engineering",
10252        Compact = "compact",
10253    }
10254
10255    /// Compact display for `Intl.NumberFormat`.
10256    #[wasm_bindgen]
10257    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10258    pub enum CompactDisplay {
10259        Short = "short",
10260        Long = "long",
10261    }
10262
10263    /// Sign display for `Intl.NumberFormat`.
10264    #[wasm_bindgen]
10265    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10266    pub enum SignDisplay {
10267        Auto = "auto",
10268        Never = "never",
10269        Always = "always",
10270        ExceptZero = "exceptZero",
10271    }
10272
10273    /// Rounding mode for `Intl.NumberFormat`.
10274    #[wasm_bindgen]
10275    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10276    pub enum RoundingMode {
10277        Ceil = "ceil",
10278        Floor = "floor",
10279        Expand = "expand",
10280        Trunc = "trunc",
10281        HalfCeil = "halfCeil",
10282        HalfFloor = "halfFloor",
10283        HalfExpand = "halfExpand",
10284        HalfTrunc = "halfTrunc",
10285        HalfEven = "halfEven",
10286    }
10287
10288    /// Rounding priority for `Intl.NumberFormat`.
10289    #[wasm_bindgen]
10290    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10291    pub enum RoundingPriority {
10292        Auto = "auto",
10293        MorePrecision = "morePrecision",
10294        LessPrecision = "lessPrecision",
10295    }
10296
10297    /// Trailing zero display for `Intl.NumberFormat`.
10298    #[wasm_bindgen]
10299    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10300    pub enum TrailingZeroDisplay {
10301        Auto = "auto",
10302        StripIfInteger = "stripIfInteger",
10303    }
10304
10305    /// Use grouping option for `Intl.NumberFormat`.
10306    ///
10307    /// Determines whether to use grouping separators, such as thousands
10308    /// separators or thousand/lakh/crore separators.
10309    ///
10310    /// The default is `Min2` if notation is "compact", and `Auto` otherwise.
10311    ///
10312    /// Note: The string values `"true"` and `"false"` are accepted by JavaScript
10313    /// but are always converted to the default value. Use `True` and `False`
10314    /// variants for the boolean behavior.
10315    ///
10316    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#usegrouping)
10317    #[wasm_bindgen]
10318    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10319    pub enum UseGrouping {
10320        /// Display grouping separators even if the locale prefers otherwise.
10321        Always = "always",
10322        /// Display grouping separators based on the locale preference,
10323        /// which may also be dependent on the currency.
10324        Auto = "auto",
10325        /// Display grouping separators when there are at least 2 digits in a group.
10326        Min2 = "min2",
10327        /// Same as `Always`. Display grouping separators even if the locale prefers otherwise.
10328        True = "true",
10329        /// Display no grouping separators.
10330        False = "false",
10331    }
10332
10333    /// Date/time style for `Intl.DateTimeFormat`.
10334    #[wasm_bindgen]
10335    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10336    pub enum DateTimeStyle {
10337        Full = "full",
10338        Long = "long",
10339        Medium = "medium",
10340        Short = "short",
10341    }
10342
10343    /// Hour cycle for `Intl.DateTimeFormat`.
10344    #[wasm_bindgen]
10345    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10346    pub enum HourCycle {
10347        H11 = "h11",
10348        H12 = "h12",
10349        H23 = "h23",
10350        H24 = "h24",
10351    }
10352
10353    /// Weekday format for `Intl.DateTimeFormat`.
10354    #[wasm_bindgen]
10355    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10356    pub enum WeekdayFormat {
10357        Narrow = "narrow",
10358        Short = "short",
10359        Long = "long",
10360    }
10361
10362    /// Era format for `Intl.DateTimeFormat`.
10363    #[wasm_bindgen]
10364    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10365    pub enum EraFormat {
10366        Narrow = "narrow",
10367        Short = "short",
10368        Long = "long",
10369    }
10370
10371    /// Year format for `Intl.DateTimeFormat`.
10372    #[wasm_bindgen]
10373    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10374    pub enum YearFormat {
10375        Numeric = "numeric",
10376        TwoDigit = "2-digit",
10377    }
10378
10379    /// Month format for `Intl.DateTimeFormat`.
10380    #[wasm_bindgen]
10381    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10382    pub enum MonthFormat {
10383        #[wasm_bindgen]
10384        Numeric = "numeric",
10385        #[wasm_bindgen]
10386        TwoDigit = "2-digit",
10387        #[wasm_bindgen]
10388        Narrow = "narrow",
10389        #[wasm_bindgen]
10390        Short = "short",
10391        #[wasm_bindgen]
10392        Long = "long",
10393    }
10394
10395    /// Day format for `Intl.DateTimeFormat`.
10396    #[wasm_bindgen]
10397    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10398    pub enum DayFormat {
10399        #[wasm_bindgen]
10400        Numeric = "numeric",
10401        #[wasm_bindgen]
10402        TwoDigit = "2-digit",
10403    }
10404
10405    /// Hour/minute/second format for `Intl.DateTimeFormat`.
10406    #[wasm_bindgen]
10407    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10408    pub enum NumericFormat {
10409        #[wasm_bindgen]
10410        Numeric = "numeric",
10411        #[wasm_bindgen]
10412        TwoDigit = "2-digit",
10413    }
10414
10415    /// Time zone name format for `Intl.DateTimeFormat`.
10416    #[wasm_bindgen]
10417    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10418    pub enum TimeZoneNameFormat {
10419        Short = "short",
10420        Long = "long",
10421        ShortOffset = "shortOffset",
10422        LongOffset = "longOffset",
10423        ShortGeneric = "shortGeneric",
10424        LongGeneric = "longGeneric",
10425    }
10426
10427    /// Day period format for `Intl.DateTimeFormat`.
10428    #[wasm_bindgen]
10429    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10430    pub enum DayPeriodFormat {
10431        Narrow = "narrow",
10432        Short = "short",
10433        Long = "long",
10434    }
10435
10436    /// Part type for `DateTimeFormat.formatToParts()`.
10437    #[wasm_bindgen]
10438    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10439    pub enum DateTimeFormatPartType {
10440        Day = "day",
10441        DayPeriod = "dayPeriod",
10442        Era = "era",
10443        FractionalSecond = "fractionalSecond",
10444        Hour = "hour",
10445        Literal = "literal",
10446        Minute = "minute",
10447        Month = "month",
10448        RelatedYear = "relatedYear",
10449        Second = "second",
10450        TimeZoneName = "timeZoneName",
10451        Weekday = "weekday",
10452        Year = "year",
10453        YearName = "yearName",
10454    }
10455
10456    /// Part type for `NumberFormat.formatToParts()`.
10457    #[wasm_bindgen]
10458    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10459    pub enum NumberFormatPartType {
10460        Compact = "compact",
10461        Currency = "currency",
10462        Decimal = "decimal",
10463        ExponentInteger = "exponentInteger",
10464        ExponentMinusSign = "exponentMinusSign",
10465        ExponentSeparator = "exponentSeparator",
10466        Fraction = "fraction",
10467        Group = "group",
10468        Infinity = "infinity",
10469        Integer = "integer",
10470        Literal = "literal",
10471        MinusSign = "minusSign",
10472        Nan = "nan",
10473        PercentSign = "percentSign",
10474        PlusSign = "plusSign",
10475        Unit = "unit",
10476        Unknown = "unknown",
10477    }
10478
10479    /// Type for `Intl.PluralRules` (cardinal or ordinal).
10480    #[wasm_bindgen]
10481    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10482    pub enum PluralRulesType {
10483        Cardinal = "cardinal",
10484        Ordinal = "ordinal",
10485    }
10486
10487    /// Plural category returned by `PluralRules.select()`.
10488    #[wasm_bindgen]
10489    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10490    pub enum PluralCategory {
10491        Zero = "zero",
10492        One = "one",
10493        Two = "two",
10494        Few = "few",
10495        Many = "many",
10496        Other = "other",
10497    }
10498
10499    /// Numeric option for `Intl.RelativeTimeFormat`.
10500    #[wasm_bindgen]
10501    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10502    pub enum RelativeTimeFormatNumeric {
10503        Always = "always",
10504        Auto = "auto",
10505    }
10506
10507    /// Style for `Intl.RelativeTimeFormat`.
10508    #[wasm_bindgen]
10509    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10510    pub enum RelativeTimeFormatStyle {
10511        Long = "long",
10512        Short = "short",
10513        Narrow = "narrow",
10514    }
10515
10516    /// Unit for `RelativeTimeFormat.format()`.
10517    #[wasm_bindgen]
10518    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10519    pub enum RelativeTimeFormatUnit {
10520        Year = "year",
10521        Years = "years",
10522        Quarter = "quarter",
10523        Quarters = "quarters",
10524        Month = "month",
10525        Months = "months",
10526        Week = "week",
10527        Weeks = "weeks",
10528        Day = "day",
10529        Days = "days",
10530        Hour = "hour",
10531        Hours = "hours",
10532        Minute = "minute",
10533        Minutes = "minutes",
10534        Second = "second",
10535        Seconds = "seconds",
10536    }
10537
10538    /// Part type for `RelativeTimeFormat.formatToParts()`.
10539    #[wasm_bindgen]
10540    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10541    pub enum RelativeTimeFormatPartType {
10542        Literal = "literal",
10543        Integer = "integer",
10544        Decimal = "decimal",
10545        Fraction = "fraction",
10546    }
10547
10548    /// Source indicator for range format parts.
10549    ///
10550    /// Indicates which part of the range (start, end, or shared) a formatted
10551    /// part belongs to when using `formatRangeToParts()`.
10552    ///
10553    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/formatRangeToParts#description)
10554    #[wasm_bindgen]
10555    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10556    pub enum RangeSource {
10557        /// The part is from the start of the range.
10558        StartRange = "startRange",
10559        /// The part is from the end of the range.
10560        EndRange = "endRange",
10561        /// The part is shared between start and end (e.g., a separator or common element).
10562        Shared = "shared",
10563    }
10564
10565    /// Type for `Intl.ListFormat`.
10566    #[wasm_bindgen]
10567    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10568    pub enum ListFormatType {
10569        /// For lists of standalone items (default).
10570        Conjunction = "conjunction",
10571        /// For lists representing alternatives.
10572        Disjunction = "disjunction",
10573        /// For lists of values with units.
10574        Unit = "unit",
10575    }
10576
10577    /// Style for `Intl.ListFormat`.
10578    #[wasm_bindgen]
10579    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10580    pub enum ListFormatStyle {
10581        /// "A, B, and C" (default).
10582        Long = "long",
10583        /// "A, B, C".
10584        Short = "short",
10585        /// "A B C".
10586        Narrow = "narrow",
10587    }
10588
10589    /// Part type for `Intl.ListFormat.formatToParts()`.
10590    #[wasm_bindgen]
10591    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10592    pub enum ListFormatPartType {
10593        /// A value from the list.
10594        Element = "element",
10595        /// A linguistic construct (e.g., ", ", " and ").
10596        Literal = "literal",
10597    }
10598
10599    /// Type for `Intl.Segmenter`.
10600    #[wasm_bindgen]
10601    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10602    pub enum SegmenterGranularity {
10603        /// Segment by grapheme clusters (user-perceived characters).
10604        Grapheme = "grapheme",
10605        /// Segment by words.
10606        Word = "word",
10607        /// Segment by sentences.
10608        Sentence = "sentence",
10609    }
10610
10611    /// Type for `Intl.DisplayNames`.
10612    #[wasm_bindgen]
10613    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10614    pub enum DisplayNamesType {
10615        /// Language display names.
10616        Language = "language",
10617        /// Region display names.
10618        Region = "region",
10619        /// Script display names.
10620        Script = "script",
10621        /// Currency display names.
10622        Currency = "currency",
10623        /// Calendar display names.
10624        Calendar = "calendar",
10625        /// Date/time field display names.
10626        DateTimeField = "dateTimeField",
10627    }
10628
10629    /// Style for `Intl.DisplayNames`.
10630    #[wasm_bindgen]
10631    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10632    pub enum DisplayNamesStyle {
10633        /// Full display name (default).
10634        Long = "long",
10635        /// Abbreviated display name.
10636        Short = "short",
10637        /// Minimal display name.
10638        Narrow = "narrow",
10639    }
10640
10641    /// Fallback for `Intl.DisplayNames`.
10642    #[wasm_bindgen]
10643    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10644    pub enum DisplayNamesFallback {
10645        /// Return the input code if no display name is available (default).
10646        Code = "code",
10647        /// Return undefined if no display name is available.
10648        None = "none",
10649    }
10650
10651    /// Language display for `Intl.DisplayNames`.
10652    #[wasm_bindgen]
10653    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
10654    pub enum DisplayNamesLanguageDisplay {
10655        /// Use dialect names (e.g., "British English").
10656        Dialect = "dialect",
10657        /// Use standard names (e.g., "English (United Kingdom)").
10658        Standard = "standard",
10659    }
10660
10661    // Intl.RelativeTimeFormatOptions
10662    #[wasm_bindgen]
10663    extern "C" {
10664        /// Options for `Intl.RelativeTimeFormat` constructor.
10665        ///
10666        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/RelativeTimeFormat#options)
10667        #[wasm_bindgen(extends = Object)]
10668        #[derive(Clone, Debug)]
10669        pub type RelativeTimeFormatOptions;
10670
10671        #[wasm_bindgen(method, getter = localeMatcher)]
10672        pub fn get_locale_matcher(this: &RelativeTimeFormatOptions) -> Option<LocaleMatcher>;
10673        #[wasm_bindgen(method, setter = localeMatcher)]
10674        pub fn set_locale_matcher(this: &RelativeTimeFormatOptions, value: LocaleMatcher);
10675
10676        #[wasm_bindgen(method, getter = numeric)]
10677        pub fn get_numeric(this: &RelativeTimeFormatOptions) -> Option<RelativeTimeFormatNumeric>;
10678        #[wasm_bindgen(method, setter = numeric)]
10679        pub fn set_numeric(this: &RelativeTimeFormatOptions, value: RelativeTimeFormatNumeric);
10680
10681        #[wasm_bindgen(method, getter = style)]
10682        pub fn get_style(this: &RelativeTimeFormatOptions) -> Option<RelativeTimeFormatStyle>;
10683        #[wasm_bindgen(method, setter = style)]
10684        pub fn set_style(this: &RelativeTimeFormatOptions, value: RelativeTimeFormatStyle);
10685    }
10686
10687    impl RelativeTimeFormatOptions {
10688        pub fn new() -> RelativeTimeFormatOptions {
10689            JsCast::unchecked_into(Object::new())
10690        }
10691    }
10692
10693    impl Default for RelativeTimeFormatOptions {
10694        fn default() -> Self {
10695            RelativeTimeFormatOptions::new()
10696        }
10697    }
10698
10699    // Intl.ResolvedRelativeTimeFormatOptions
10700    #[wasm_bindgen]
10701    extern "C" {
10702        /// Resolved options returned by `Intl.RelativeTimeFormat.prototype.resolvedOptions()`.
10703        ///
10704        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/resolvedOptions)
10705        #[wasm_bindgen(extends = RelativeTimeFormatOptions)]
10706        #[derive(Clone, Debug)]
10707        pub type ResolvedRelativeTimeFormatOptions;
10708
10709        /// The resolved locale string.
10710        #[wasm_bindgen(method, getter = locale)]
10711        pub fn get_locale(this: &ResolvedRelativeTimeFormatOptions) -> JsString;
10712
10713        /// The numbering system used.
10714        #[wasm_bindgen(method, getter = numberingSystem)]
10715        pub fn get_numbering_system(this: &ResolvedRelativeTimeFormatOptions) -> JsString;
10716    }
10717
10718    // Intl.RelativeTimeFormatPart
10719    #[wasm_bindgen]
10720    extern "C" {
10721        /// A part of the formatted relative time returned by `formatToParts()`.
10722        ///
10723        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/formatToParts)
10724        #[wasm_bindgen(extends = Object)]
10725        #[derive(Clone, Debug)]
10726        pub type RelativeTimeFormatPart;
10727
10728        /// The type of this part.
10729        #[wasm_bindgen(method, getter = type)]
10730        pub fn type_(this: &RelativeTimeFormatPart) -> RelativeTimeFormatPartType;
10731
10732        /// The string value of this part.
10733        #[wasm_bindgen(method, getter = value)]
10734        pub fn value(this: &RelativeTimeFormatPart) -> JsString;
10735
10736        /// The unit used in this part (only for integer parts).
10737        #[wasm_bindgen(method, getter = unit)]
10738        pub fn unit(this: &RelativeTimeFormatPart) -> Option<JsString>;
10739    }
10740
10741    // Intl.LocaleMatcherOptions
10742    #[wasm_bindgen]
10743    extern "C" {
10744        /// Options for `supportedLocalesOf` methods.
10745        #[wasm_bindgen(extends = Object)]
10746        #[derive(Clone, Debug)]
10747        pub type LocaleMatcherOptions;
10748
10749        #[wasm_bindgen(method, getter = localeMatcher)]
10750        pub fn get_locale_matcher(this: &LocaleMatcherOptions) -> Option<LocaleMatcher>;
10751
10752        #[wasm_bindgen(method, setter = localeMatcher)]
10753        pub fn set_locale_matcher(this: &LocaleMatcherOptions, value: LocaleMatcher);
10754    }
10755
10756    impl LocaleMatcherOptions {
10757        pub fn new() -> LocaleMatcherOptions {
10758            JsCast::unchecked_into(Object::new())
10759        }
10760    }
10761
10762    impl Default for LocaleMatcherOptions {
10763        fn default() -> Self {
10764            LocaleMatcherOptions::new()
10765        }
10766    }
10767
10768    // Intl.Collator Options
10769    #[wasm_bindgen]
10770    extern "C" {
10771        /// Options for `Intl.Collator` and `String.prototype.localeCompare`.
10772        ///
10773        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Collator/Collator#options)
10774        #[wasm_bindgen(extends = Object)]
10775        #[derive(Clone, Debug)]
10776        pub type CollatorOptions;
10777
10778        #[wasm_bindgen(method, getter = localeMatcher)]
10779        pub fn get_locale_matcher(this: &CollatorOptions) -> Option<LocaleMatcher>;
10780        #[wasm_bindgen(method, setter = localeMatcher)]
10781        pub fn set_locale_matcher(this: &CollatorOptions, value: LocaleMatcher);
10782
10783        #[wasm_bindgen(method, getter = usage)]
10784        pub fn get_usage(this: &CollatorOptions) -> Option<CollatorUsage>;
10785        #[wasm_bindgen(method, setter = usage)]
10786        pub fn set_usage(this: &CollatorOptions, value: CollatorUsage);
10787
10788        #[wasm_bindgen(method, getter = sensitivity)]
10789        pub fn get_sensitivity(this: &CollatorOptions) -> Option<CollatorSensitivity>;
10790        #[wasm_bindgen(method, setter = sensitivity)]
10791        pub fn set_sensitivity(this: &CollatorOptions, value: CollatorSensitivity);
10792
10793        #[wasm_bindgen(method, getter = ignorePunctuation)]
10794        pub fn get_ignore_punctuation(this: &CollatorOptions) -> Option<bool>;
10795        #[wasm_bindgen(method, setter = ignorePunctuation)]
10796        pub fn set_ignore_punctuation(this: &CollatorOptions, value: bool);
10797
10798        #[wasm_bindgen(method, getter = numeric)]
10799        pub fn get_numeric(this: &CollatorOptions) -> Option<bool>;
10800        #[wasm_bindgen(method, setter = numeric)]
10801        pub fn set_numeric(this: &CollatorOptions, value: bool);
10802
10803        #[wasm_bindgen(method, getter = caseFirst)]
10804        pub fn get_case_first(this: &CollatorOptions) -> Option<CollatorCaseFirst>;
10805        #[wasm_bindgen(method, setter = caseFirst)]
10806        pub fn set_case_first(this: &CollatorOptions, value: CollatorCaseFirst);
10807    }
10808    impl CollatorOptions {
10809        pub fn new() -> CollatorOptions {
10810            JsCast::unchecked_into(Object::new())
10811        }
10812    }
10813    impl Default for CollatorOptions {
10814        fn default() -> Self {
10815            CollatorOptions::new()
10816        }
10817    }
10818
10819    // Intl.Collator ResolvedCollatorOptions
10820    #[wasm_bindgen]
10821    extern "C" {
10822        #[wasm_bindgen(extends = CollatorOptions)]
10823        #[derive(Clone, Debug)]
10824        pub type ResolvedCollatorOptions;
10825
10826        #[wasm_bindgen(method, getter = locale)]
10827        pub fn get_locale(this: &ResolvedCollatorOptions) -> JsString; // not Option, always present
10828        #[wasm_bindgen(method, getter = collation)]
10829        pub fn get_collation(this: &ResolvedCollatorOptions) -> JsString;
10830    }
10831
10832    // Intl.Collator
10833    #[wasm_bindgen]
10834    extern "C" {
10835        /// The `Intl.Collator` object is a constructor for collators, objects
10836        /// that enable language sensitive string comparison.
10837        ///
10838        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator)
10839        #[wasm_bindgen(extends = Object, js_namespace = Intl, typescript_type = "Intl.Collator")]
10840        #[derive(Clone, Debug)]
10841        pub type Collator;
10842
10843        /// The `Intl.Collator` object is a constructor for collators, objects
10844        /// that enable language sensitive string comparison.
10845        ///
10846        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator)
10847        #[cfg(not(js_sys_unstable_apis))]
10848        #[wasm_bindgen(constructor, js_namespace = Intl)]
10849        pub fn new(locales: &Array, options: &Object) -> Collator;
10850
10851        /// The `Intl.Collator` object is a constructor for collators, objects
10852        /// that enable language sensitive string comparison.
10853        ///
10854        /// Throws a `RangeError` if locales contain invalid values.
10855        ///
10856        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator)
10857        #[cfg(js_sys_unstable_apis)]
10858        #[wasm_bindgen(constructor, js_namespace = Intl, catch)]
10859        pub fn new(locales: &[JsString], options: &CollatorOptions) -> Result<Collator, JsValue>;
10860
10861        /// The Intl.Collator.prototype.compare property returns a function that
10862        /// compares two strings according to the sort order of this Collator
10863        /// object.
10864        ///
10865        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator/compare)
10866        #[cfg(not(js_sys_unstable_apis))]
10867        #[wasm_bindgen(method, getter, js_class = "Intl.Collator")]
10868        pub fn compare(this: &Collator) -> Function;
10869
10870        /// Compares two strings according to the sort order of this Collator.
10871        ///
10872        /// Returns a negative value if `a` comes before `b`, positive if `a` comes
10873        /// after `b`, and zero if they are equal.
10874        ///
10875        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Collator/compare)
10876        #[cfg(js_sys_unstable_apis)]
10877        #[wasm_bindgen(method, js_class = "Intl.Collator")]
10878        pub fn compare(this: &Collator, a: &str, b: &str) -> i32;
10879
10880        /// The `Intl.Collator.prototype.resolvedOptions()` method returns a new
10881        /// object with properties reflecting the locale and collation options
10882        /// computed during initialization of this Collator object.
10883        ///
10884        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator/resolvedOptions)
10885        #[cfg(not(js_sys_unstable_apis))]
10886        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
10887        pub fn resolved_options(this: &Collator) -> Object;
10888
10889        /// The `Intl.Collator.prototype.resolvedOptions()` method returns a new
10890        /// object with properties reflecting the locale and collation options
10891        /// computed during initialization of this Collator object.
10892        ///
10893        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator/resolvedOptions)
10894        #[cfg(js_sys_unstable_apis)]
10895        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
10896        pub fn resolved_options(this: &Collator) -> ResolvedCollatorOptions;
10897
10898        /// The `Intl.Collator.supportedLocalesOf()` method returns an array
10899        /// containing those of the provided locales that are supported in
10900        /// collation without having to fall back to the runtime's default
10901        /// locale.
10902        ///
10903        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator/supportedLocalesOf)
10904        #[cfg(not(js_sys_unstable_apis))]
10905        #[wasm_bindgen(static_method_of = Collator, js_namespace = Intl, js_name = supportedLocalesOf)]
10906        pub fn supported_locales_of(locales: &Array, options: &Object) -> Array;
10907
10908        /// The `Intl.Collator.supportedLocalesOf()` method returns an array
10909        /// containing those of the provided locales that are supported in
10910        /// collation without having to fall back to the runtime's default
10911        /// locale.
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/supportedLocalesOf)
10916        #[cfg(js_sys_unstable_apis)]
10917        #[wasm_bindgen(static_method_of = Collator, js_namespace = Intl, js_name = supportedLocalesOf, catch)]
10918        pub fn supported_locales_of(
10919            locales: &[JsString],
10920            options: &LocaleMatcherOptions,
10921        ) -> Result<Array<JsString>, JsValue>;
10922    }
10923
10924    #[cfg(not(js_sys_unstable_apis))]
10925    impl Default for Collator {
10926        fn default() -> Self {
10927            Self::new(
10928                &JsValue::UNDEFINED.unchecked_into(),
10929                &JsValue::UNDEFINED.unchecked_into(),
10930            )
10931        }
10932    }
10933
10934    #[cfg(js_sys_unstable_apis)]
10935    impl Default for Collator {
10936        fn default() -> Self {
10937            Self::new(&[], &Default::default()).unwrap()
10938        }
10939    }
10940
10941    // Intl.DateTimeFormatOptions
10942    #[wasm_bindgen]
10943    extern "C" {
10944        /// Options for `Intl.DateTimeFormat` constructor.
10945        ///
10946        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat#options)
10947        #[wasm_bindgen(extends = Object)]
10948        #[derive(Clone, Debug)]
10949        pub type DateTimeFormatOptions;
10950
10951        // Locale matching
10952        #[wasm_bindgen(method, getter = localeMatcher)]
10953        pub fn get_locale_matcher(this: &DateTimeFormatOptions) -> Option<LocaleMatcher>;
10954        #[wasm_bindgen(method, setter = localeMatcher)]
10955        pub fn set_locale_matcher(this: &DateTimeFormatOptions, value: LocaleMatcher);
10956
10957        // Calendar/numbering (free-form strings, no enum)
10958        #[wasm_bindgen(method, getter = calendar)]
10959        pub fn get_calendar(this: &DateTimeFormatOptions) -> Option<JsString>;
10960        #[wasm_bindgen(method, setter = calendar)]
10961        pub fn set_calendar(this: &DateTimeFormatOptions, value: &str);
10962
10963        #[wasm_bindgen(method, getter = numberingSystem)]
10964        pub fn get_numbering_system(this: &DateTimeFormatOptions) -> Option<JsString>;
10965        #[wasm_bindgen(method, setter = numberingSystem)]
10966        pub fn set_numbering_system(this: &DateTimeFormatOptions, value: &str);
10967
10968        // Timezone (free-form string)
10969        #[wasm_bindgen(method, getter = timeZone)]
10970        pub fn get_time_zone(this: &DateTimeFormatOptions) -> Option<JsString>;
10971        #[wasm_bindgen(method, setter = timeZone)]
10972        pub fn set_time_zone(this: &DateTimeFormatOptions, value: &str);
10973
10974        // Hour cycle
10975        #[wasm_bindgen(method, getter = hour12)]
10976        pub fn get_hour12(this: &DateTimeFormatOptions) -> Option<bool>;
10977        #[wasm_bindgen(method, setter = hour12)]
10978        pub fn set_hour12(this: &DateTimeFormatOptions, value: bool);
10979
10980        #[wasm_bindgen(method, getter = hourCycle)]
10981        pub fn get_hour_cycle(this: &DateTimeFormatOptions) -> Option<HourCycle>;
10982        #[wasm_bindgen(method, setter = hourCycle)]
10983        pub fn set_hour_cycle(this: &DateTimeFormatOptions, value: HourCycle);
10984
10985        // Style shortcuts
10986        #[wasm_bindgen(method, getter = dateStyle)]
10987        pub fn get_date_style(this: &DateTimeFormatOptions) -> Option<DateTimeStyle>;
10988        #[wasm_bindgen(method, setter = dateStyle)]
10989        pub fn set_date_style(this: &DateTimeFormatOptions, value: DateTimeStyle);
10990
10991        #[wasm_bindgen(method, getter = timeStyle)]
10992        pub fn get_time_style(this: &DateTimeFormatOptions) -> Option<DateTimeStyle>;
10993        #[wasm_bindgen(method, setter = timeStyle)]
10994        pub fn set_time_style(this: &DateTimeFormatOptions, value: DateTimeStyle);
10995
10996        // Component options
10997        #[wasm_bindgen(method, getter = weekday)]
10998        pub fn get_weekday(this: &DateTimeFormatOptions) -> Option<WeekdayFormat>;
10999        #[wasm_bindgen(method, setter = weekday)]
11000        pub fn set_weekday(this: &DateTimeFormatOptions, value: WeekdayFormat);
11001
11002        #[wasm_bindgen(method, getter = era)]
11003        pub fn get_era(this: &DateTimeFormatOptions) -> Option<EraFormat>;
11004        #[wasm_bindgen(method, setter = era)]
11005        pub fn set_era(this: &DateTimeFormatOptions, value: EraFormat);
11006
11007        #[wasm_bindgen(method, getter = year)]
11008        pub fn get_year(this: &DateTimeFormatOptions) -> Option<YearFormat>;
11009        #[wasm_bindgen(method, setter = year)]
11010        pub fn set_year(this: &DateTimeFormatOptions, value: YearFormat);
11011
11012        #[wasm_bindgen(method, getter = month)]
11013        pub fn get_month(this: &DateTimeFormatOptions) -> Option<MonthFormat>;
11014        #[wasm_bindgen(method, setter = month)]
11015        pub fn set_month(this: &DateTimeFormatOptions, value: MonthFormat);
11016
11017        #[wasm_bindgen(method, getter = day)]
11018        pub fn get_day(this: &DateTimeFormatOptions) -> Option<DayFormat>;
11019        #[wasm_bindgen(method, setter = day)]
11020        pub fn set_day(this: &DateTimeFormatOptions, value: DayFormat);
11021
11022        #[wasm_bindgen(method, getter = hour)]
11023        pub fn get_hour(this: &DateTimeFormatOptions) -> Option<NumericFormat>;
11024        #[wasm_bindgen(method, setter = hour)]
11025        pub fn set_hour(this: &DateTimeFormatOptions, value: NumericFormat);
11026
11027        #[wasm_bindgen(method, getter = minute)]
11028        pub fn get_minute(this: &DateTimeFormatOptions) -> Option<NumericFormat>;
11029        #[wasm_bindgen(method, setter = minute)]
11030        pub fn set_minute(this: &DateTimeFormatOptions, value: NumericFormat);
11031
11032        #[wasm_bindgen(method, getter = second)]
11033        pub fn get_second(this: &DateTimeFormatOptions) -> Option<NumericFormat>;
11034        #[wasm_bindgen(method, setter = second)]
11035        pub fn set_second(this: &DateTimeFormatOptions, value: NumericFormat);
11036
11037        #[wasm_bindgen(method, getter = fractionalSecondDigits)]
11038        pub fn get_fractional_second_digits(this: &DateTimeFormatOptions) -> Option<u8>;
11039        #[wasm_bindgen(method, setter = fractionalSecondDigits)]
11040        pub fn set_fractional_second_digits(this: &DateTimeFormatOptions, value: u8);
11041
11042        #[wasm_bindgen(method, getter = timeZoneName)]
11043        pub fn get_time_zone_name(this: &DateTimeFormatOptions) -> Option<TimeZoneNameFormat>;
11044        #[wasm_bindgen(method, setter = timeZoneName)]
11045        pub fn set_time_zone_name(this: &DateTimeFormatOptions, value: TimeZoneNameFormat);
11046
11047        #[wasm_bindgen(method, getter = dayPeriod)]
11048        pub fn get_day_period(this: &DateTimeFormatOptions) -> Option<DayPeriodFormat>;
11049        #[wasm_bindgen(method, setter = dayPeriod)]
11050        pub fn set_day_period(this: &DateTimeFormatOptions, value: DayPeriodFormat);
11051    }
11052
11053    impl DateTimeFormatOptions {
11054        pub fn new() -> DateTimeFormatOptions {
11055            JsCast::unchecked_into(Object::new())
11056        }
11057    }
11058
11059    impl Default for DateTimeFormatOptions {
11060        fn default() -> Self {
11061            DateTimeFormatOptions::new()
11062        }
11063    }
11064
11065    // Intl.ResolvedDateTimeFormatOptions
11066    #[wasm_bindgen]
11067    extern "C" {
11068        /// Resolved options returned by `Intl.DateTimeFormat.prototype.resolvedOptions()`.
11069        ///
11070        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/resolvedOptions)
11071        #[wasm_bindgen(extends = DateTimeFormatOptions)]
11072        #[derive(Clone, Debug)]
11073        pub type ResolvedDateTimeFormatOptions;
11074
11075        /// The resolved locale string.
11076        #[wasm_bindgen(method, getter = locale)]
11077        pub fn get_locale(this: &ResolvedDateTimeFormatOptions) -> JsString;
11078    }
11079
11080    // Intl.DateTimeFormatPart
11081    #[wasm_bindgen]
11082    extern "C" {
11083        /// A part of the formatted date returned by `formatToParts()`.
11084        ///
11085        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/formatToParts)
11086        #[wasm_bindgen(extends = Object)]
11087        #[derive(Clone, Debug)]
11088        pub type DateTimeFormatPart;
11089
11090        /// The type of the part (e.g., "day", "month", "year", "literal", etc.)
11091        #[wasm_bindgen(method, getter = type)]
11092        pub fn type_(this: &DateTimeFormatPart) -> DateTimeFormatPartType;
11093
11094        /// The value of the part.
11095        #[wasm_bindgen(method, getter)]
11096        pub fn value(this: &DateTimeFormatPart) -> JsString;
11097    }
11098
11099    // Intl.DateTimeRangeFormatPart
11100    #[wasm_bindgen]
11101    extern "C" {
11102        /// A part of the formatted date range returned by `formatRangeToParts()`.
11103        ///
11104        /// Extends `DateTimeFormatPart` with a `source` property indicating whether
11105        /// the part is from the start date, end date, or shared between them.
11106        ///
11107        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/formatRangeToParts)
11108        #[wasm_bindgen(extends = DateTimeFormatPart)]
11109        #[derive(Clone, Debug)]
11110        pub type DateTimeRangeFormatPart;
11111
11112        /// The source of the part: "startRange", "endRange", or "shared".
11113        #[wasm_bindgen(method, getter)]
11114        pub fn source(this: &DateTimeRangeFormatPart) -> RangeSource;
11115    }
11116
11117    // Intl.DateTimeFormat
11118    #[wasm_bindgen]
11119    extern "C" {
11120        /// The `Intl.DateTimeFormat` object is a constructor for objects
11121        /// that enable language-sensitive date and time formatting.
11122        ///
11123        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat)
11124        #[wasm_bindgen(extends = Object, js_namespace = Intl, typescript_type = "Intl.DateTimeFormat")]
11125        #[derive(Clone, Debug)]
11126        pub type DateTimeFormat;
11127
11128        /// The `Intl.DateTimeFormat` object is a constructor for objects
11129        /// that enable language-sensitive date and time formatting.
11130        ///
11131        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat)
11132        #[cfg(not(js_sys_unstable_apis))]
11133        #[wasm_bindgen(constructor, js_namespace = Intl)]
11134        pub fn new(locales: &Array, options: &Object) -> DateTimeFormat;
11135
11136        /// The `Intl.DateTimeFormat` object is a constructor for objects
11137        /// that enable language-sensitive date and time formatting.
11138        ///
11139        /// Throws a `RangeError` if locales contain invalid values.
11140        ///
11141        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat)
11142        #[cfg(js_sys_unstable_apis)]
11143        #[wasm_bindgen(constructor, js_namespace = Intl, catch)]
11144        pub fn new(
11145            locales: &[JsString],
11146            options: &DateTimeFormatOptions,
11147        ) -> Result<DateTimeFormat, JsValue>;
11148
11149        /// The Intl.DateTimeFormat.prototype.format property returns a getter function that
11150        /// formats a date according to the locale and formatting options of this
11151        /// Intl.DateTimeFormat object.
11152        ///
11153        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/format)
11154        #[cfg(not(js_sys_unstable_apis))]
11155        #[wasm_bindgen(method, getter, js_class = "Intl.DateTimeFormat")]
11156        pub fn format(this: &DateTimeFormat) -> Function;
11157
11158        /// Formats a date according to the locale and formatting options of this
11159        /// `Intl.DateTimeFormat` object.
11160        ///
11161        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/format)
11162        #[cfg(js_sys_unstable_apis)]
11163        #[wasm_bindgen(method, js_class = "Intl.DateTimeFormat")]
11164        pub fn format(this: &DateTimeFormat, date: &Date) -> JsString;
11165
11166        /// The `Intl.DateTimeFormat.prototype.formatToParts()` method allows locale-aware
11167        /// formatting of strings produced by DateTimeFormat formatters.
11168        ///
11169        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/formatToParts)
11170        #[cfg(not(js_sys_unstable_apis))]
11171        #[wasm_bindgen(method, js_class = "Intl.DateTimeFormat", js_name = formatToParts)]
11172        pub fn format_to_parts(this: &DateTimeFormat, date: &Date) -> Array;
11173
11174        /// The `Intl.DateTimeFormat.prototype.formatToParts()` method allows locale-aware
11175        /// formatting of strings produced by DateTimeFormat formatters.
11176        ///
11177        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/formatToParts)
11178        #[cfg(js_sys_unstable_apis)]
11179        #[wasm_bindgen(method, js_class = "Intl.DateTimeFormat", js_name = formatToParts)]
11180        pub fn format_to_parts(this: &DateTimeFormat, date: &Date) -> Array<DateTimeFormatPart>;
11181
11182        /// The `Intl.DateTimeFormat.prototype.formatRange()` method formats a date range
11183        /// in the most concise way based on the locales and options provided when
11184        /// instantiating this `Intl.DateTimeFormat` object.
11185        ///
11186        /// Throws a `TypeError` if the dates are invalid.
11187        ///
11188        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/formatRange)
11189        #[wasm_bindgen(method, js_class = "Intl.DateTimeFormat", js_name = formatRange, catch)]
11190        pub fn format_range(
11191            this: &DateTimeFormat,
11192            start_date: &Date,
11193            end_date: &Date,
11194        ) -> Result<JsString, JsValue>;
11195
11196        /// The `Intl.DateTimeFormat.prototype.formatRangeToParts()` method returns an array
11197        /// of locale-specific tokens representing each part of the formatted date range
11198        /// produced by `Intl.DateTimeFormat` formatters.
11199        ///
11200        /// Throws a `TypeError` if the dates are invalid.
11201        ///
11202        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/formatRangeToParts)
11203        #[wasm_bindgen(method, js_class = "Intl.DateTimeFormat", js_name = formatRangeToParts, catch)]
11204        pub fn format_range_to_parts(
11205            this: &DateTimeFormat,
11206            start_date: &Date,
11207            end_date: &Date,
11208        ) -> Result<Array<DateTimeRangeFormatPart>, JsValue>;
11209
11210        /// The `Intl.DateTimeFormat.prototype.resolvedOptions()` method returns a new
11211        /// object with properties reflecting the locale and date and time formatting
11212        /// options computed during initialization of this DateTimeFormat object.
11213        ///
11214        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/resolvedOptions)
11215        #[cfg(not(js_sys_unstable_apis))]
11216        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
11217        pub fn resolved_options(this: &DateTimeFormat) -> Object;
11218
11219        /// The `Intl.DateTimeFormat.prototype.resolvedOptions()` method returns a new
11220        /// object with properties reflecting the locale and date and time formatting
11221        /// options computed during initialization of this DateTimeFormat object.
11222        ///
11223        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/resolvedOptions)
11224        #[cfg(js_sys_unstable_apis)]
11225        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
11226        pub fn resolved_options(this: &DateTimeFormat) -> ResolvedDateTimeFormatOptions;
11227
11228        /// The `Intl.DateTimeFormat.supportedLocalesOf()` method returns an array
11229        /// containing those of the provided locales that are supported in date
11230        /// and time formatting without having to fall back to the runtime's default
11231        /// locale.
11232        ///
11233        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/supportedLocalesOf)
11234        #[cfg(not(js_sys_unstable_apis))]
11235        #[wasm_bindgen(static_method_of = DateTimeFormat, js_namespace = Intl, js_name = supportedLocalesOf)]
11236        pub fn supported_locales_of(locales: &Array, options: &Object) -> Array;
11237
11238        /// The `Intl.DateTimeFormat.supportedLocalesOf()` method returns an array
11239        /// containing those of the provided locales that are supported in date
11240        /// and time formatting without having to fall back to the runtime's default
11241        /// locale.
11242        ///
11243        /// Throws a `RangeError` if locales contain invalid values.
11244        ///
11245        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/supportedLocalesOf)
11246        #[cfg(js_sys_unstable_apis)]
11247        #[wasm_bindgen(static_method_of = DateTimeFormat, js_namespace = Intl, js_name = supportedLocalesOf, catch)]
11248        pub fn supported_locales_of(
11249            locales: &[JsString],
11250            options: &LocaleMatcherOptions,
11251        ) -> Result<Array<JsString>, JsValue>;
11252    }
11253
11254    #[cfg(not(js_sys_unstable_apis))]
11255    impl Default for DateTimeFormat {
11256        fn default() -> Self {
11257            Self::new(
11258                &JsValue::UNDEFINED.unchecked_into(),
11259                &JsValue::UNDEFINED.unchecked_into(),
11260            )
11261        }
11262    }
11263
11264    #[cfg(js_sys_unstable_apis)]
11265    impl Default for DateTimeFormat {
11266        fn default() -> Self {
11267            Self::new(&[], &Default::default()).unwrap()
11268        }
11269    }
11270
11271    // Intl.NumberFormatOptions
11272    #[wasm_bindgen]
11273    extern "C" {
11274        /// Options for `Intl.NumberFormat` constructor.
11275        ///
11276        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#options)
11277        #[wasm_bindgen(extends = Object)]
11278        #[derive(Clone, Debug)]
11279        pub type NumberFormatOptions;
11280
11281        // Locale matching
11282        #[wasm_bindgen(method, getter = localeMatcher)]
11283        pub fn get_locale_matcher(this: &NumberFormatOptions) -> Option<LocaleMatcher>;
11284        #[wasm_bindgen(method, setter = localeMatcher)]
11285        pub fn set_locale_matcher(this: &NumberFormatOptions, value: LocaleMatcher);
11286
11287        // Numbering system (free-form string)
11288        #[wasm_bindgen(method, getter = numberingSystem)]
11289        pub fn get_numbering_system(this: &NumberFormatOptions) -> Option<JsString>;
11290        #[wasm_bindgen(method, setter = numberingSystem)]
11291        pub fn set_numbering_system(this: &NumberFormatOptions, value: &str);
11292
11293        // Style
11294        #[wasm_bindgen(method, getter = style)]
11295        pub fn get_style(this: &NumberFormatOptions) -> Option<NumberFormatStyle>;
11296        #[wasm_bindgen(method, setter = style)]
11297        pub fn set_style(this: &NumberFormatOptions, value: NumberFormatStyle);
11298
11299        // Currency options (currency code is free-form ISO 4217 string)
11300        #[wasm_bindgen(method, getter = currency)]
11301        pub fn get_currency(this: &NumberFormatOptions) -> Option<JsString>;
11302        #[wasm_bindgen(method, setter = currency)]
11303        pub fn set_currency(this: &NumberFormatOptions, value: &str);
11304
11305        #[wasm_bindgen(method, getter = currencyDisplay)]
11306        pub fn get_currency_display(this: &NumberFormatOptions) -> Option<CurrencyDisplay>;
11307        #[wasm_bindgen(method, setter = currencyDisplay)]
11308        pub fn set_currency_display(this: &NumberFormatOptions, value: CurrencyDisplay);
11309
11310        #[wasm_bindgen(method, getter = currencySign)]
11311        pub fn get_currency_sign(this: &NumberFormatOptions) -> Option<CurrencySign>;
11312        #[wasm_bindgen(method, setter = currencySign)]
11313        pub fn set_currency_sign(this: &NumberFormatOptions, value: CurrencySign);
11314
11315        // Unit options (unit name is free-form string)
11316        #[wasm_bindgen(method, getter = unit)]
11317        pub fn get_unit(this: &NumberFormatOptions) -> Option<JsString>;
11318        #[wasm_bindgen(method, setter = unit)]
11319        pub fn set_unit(this: &NumberFormatOptions, value: &str);
11320
11321        #[wasm_bindgen(method, getter = unitDisplay)]
11322        pub fn get_unit_display(this: &NumberFormatOptions) -> Option<UnitDisplay>;
11323        #[wasm_bindgen(method, setter = unitDisplay)]
11324        pub fn set_unit_display(this: &NumberFormatOptions, value: UnitDisplay);
11325
11326        // Notation
11327        #[wasm_bindgen(method, getter = notation)]
11328        pub fn get_notation(this: &NumberFormatOptions) -> Option<NumberFormatNotation>;
11329        #[wasm_bindgen(method, setter = notation)]
11330        pub fn set_notation(this: &NumberFormatOptions, value: NumberFormatNotation);
11331
11332        #[wasm_bindgen(method, getter = compactDisplay)]
11333        pub fn get_compact_display(this: &NumberFormatOptions) -> Option<CompactDisplay>;
11334        #[wasm_bindgen(method, setter = compactDisplay)]
11335        pub fn set_compact_display(this: &NumberFormatOptions, value: CompactDisplay);
11336
11337        // Sign display
11338        #[wasm_bindgen(method, getter = signDisplay)]
11339        pub fn get_sign_display(this: &NumberFormatOptions) -> Option<SignDisplay>;
11340        #[wasm_bindgen(method, setter = signDisplay)]
11341        pub fn set_sign_display(this: &NumberFormatOptions, value: SignDisplay);
11342
11343        // Digit options
11344        #[wasm_bindgen(method, getter = minimumIntegerDigits)]
11345        pub fn get_minimum_integer_digits(this: &NumberFormatOptions) -> Option<u8>;
11346        #[wasm_bindgen(method, setter = minimumIntegerDigits)]
11347        pub fn set_minimum_integer_digits(this: &NumberFormatOptions, value: u8);
11348
11349        #[wasm_bindgen(method, getter = minimumFractionDigits)]
11350        pub fn get_minimum_fraction_digits(this: &NumberFormatOptions) -> Option<u8>;
11351        #[wasm_bindgen(method, setter = minimumFractionDigits)]
11352        pub fn set_minimum_fraction_digits(this: &NumberFormatOptions, value: u8);
11353
11354        #[wasm_bindgen(method, getter = maximumFractionDigits)]
11355        pub fn get_maximum_fraction_digits(this: &NumberFormatOptions) -> Option<u8>;
11356        #[wasm_bindgen(method, setter = maximumFractionDigits)]
11357        pub fn set_maximum_fraction_digits(this: &NumberFormatOptions, value: u8);
11358
11359        #[wasm_bindgen(method, getter = minimumSignificantDigits)]
11360        pub fn get_minimum_significant_digits(this: &NumberFormatOptions) -> Option<u8>;
11361        #[wasm_bindgen(method, setter = minimumSignificantDigits)]
11362        pub fn set_minimum_significant_digits(this: &NumberFormatOptions, value: u8);
11363
11364        #[wasm_bindgen(method, getter = maximumSignificantDigits)]
11365        pub fn get_maximum_significant_digits(this: &NumberFormatOptions) -> Option<u8>;
11366        #[wasm_bindgen(method, setter = maximumSignificantDigits)]
11367        pub fn set_maximum_significant_digits(this: &NumberFormatOptions, value: u8);
11368
11369        // Grouping
11370        #[wasm_bindgen(method, getter = useGrouping)]
11371        pub fn get_use_grouping(this: &NumberFormatOptions) -> Option<UseGrouping>;
11372        #[wasm_bindgen(method, setter = useGrouping)]
11373        pub fn set_use_grouping(this: &NumberFormatOptions, value: UseGrouping);
11374
11375        // Rounding
11376        #[wasm_bindgen(method, getter = roundingMode)]
11377        pub fn get_rounding_mode(this: &NumberFormatOptions) -> Option<RoundingMode>;
11378        #[wasm_bindgen(method, setter = roundingMode)]
11379        pub fn set_rounding_mode(this: &NumberFormatOptions, value: RoundingMode);
11380
11381        #[wasm_bindgen(method, getter = roundingPriority)]
11382        pub fn get_rounding_priority(this: &NumberFormatOptions) -> Option<RoundingPriority>;
11383        #[wasm_bindgen(method, setter = roundingPriority)]
11384        pub fn set_rounding_priority(this: &NumberFormatOptions, value: RoundingPriority);
11385
11386        #[wasm_bindgen(method, getter = roundingIncrement)]
11387        pub fn get_rounding_increment(this: &NumberFormatOptions) -> Option<u32>;
11388        #[wasm_bindgen(method, setter = roundingIncrement)]
11389        pub fn set_rounding_increment(this: &NumberFormatOptions, value: u32);
11390
11391        #[wasm_bindgen(method, getter = trailingZeroDisplay)]
11392        pub fn get_trailing_zero_display(this: &NumberFormatOptions)
11393            -> Option<TrailingZeroDisplay>;
11394        #[wasm_bindgen(method, setter = trailingZeroDisplay)]
11395        pub fn set_trailing_zero_display(this: &NumberFormatOptions, value: TrailingZeroDisplay);
11396    }
11397
11398    impl NumberFormatOptions {
11399        pub fn new() -> NumberFormatOptions {
11400            JsCast::unchecked_into(Object::new())
11401        }
11402    }
11403
11404    impl Default for NumberFormatOptions {
11405        fn default() -> Self {
11406            NumberFormatOptions::new()
11407        }
11408    }
11409
11410    // Intl.ResolvedNumberFormatOptions
11411    #[wasm_bindgen]
11412    extern "C" {
11413        /// Resolved options returned by `Intl.NumberFormat.prototype.resolvedOptions()`.
11414        ///
11415        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/resolvedOptions)
11416        #[wasm_bindgen(extends = NumberFormatOptions)]
11417        #[derive(Clone, Debug)]
11418        pub type ResolvedNumberFormatOptions;
11419
11420        /// The resolved locale string.
11421        #[wasm_bindgen(method, getter = locale)]
11422        pub fn get_locale(this: &ResolvedNumberFormatOptions) -> JsString;
11423    }
11424
11425    // Intl.NumberFormatPart
11426    #[wasm_bindgen]
11427    extern "C" {
11428        /// A part of the formatted number returned by `formatToParts()`.
11429        ///
11430        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/formatToParts)
11431        #[wasm_bindgen(extends = Object)]
11432        #[derive(Clone, Debug)]
11433        pub type NumberFormatPart;
11434
11435        /// The type of the part (e.g., "integer", "decimal", "fraction", "currency", etc.)
11436        #[wasm_bindgen(method, getter = type)]
11437        pub fn type_(this: &NumberFormatPart) -> NumberFormatPartType;
11438
11439        /// The value of the part.
11440        #[wasm_bindgen(method, getter)]
11441        pub fn value(this: &NumberFormatPart) -> JsString;
11442    }
11443
11444    // Intl.NumberRangeFormatPart
11445    #[wasm_bindgen]
11446    extern "C" {
11447        /// A part of the formatted number range returned by `formatRangeToParts()`.
11448        ///
11449        /// Extends `NumberFormatPart` with a `source` property indicating whether
11450        /// the part is from the start number, end number, or shared between them.
11451        ///
11452        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/formatRangeToParts)
11453        #[wasm_bindgen(extends = NumberFormatPart)]
11454        #[derive(Clone, Debug)]
11455        pub type NumberRangeFormatPart;
11456
11457        /// The source of the part: "startRange", "endRange", or "shared".
11458        #[wasm_bindgen(method, getter)]
11459        pub fn source(this: &NumberRangeFormatPart) -> RangeSource;
11460    }
11461
11462    // Intl.NumberFormat
11463    #[wasm_bindgen]
11464    extern "C" {
11465        /// The `Intl.NumberFormat` object is a constructor for objects
11466        /// that enable language sensitive number formatting.
11467        ///
11468        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat)
11469        #[wasm_bindgen(extends = Object, js_namespace = Intl, typescript_type = "Intl.NumberFormat")]
11470        #[derive(Clone, Debug)]
11471        pub type NumberFormat;
11472
11473        /// The `Intl.NumberFormat` object is a constructor for objects
11474        /// that enable language sensitive number formatting.
11475        ///
11476        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat)
11477        #[cfg(not(js_sys_unstable_apis))]
11478        #[wasm_bindgen(constructor, js_namespace = Intl)]
11479        pub fn new(locales: &Array, options: &Object) -> NumberFormat;
11480
11481        /// The `Intl.NumberFormat` object is a constructor for objects
11482        /// that enable language sensitive number formatting.
11483        ///
11484        /// Throws a `RangeError` if locales contain invalid values.
11485        ///
11486        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat)
11487        #[cfg(js_sys_unstable_apis)]
11488        #[wasm_bindgen(constructor, js_namespace = Intl, catch)]
11489        pub fn new(
11490            locales: &[JsString],
11491            options: &NumberFormatOptions,
11492        ) -> Result<NumberFormat, JsValue>;
11493
11494        /// The Intl.NumberFormat.prototype.format property returns a getter function that
11495        /// formats a number according to the locale and formatting options of this
11496        /// NumberFormat object.
11497        ///
11498        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/format)
11499        #[cfg(not(js_sys_unstable_apis))]
11500        #[wasm_bindgen(method, getter, js_class = "Intl.NumberFormat")]
11501        pub fn format(this: &NumberFormat) -> Function;
11502
11503        /// Formats a number according to the locale and formatting options of this
11504        /// `Intl.NumberFormat` object.
11505        ///
11506        /// Accepts numeric strings for BigInt/arbitrary precision (e.g., `"123n"` → `"123"`,
11507        /// or use E notation: `"1000000E-6"` → `"1"`).
11508        ///
11509        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/format)
11510        #[cfg(js_sys_unstable_apis)]
11511        #[wasm_bindgen(method, js_class = "Intl.NumberFormat")]
11512        pub fn format(this: &NumberFormat, value: &JsString) -> JsString;
11513
11514        /// The `Intl.Numberformat.prototype.formatToParts()` method allows locale-aware
11515        /// formatting of strings produced by NumberTimeFormat formatters.
11516        ///
11517        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/formatToParts)
11518        #[cfg(not(js_sys_unstable_apis))]
11519        #[wasm_bindgen(method, js_class = "Intl.NumberFormat", js_name = formatToParts)]
11520        pub fn format_to_parts(this: &NumberFormat, number: f64) -> Array;
11521
11522        /// The `Intl.NumberFormat.prototype.formatToParts()` method allows locale-aware
11523        /// formatting of strings produced by `Intl.NumberFormat` formatters.
11524        ///
11525        /// Accepts numeric strings for BigInt/arbitrary precision (e.g., `"123n"` → `"123"`,
11526        /// or use E notation: `"1000000E-6"` → `"1"`).
11527        ///
11528        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/formatToParts)
11529        #[cfg(js_sys_unstable_apis)]
11530        #[wasm_bindgen(method, js_class = "Intl.NumberFormat", js_name = formatToParts)]
11531        pub fn format_to_parts(this: &NumberFormat, value: &JsString) -> Array<NumberFormatPart>;
11532
11533        /// Formats a range of numbers according to the locale and formatting options
11534        /// of this `Intl.NumberFormat` object.
11535        ///
11536        /// Accepts numeric strings for BigInt/arbitrary precision (e.g., `"123n"` → `"123"`,
11537        /// or use E notation: `"1000000E-6"` → `"1"`).
11538        ///
11539        /// Throws a `TypeError` if the values are invalid.
11540        ///
11541        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/formatRange)
11542        #[wasm_bindgen(method, js_class = "Intl.NumberFormat", js_name = formatRange, catch)]
11543        pub fn format_range(
11544            this: &NumberFormat,
11545            start: &JsString,
11546            end: &JsString,
11547        ) -> Result<JsString, JsValue>;
11548
11549        /// Returns an array of locale-specific tokens representing each part of
11550        /// the formatted number range.
11551        ///
11552        /// Accepts numeric strings for BigInt/arbitrary precision (e.g., `"123n"` → `"123"`,
11553        /// or use E notation: `"1000000E-6"` → `"1"`).
11554        ///
11555        /// Throws a `TypeError` if the values are invalid.
11556        ///
11557        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/formatRangeToParts)
11558        #[wasm_bindgen(method, js_class = "Intl.NumberFormat", js_name = formatRangeToParts, catch)]
11559        pub fn format_range_to_parts(
11560            this: &NumberFormat,
11561            start: &JsString,
11562            end: &JsString,
11563        ) -> Result<Array<NumberRangeFormatPart>, JsValue>;
11564
11565        /// The `Intl.NumberFormat.prototype.resolvedOptions()` method returns a new
11566        /// object with properties reflecting the locale and number formatting
11567        /// options computed during initialization of this NumberFormat object.
11568        ///
11569        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/resolvedOptions)
11570        #[cfg(not(js_sys_unstable_apis))]
11571        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
11572        pub fn resolved_options(this: &NumberFormat) -> Object;
11573
11574        /// The `Intl.NumberFormat.prototype.resolvedOptions()` method returns a new
11575        /// object with properties reflecting the locale and number formatting
11576        /// options computed during initialization of this NumberFormat object.
11577        ///
11578        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/resolvedOptions)
11579        #[cfg(js_sys_unstable_apis)]
11580        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
11581        pub fn resolved_options(this: &NumberFormat) -> ResolvedNumberFormatOptions;
11582
11583        /// The `Intl.NumberFormat.supportedLocalesOf()` method returns an array
11584        /// containing those of the provided locales that are supported in number
11585        /// formatting without having to fall back to the runtime's default locale.
11586        ///
11587        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/supportedLocalesOf)
11588        #[cfg(not(js_sys_unstable_apis))]
11589        #[wasm_bindgen(static_method_of = NumberFormat, js_namespace = Intl, js_name = supportedLocalesOf)]
11590        pub fn supported_locales_of(locales: &Array, options: &Object) -> Array;
11591
11592        /// The `Intl.NumberFormat.supportedLocalesOf()` method returns an array
11593        /// containing those of the provided locales that are supported in number
11594        /// formatting without having to fall back to the runtime's default locale.
11595        ///
11596        /// Throws a `RangeError` if locales contain invalid values.
11597        ///
11598        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/supportedLocalesOf)
11599        #[cfg(js_sys_unstable_apis)]
11600        #[wasm_bindgen(static_method_of = NumberFormat, js_namespace = Intl, js_name = supportedLocalesOf, catch)]
11601        pub fn supported_locales_of(
11602            locales: &[JsString],
11603            options: &LocaleMatcherOptions,
11604        ) -> Result<Array<JsString>, JsValue>;
11605    }
11606
11607    #[cfg(not(js_sys_unstable_apis))]
11608    impl Default for NumberFormat {
11609        fn default() -> Self {
11610            Self::new(
11611                &JsValue::UNDEFINED.unchecked_into(),
11612                &JsValue::UNDEFINED.unchecked_into(),
11613            )
11614        }
11615    }
11616
11617    #[cfg(js_sys_unstable_apis)]
11618    impl Default for NumberFormat {
11619        fn default() -> Self {
11620            Self::new(&[], &Default::default()).unwrap()
11621        }
11622    }
11623
11624    // Intl.PluralRulesOptions
11625    #[wasm_bindgen]
11626    extern "C" {
11627        /// Options for `Intl.PluralRules` constructor.
11628        ///
11629        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/PluralRules/PluralRules#options)
11630        #[wasm_bindgen(extends = Object)]
11631        #[derive(Clone, Debug)]
11632        pub type PluralRulesOptions;
11633
11634        #[wasm_bindgen(method, getter = localeMatcher)]
11635        pub fn get_locale_matcher(this: &PluralRulesOptions) -> Option<LocaleMatcher>;
11636        #[wasm_bindgen(method, setter = localeMatcher)]
11637        pub fn set_locale_matcher(this: &PluralRulesOptions, value: LocaleMatcher);
11638
11639        #[wasm_bindgen(method, getter = type)]
11640        pub fn get_type(this: &PluralRulesOptions) -> Option<PluralRulesType>;
11641        #[wasm_bindgen(method, setter = type)]
11642        pub fn set_type(this: &PluralRulesOptions, value: PluralRulesType);
11643
11644        #[wasm_bindgen(method, getter = minimumIntegerDigits)]
11645        pub fn get_minimum_integer_digits(this: &PluralRulesOptions) -> Option<u8>;
11646        #[wasm_bindgen(method, setter = minimumIntegerDigits)]
11647        pub fn set_minimum_integer_digits(this: &PluralRulesOptions, value: u8);
11648
11649        #[wasm_bindgen(method, getter = minimumFractionDigits)]
11650        pub fn get_minimum_fraction_digits(this: &PluralRulesOptions) -> Option<u8>;
11651        #[wasm_bindgen(method, setter = minimumFractionDigits)]
11652        pub fn set_minimum_fraction_digits(this: &PluralRulesOptions, value: u8);
11653
11654        #[wasm_bindgen(method, getter = maximumFractionDigits)]
11655        pub fn get_maximum_fraction_digits(this: &PluralRulesOptions) -> Option<u8>;
11656        #[wasm_bindgen(method, setter = maximumFractionDigits)]
11657        pub fn set_maximum_fraction_digits(this: &PluralRulesOptions, value: u8);
11658
11659        #[wasm_bindgen(method, getter = minimumSignificantDigits)]
11660        pub fn get_minimum_significant_digits(this: &PluralRulesOptions) -> Option<u8>;
11661        #[wasm_bindgen(method, setter = minimumSignificantDigits)]
11662        pub fn set_minimum_significant_digits(this: &PluralRulesOptions, value: u8);
11663
11664        #[wasm_bindgen(method, getter = maximumSignificantDigits)]
11665        pub fn get_maximum_significant_digits(this: &PluralRulesOptions) -> Option<u8>;
11666        #[wasm_bindgen(method, setter = maximumSignificantDigits)]
11667        pub fn set_maximum_significant_digits(this: &PluralRulesOptions, value: u8);
11668
11669        #[wasm_bindgen(method, getter = roundingPriority)]
11670        pub fn get_rounding_priority(this: &PluralRulesOptions) -> Option<RoundingPriority>;
11671        #[wasm_bindgen(method, setter = roundingPriority)]
11672        pub fn set_rounding_priority(this: &PluralRulesOptions, value: RoundingPriority);
11673
11674        #[wasm_bindgen(method, getter = roundingIncrement)]
11675        pub fn get_rounding_increment(this: &PluralRulesOptions) -> Option<u32>;
11676        #[wasm_bindgen(method, setter = roundingIncrement)]
11677        pub fn set_rounding_increment(this: &PluralRulesOptions, value: u32);
11678
11679        #[wasm_bindgen(method, getter = roundingMode)]
11680        pub fn get_rounding_mode(this: &PluralRulesOptions) -> Option<RoundingMode>;
11681        #[wasm_bindgen(method, setter = roundingMode)]
11682        pub fn set_rounding_mode(this: &PluralRulesOptions, value: RoundingMode);
11683
11684        #[wasm_bindgen(method, getter = trailingZeroDisplay)]
11685        pub fn get_trailing_zero_display(this: &PluralRulesOptions) -> Option<TrailingZeroDisplay>;
11686        #[wasm_bindgen(method, setter = trailingZeroDisplay)]
11687        pub fn set_trailing_zero_display(this: &PluralRulesOptions, value: TrailingZeroDisplay);
11688    }
11689
11690    impl PluralRulesOptions {
11691        pub fn new() -> PluralRulesOptions {
11692            JsCast::unchecked_into(Object::new())
11693        }
11694    }
11695
11696    impl Default for PluralRulesOptions {
11697        fn default() -> Self {
11698            PluralRulesOptions::new()
11699        }
11700    }
11701
11702    // Intl.ResolvedPluralRulesOptions
11703    #[wasm_bindgen]
11704    extern "C" {
11705        /// Resolved options returned by `Intl.PluralRules.prototype.resolvedOptions()`.
11706        ///
11707        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/PluralRules/resolvedOptions)
11708        #[wasm_bindgen(extends = PluralRulesOptions)]
11709        #[derive(Clone, Debug)]
11710        pub type ResolvedPluralRulesOptions;
11711
11712        /// The resolved locale string.
11713        #[wasm_bindgen(method, getter = locale)]
11714        pub fn get_locale(this: &ResolvedPluralRulesOptions) -> JsString;
11715
11716        /// The plural categories used by the locale.
11717        #[wasm_bindgen(method, getter = pluralCategories)]
11718        pub fn get_plural_categories(this: &ResolvedPluralRulesOptions) -> Array<JsString>;
11719    }
11720
11721    // Intl.PluralRules
11722    #[wasm_bindgen]
11723    extern "C" {
11724        /// The `Intl.PluralRules` object is a constructor for objects
11725        /// that enable plural sensitive formatting and plural language rules.
11726        ///
11727        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules)
11728        #[wasm_bindgen(extends = Object, js_namespace = Intl, typescript_type = "Intl.PluralRules")]
11729        #[derive(Clone, Debug)]
11730        pub type PluralRules;
11731
11732        /// The `Intl.PluralRules` object is a constructor for objects
11733        /// that enable plural sensitive formatting and plural language rules.
11734        ///
11735        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules)
11736        #[cfg(not(js_sys_unstable_apis))]
11737        #[wasm_bindgen(constructor, js_namespace = Intl)]
11738        pub fn new(locales: &Array, options: &Object) -> PluralRules;
11739
11740        /// The `Intl.PluralRules` object is a constructor for objects
11741        /// that enable plural sensitive formatting and plural language rules.
11742        ///
11743        /// Throws a `RangeError` if locales contain invalid values.
11744        ///
11745        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules)
11746        #[cfg(js_sys_unstable_apis)]
11747        #[wasm_bindgen(constructor, js_namespace = Intl, catch)]
11748        pub fn new(
11749            locales: &[JsString],
11750            options: &PluralRulesOptions,
11751        ) -> Result<PluralRules, JsValue>;
11752
11753        /// The `Intl.PluralRules.prototype.resolvedOptions()` method returns a new
11754        /// object with properties reflecting the locale and plural formatting
11755        /// options computed during initialization of this PluralRules object.
11756        ///
11757        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules/resolvedOptions)
11758        #[cfg(not(js_sys_unstable_apis))]
11759        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
11760        pub fn resolved_options(this: &PluralRules) -> Object;
11761
11762        /// The `Intl.PluralRules.prototype.resolvedOptions()` method returns a new
11763        /// object with properties reflecting the locale and plural formatting
11764        /// options computed during initialization of this PluralRules object.
11765        ///
11766        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules/resolvedOptions)
11767        #[cfg(js_sys_unstable_apis)]
11768        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
11769        pub fn resolved_options(this: &PluralRules) -> ResolvedPluralRulesOptions;
11770
11771        /// The `Intl.PluralRules.prototype.select()` method returns a String indicating
11772        /// which plural rule to use for locale-aware formatting.
11773        ///
11774        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules/select)
11775        #[cfg(not(js_sys_unstable_apis))]
11776        #[wasm_bindgen(method, js_namespace = Intl)]
11777        pub fn select(this: &PluralRules, number: f64) -> JsString;
11778
11779        /// The `Intl.PluralRules.prototype.select()` method returns a String indicating
11780        /// which plural rule to use for locale-aware formatting.
11781        ///
11782        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules/select)
11783        #[cfg(js_sys_unstable_apis)]
11784        #[wasm_bindgen(method, js_namespace = Intl)]
11785        pub fn select(this: &PluralRules, number: f64) -> PluralCategory;
11786
11787        /// The `Intl.PluralRules.prototype.selectRange()` method returns a string indicating
11788        /// which plural rule to use for locale-aware formatting of a range of numbers.
11789        ///
11790        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/PluralRules/selectRange)
11791        #[cfg(not(js_sys_unstable_apis))]
11792        #[wasm_bindgen(method, js_namespace = Intl, js_name = selectRange)]
11793        pub fn select_range(this: &PluralRules, start: f64, end: f64) -> JsString;
11794
11795        /// The `Intl.PluralRules.prototype.selectRange()` method returns a string indicating
11796        /// which plural rule to use for locale-aware formatting of a range of numbers.
11797        ///
11798        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/PluralRules/selectRange)
11799        #[cfg(js_sys_unstable_apis)]
11800        #[wasm_bindgen(method, js_namespace = Intl, js_name = selectRange)]
11801        pub fn select_range(this: &PluralRules, start: f64, end: f64) -> PluralCategory;
11802
11803        /// The `Intl.PluralRules.supportedLocalesOf()` method returns an array
11804        /// containing those of the provided locales that are supported in plural
11805        /// formatting without having to fall back to the runtime's default locale.
11806        ///
11807        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules/supportedLocalesOf)
11808        #[cfg(not(js_sys_unstable_apis))]
11809        #[wasm_bindgen(static_method_of = PluralRules, js_namespace = Intl, js_name = supportedLocalesOf)]
11810        pub fn supported_locales_of(locales: &Array, options: &Object) -> Array;
11811
11812        /// The `Intl.PluralRules.supportedLocalesOf()` method returns an array
11813        /// containing those of the provided locales that are supported in plural
11814        /// formatting without having to fall back to the runtime's default locale.
11815        ///
11816        /// Throws a `RangeError` if locales contain invalid values.
11817        ///
11818        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules/supportedLocalesOf)
11819        #[cfg(js_sys_unstable_apis)]
11820        #[wasm_bindgen(static_method_of = PluralRules, js_namespace = Intl, js_name = supportedLocalesOf, catch)]
11821        pub fn supported_locales_of(
11822            locales: &[JsString],
11823            options: &LocaleMatcherOptions,
11824        ) -> Result<Array<JsString>, JsValue>;
11825    }
11826
11827    #[cfg(not(js_sys_unstable_apis))]
11828    impl Default for PluralRules {
11829        fn default() -> Self {
11830            Self::new(
11831                &JsValue::UNDEFINED.unchecked_into(),
11832                &JsValue::UNDEFINED.unchecked_into(),
11833            )
11834        }
11835    }
11836
11837    #[cfg(js_sys_unstable_apis)]
11838    impl Default for PluralRules {
11839        fn default() -> Self {
11840            Self::new(&[], &Default::default()).unwrap()
11841        }
11842    }
11843
11844    // Intl.RelativeTimeFormat
11845    #[wasm_bindgen]
11846    extern "C" {
11847        /// The `Intl.RelativeTimeFormat` object is a constructor for objects
11848        /// that enable language-sensitive relative time formatting.
11849        ///
11850        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat)
11851        #[wasm_bindgen(extends = Object, js_namespace = Intl, typescript_type = "Intl.RelativeTimeFormat")]
11852        #[derive(Clone, Debug)]
11853        pub type RelativeTimeFormat;
11854
11855        /// The `Intl.RelativeTimeFormat` object is a constructor for objects
11856        /// that enable language-sensitive relative time formatting.
11857        ///
11858        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat)
11859        #[cfg(not(js_sys_unstable_apis))]
11860        #[wasm_bindgen(constructor, js_namespace = Intl)]
11861        pub fn new(locales: &Array, options: &Object) -> RelativeTimeFormat;
11862
11863        /// The `Intl.RelativeTimeFormat` object is a constructor for objects
11864        /// that enable language-sensitive relative time formatting.
11865        ///
11866        /// Throws a `RangeError` if locales contain invalid values.
11867        ///
11868        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat)
11869        #[cfg(js_sys_unstable_apis)]
11870        #[wasm_bindgen(constructor, js_namespace = Intl, catch)]
11871        pub fn new(locales: &[JsString]) -> Result<RelativeTimeFormat, JsValue>;
11872
11873        /// The `Intl.RelativeTimeFormat` object is a constructor for objects
11874        /// that enable language-sensitive relative time formatting.
11875        ///
11876        /// Throws a `RangeError` if locales or options contain invalid values.
11877        ///
11878        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat)
11879        #[cfg(js_sys_unstable_apis)]
11880        #[wasm_bindgen(constructor, js_namespace = Intl, catch)]
11881        pub fn new_with_options(
11882            locales: &[JsString],
11883            options: &RelativeTimeFormatOptions,
11884        ) -> Result<RelativeTimeFormat, JsValue>;
11885
11886        /// The `Intl.RelativeTimeFormat.prototype.format` method formats a `value` and `unit`
11887        /// according to the locale and formatting options of this Intl.RelativeTimeFormat object.
11888        ///
11889        /// Throws a `RangeError` if unit is invalid.
11890        ///
11891        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/format)
11892        #[cfg(not(js_sys_unstable_apis))]
11893        #[wasm_bindgen(method, js_class = "Intl.RelativeTimeFormat")]
11894        pub fn format(this: &RelativeTimeFormat, value: f64, unit: &str) -> JsString;
11895
11896        /// The `Intl.RelativeTimeFormat.prototype.format` method formats a `value` and `unit`
11897        /// according to the locale and formatting options of this Intl.RelativeTimeFormat object.
11898        ///
11899        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/format)
11900        #[cfg(js_sys_unstable_apis)]
11901        #[wasm_bindgen(method, js_class = "Intl.RelativeTimeFormat")]
11902        pub fn format(
11903            this: &RelativeTimeFormat,
11904            value: f64,
11905            unit: RelativeTimeFormatUnit,
11906        ) -> JsString;
11907
11908        /// The `Intl.RelativeTimeFormat.prototype.formatToParts()` method returns an array of
11909        /// objects representing the relative time format in parts that can be used for custom locale-aware formatting.
11910        ///
11911        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/formatToParts)
11912        #[cfg(not(js_sys_unstable_apis))]
11913        #[wasm_bindgen(method, js_class = "Intl.RelativeTimeFormat", js_name = formatToParts)]
11914        pub fn format_to_parts(this: &RelativeTimeFormat, value: f64, unit: &str) -> Array;
11915
11916        /// The `Intl.RelativeTimeFormat.prototype.formatToParts()` method returns an array of
11917        /// objects representing the relative time format in parts that can be used for custom locale-aware formatting.
11918        ///
11919        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/formatToParts)
11920        #[cfg(js_sys_unstable_apis)]
11921        #[wasm_bindgen(method, js_class = "Intl.RelativeTimeFormat", js_name = formatToParts)]
11922        pub fn format_to_parts(
11923            this: &RelativeTimeFormat,
11924            value: f64,
11925            unit: RelativeTimeFormatUnit,
11926        ) -> Array<RelativeTimeFormatPart>;
11927
11928        /// The `Intl.RelativeTimeFormat.prototype.resolvedOptions()` method returns a new
11929        /// object with properties reflecting the locale and relative time formatting
11930        /// options computed during initialization of this RelativeTimeFormat object.
11931        ///
11932        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/resolvedOptions)
11933        #[cfg(not(js_sys_unstable_apis))]
11934        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
11935        pub fn resolved_options(this: &RelativeTimeFormat) -> Object;
11936
11937        /// The `Intl.RelativeTimeFormat.prototype.resolvedOptions()` method returns a new
11938        /// object with properties reflecting the locale and relative time formatting
11939        /// options computed during initialization of this RelativeTimeFormat object.
11940        ///
11941        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/resolvedOptions)
11942        #[cfg(js_sys_unstable_apis)]
11943        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
11944        pub fn resolved_options(this: &RelativeTimeFormat) -> ResolvedRelativeTimeFormatOptions;
11945
11946        /// The `Intl.RelativeTimeFormat.supportedLocalesOf()` method returns an array
11947        /// containing those of the provided locales that are supported in date and time
11948        /// formatting without having to fall back to the runtime's default locale.
11949        ///
11950        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RelativeTimeFormat/supportedLocalesOf)
11951        #[cfg(not(js_sys_unstable_apis))]
11952        #[wasm_bindgen(static_method_of = RelativeTimeFormat, js_namespace = Intl, js_name = supportedLocalesOf)]
11953        pub fn supported_locales_of(locales: &Array, options: &Object) -> Array;
11954
11955        /// The `Intl.RelativeTimeFormat.supportedLocalesOf()` method returns an array
11956        /// containing those of the provided locales that are supported in date and time
11957        /// formatting without having to fall back to the runtime's default locale.
11958        ///
11959        /// Throws a `RangeError` if locales contain invalid values.
11960        ///
11961        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RelativeTimeFormat/supportedLocalesOf)
11962        #[cfg(js_sys_unstable_apis)]
11963        #[wasm_bindgen(static_method_of = RelativeTimeFormat, js_namespace = Intl, js_name = supportedLocalesOf, catch)]
11964        pub fn supported_locales_of(
11965            locales: &[JsString],
11966            options: &LocaleMatcherOptions,
11967        ) -> Result<Array<JsString>, JsValue>;
11968    }
11969
11970    #[cfg(not(js_sys_unstable_apis))]
11971    impl Default for RelativeTimeFormat {
11972        fn default() -> Self {
11973            Self::new(
11974                &JsValue::UNDEFINED.unchecked_into(),
11975                &JsValue::UNDEFINED.unchecked_into(),
11976            )
11977        }
11978    }
11979
11980    #[cfg(js_sys_unstable_apis)]
11981    impl Default for RelativeTimeFormat {
11982        fn default() -> Self {
11983            Self::new(&[]).unwrap()
11984        }
11985    }
11986
11987    // Intl.ListFormatOptions
11988    #[wasm_bindgen]
11989    extern "C" {
11990        /// Options for `Intl.ListFormat` constructor.
11991        ///
11992        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/ListFormat#options)
11993        #[wasm_bindgen(extends = Object)]
11994        #[derive(Clone, Debug)]
11995        pub type ListFormatOptions;
11996
11997        #[wasm_bindgen(method, getter = localeMatcher)]
11998        pub fn get_locale_matcher(this: &ListFormatOptions) -> Option<LocaleMatcher>;
11999        #[wasm_bindgen(method, setter = localeMatcher)]
12000        pub fn set_locale_matcher(this: &ListFormatOptions, value: LocaleMatcher);
12001
12002        #[wasm_bindgen(method, getter = type)]
12003        pub fn get_type(this: &ListFormatOptions) -> Option<ListFormatType>;
12004        #[wasm_bindgen(method, setter = type)]
12005        pub fn set_type(this: &ListFormatOptions, value: ListFormatType);
12006
12007        #[wasm_bindgen(method, getter = style)]
12008        pub fn get_style(this: &ListFormatOptions) -> Option<ListFormatStyle>;
12009        #[wasm_bindgen(method, setter = style)]
12010        pub fn set_style(this: &ListFormatOptions, value: ListFormatStyle);
12011    }
12012
12013    impl ListFormatOptions {
12014        pub fn new() -> ListFormatOptions {
12015            JsCast::unchecked_into(Object::new())
12016        }
12017    }
12018
12019    impl Default for ListFormatOptions {
12020        fn default() -> Self {
12021            ListFormatOptions::new()
12022        }
12023    }
12024
12025    // Intl.ResolvedListFormatOptions
12026    #[wasm_bindgen]
12027    extern "C" {
12028        /// Resolved options returned by `Intl.ListFormat.prototype.resolvedOptions()`.
12029        ///
12030        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/resolvedOptions)
12031        #[wasm_bindgen(extends = ListFormatOptions)]
12032        #[derive(Clone, Debug)]
12033        pub type ResolvedListFormatOptions;
12034
12035        /// The resolved locale string.
12036        #[wasm_bindgen(method, getter = locale)]
12037        pub fn get_locale(this: &ResolvedListFormatOptions) -> JsString;
12038    }
12039
12040    // Intl.ListFormatPart
12041    #[wasm_bindgen]
12042    extern "C" {
12043        /// A part of the formatted list returned by `formatToParts()`.
12044        ///
12045        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/formatToParts)
12046        #[wasm_bindgen(extends = Object)]
12047        #[derive(Clone, Debug)]
12048        pub type ListFormatPart;
12049
12050        /// The type of the part ("element" or "literal").
12051        #[wasm_bindgen(method, getter = type)]
12052        pub fn type_(this: &ListFormatPart) -> ListFormatPartType;
12053
12054        /// The value of the part.
12055        #[wasm_bindgen(method, getter)]
12056        pub fn value(this: &ListFormatPart) -> JsString;
12057    }
12058
12059    // Intl.ListFormat
12060    #[wasm_bindgen]
12061    extern "C" {
12062        /// The `Intl.ListFormat` object enables language-sensitive list formatting.
12063        ///
12064        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat)
12065        #[wasm_bindgen(extends = Object, js_namespace = Intl, typescript_type = "Intl.ListFormat")]
12066        #[derive(Clone, Debug)]
12067        pub type ListFormat;
12068
12069        /// Creates a new `Intl.ListFormat` object.
12070        ///
12071        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/ListFormat)
12072        #[cfg(not(js_sys_unstable_apis))]
12073        #[wasm_bindgen(constructor, js_namespace = Intl)]
12074        pub fn new(locales: &Array, options: &Object) -> ListFormat;
12075
12076        /// Creates a new `Intl.ListFormat` object.
12077        ///
12078        /// Throws a `RangeError` if locales or options contain invalid values.
12079        ///
12080        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/ListFormat)
12081        #[cfg(js_sys_unstable_apis)]
12082        #[wasm_bindgen(constructor, js_namespace = Intl, catch)]
12083        pub fn new(
12084            locales: &[JsString],
12085            options: &ListFormatOptions,
12086        ) -> Result<ListFormat, JsValue>;
12087
12088        /// Formats a list of strings according to the locale and options.
12089        ///
12090        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/format)
12091        #[cfg(not(js_sys_unstable_apis))]
12092        #[wasm_bindgen(method, js_class = "Intl.ListFormat")]
12093        pub fn format(this: &ListFormat, list: &Array) -> JsString;
12094
12095        /// Formats a list of strings according to the locale and options.
12096        ///
12097        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/format)
12098        #[cfg(js_sys_unstable_apis)]
12099        #[wasm_bindgen(method, js_class = "Intl.ListFormat")]
12100        pub fn format(this: &ListFormat, list: &[JsString]) -> JsString;
12101
12102        /// Returns an array of objects representing the list in parts.
12103        ///
12104        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/formatToParts)
12105        #[cfg(not(js_sys_unstable_apis))]
12106        #[wasm_bindgen(method, js_class = "Intl.ListFormat", js_name = formatToParts)]
12107        pub fn format_to_parts(this: &ListFormat, list: &Array) -> Array;
12108
12109        /// Returns an array of objects representing the list in parts.
12110        ///
12111        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/formatToParts)
12112        #[cfg(js_sys_unstable_apis)]
12113        #[wasm_bindgen(method, js_class = "Intl.ListFormat", js_name = formatToParts)]
12114        pub fn format_to_parts(this: &ListFormat, list: &[JsString]) -> Array<ListFormatPart>;
12115
12116        /// Returns an object with properties reflecting the options used.
12117        ///
12118        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/resolvedOptions)
12119        #[cfg(not(js_sys_unstable_apis))]
12120        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
12121        pub fn resolved_options(this: &ListFormat) -> Object;
12122
12123        /// Returns an object with properties reflecting the options used.
12124        ///
12125        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/resolvedOptions)
12126        #[cfg(js_sys_unstable_apis)]
12127        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
12128        pub fn resolved_options(this: &ListFormat) -> ResolvedListFormatOptions;
12129
12130        /// Returns an array of supported locales.
12131        ///
12132        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/supportedLocalesOf)
12133        #[cfg(not(js_sys_unstable_apis))]
12134        #[wasm_bindgen(static_method_of = ListFormat, js_namespace = Intl, js_name = supportedLocalesOf)]
12135        pub fn supported_locales_of(locales: &Array, options: &Object) -> Array;
12136
12137        /// Returns an array of supported locales.
12138        ///
12139        /// Throws a `RangeError` if locales contain invalid values.
12140        ///
12141        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/supportedLocalesOf)
12142        #[cfg(js_sys_unstable_apis)]
12143        #[wasm_bindgen(static_method_of = ListFormat, js_namespace = Intl, js_name = supportedLocalesOf, catch)]
12144        pub fn supported_locales_of(
12145            locales: &[JsString],
12146            options: &LocaleMatcherOptions,
12147        ) -> Result<Array<JsString>, JsValue>;
12148    }
12149
12150    #[cfg(not(js_sys_unstable_apis))]
12151    impl Default for ListFormat {
12152        fn default() -> Self {
12153            Self::new(
12154                &JsValue::UNDEFINED.unchecked_into(),
12155                &JsValue::UNDEFINED.unchecked_into(),
12156            )
12157        }
12158    }
12159
12160    #[cfg(js_sys_unstable_apis)]
12161    impl Default for ListFormat {
12162        fn default() -> Self {
12163            Self::new(&[], &Default::default()).unwrap()
12164        }
12165    }
12166
12167    // Intl.SegmenterOptions
12168    #[wasm_bindgen]
12169    extern "C" {
12170        /// Options for `Intl.Segmenter` constructor.
12171        ///
12172        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/Segmenter#options)
12173        #[wasm_bindgen(extends = Object)]
12174        #[derive(Clone, Debug)]
12175        pub type SegmenterOptions;
12176
12177        #[wasm_bindgen(method, getter = localeMatcher)]
12178        pub fn get_locale_matcher(this: &SegmenterOptions) -> Option<LocaleMatcher>;
12179        #[wasm_bindgen(method, setter = localeMatcher)]
12180        pub fn set_locale_matcher(this: &SegmenterOptions, value: LocaleMatcher);
12181
12182        #[wasm_bindgen(method, getter = granularity)]
12183        pub fn get_granularity(this: &SegmenterOptions) -> Option<SegmenterGranularity>;
12184        #[wasm_bindgen(method, setter = granularity)]
12185        pub fn set_granularity(this: &SegmenterOptions, value: SegmenterGranularity);
12186    }
12187
12188    impl SegmenterOptions {
12189        pub fn new() -> SegmenterOptions {
12190            JsCast::unchecked_into(Object::new())
12191        }
12192    }
12193
12194    impl Default for SegmenterOptions {
12195        fn default() -> Self {
12196            SegmenterOptions::new()
12197        }
12198    }
12199
12200    // Intl.ResolvedSegmenterOptions
12201    #[wasm_bindgen]
12202    extern "C" {
12203        /// Resolved options returned by `Intl.Segmenter.prototype.resolvedOptions()`.
12204        ///
12205        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/resolvedOptions)
12206        #[wasm_bindgen(extends = SegmenterOptions)]
12207        #[derive(Clone, Debug)]
12208        pub type ResolvedSegmenterOptions;
12209
12210        /// The resolved locale string.
12211        #[wasm_bindgen(method, getter = locale)]
12212        pub fn get_locale(this: &ResolvedSegmenterOptions) -> JsString;
12213    }
12214
12215    // Intl.SegmentData
12216    #[wasm_bindgen]
12217    extern "C" {
12218        /// Data about a segment returned by the Segments iterator.
12219        ///
12220        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/segment/Segments#segment_data)
12221        #[wasm_bindgen(extends = Object)]
12222        #[derive(Clone, Debug)]
12223        pub type SegmentData;
12224
12225        /// The segment string.
12226        #[wasm_bindgen(method, getter)]
12227        pub fn segment(this: &SegmentData) -> JsString;
12228
12229        /// The index of the segment in the original string.
12230        #[wasm_bindgen(method, getter)]
12231        pub fn index(this: &SegmentData) -> u32;
12232
12233        /// The original input string.
12234        #[wasm_bindgen(method, getter)]
12235        pub fn input(this: &SegmentData) -> JsString;
12236
12237        /// Whether the segment is word-like (only for word granularity).
12238        #[wasm_bindgen(method, getter = isWordLike)]
12239        pub fn is_word_like(this: &SegmentData) -> Option<bool>;
12240    }
12241
12242    // Intl.Segments
12243    #[wasm_bindgen]
12244    extern "C" {
12245        /// The Segments object is an iterable collection of segments of a string.
12246        ///
12247        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/segment/Segments)
12248        #[wasm_bindgen(extends = Object)]
12249        #[derive(Clone, Debug)]
12250        pub type Segments;
12251
12252        /// Returns segment data for the segment containing the character at the given index.
12253        ///
12254        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/segment/Segments/containing)
12255        #[wasm_bindgen(method)]
12256        pub fn containing(this: &Segments, index: u32) -> Option<SegmentData>;
12257    }
12258
12259    // Intl.Segmenter
12260    #[wasm_bindgen]
12261    extern "C" {
12262        /// The `Intl.Segmenter` object enables locale-sensitive text segmentation.
12263        ///
12264        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter)
12265        #[wasm_bindgen(extends = Object, js_namespace = Intl, typescript_type = "Intl.Segmenter")]
12266        #[derive(Clone, Debug)]
12267        pub type Segmenter;
12268
12269        /// Creates a new `Intl.Segmenter` object.
12270        ///
12271        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/Segmenter)
12272        #[cfg(not(js_sys_unstable_apis))]
12273        #[wasm_bindgen(constructor, js_namespace = Intl)]
12274        pub fn new(locales: &Array, options: &Object) -> Segmenter;
12275
12276        /// Creates a new `Intl.Segmenter` object.
12277        ///
12278        /// Throws a `RangeError` if locales or options contain invalid values.
12279        ///
12280        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/Segmenter)
12281        #[cfg(js_sys_unstable_apis)]
12282        #[wasm_bindgen(constructor, js_namespace = Intl, catch)]
12283        pub fn new(locales: &[JsString], options: &SegmenterOptions) -> Result<Segmenter, JsValue>;
12284
12285        /// Returns a Segments object containing the segments of the input string.
12286        ///
12287        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/segment)
12288        #[wasm_bindgen(method, js_class = "Intl.Segmenter")]
12289        pub fn segment(this: &Segmenter, input: &str) -> Segments;
12290
12291        /// Returns an object with properties reflecting the options used.
12292        ///
12293        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/resolvedOptions)
12294        #[cfg(not(js_sys_unstable_apis))]
12295        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
12296        pub fn resolved_options(this: &Segmenter) -> Object;
12297
12298        /// Returns an object with properties reflecting the options used.
12299        ///
12300        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/resolvedOptions)
12301        #[cfg(js_sys_unstable_apis)]
12302        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
12303        pub fn resolved_options(this: &Segmenter) -> ResolvedSegmenterOptions;
12304
12305        /// Returns an array of supported locales.
12306        ///
12307        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/supportedLocalesOf)
12308        #[cfg(not(js_sys_unstable_apis))]
12309        #[wasm_bindgen(static_method_of = Segmenter, js_namespace = Intl, js_name = supportedLocalesOf)]
12310        pub fn supported_locales_of(locales: &Array, options: &Object) -> Array;
12311
12312        /// Returns an array of supported locales.
12313        ///
12314        /// Throws a `RangeError` if locales contain invalid values.
12315        ///
12316        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/supportedLocalesOf)
12317        #[cfg(js_sys_unstable_apis)]
12318        #[wasm_bindgen(static_method_of = Segmenter, js_namespace = Intl, js_name = supportedLocalesOf, catch)]
12319        pub fn supported_locales_of(
12320            locales: &[JsString],
12321            options: &LocaleMatcherOptions,
12322        ) -> Result<Array<JsString>, JsValue>;
12323    }
12324
12325    #[cfg(not(js_sys_unstable_apis))]
12326    impl Default for Segmenter {
12327        fn default() -> Self {
12328            Self::new(
12329                &JsValue::UNDEFINED.unchecked_into(),
12330                &JsValue::UNDEFINED.unchecked_into(),
12331            )
12332        }
12333    }
12334
12335    #[cfg(js_sys_unstable_apis)]
12336    impl Default for Segmenter {
12337        fn default() -> Self {
12338            Self::new(&[], &Default::default()).unwrap()
12339        }
12340    }
12341
12342    // Intl.DisplayNamesOptions
12343    #[wasm_bindgen]
12344    extern "C" {
12345        /// Options for `Intl.DisplayNames` constructor.
12346        ///
12347        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/DisplayNames#options)
12348        #[wasm_bindgen(extends = Object)]
12349        #[derive(Clone, Debug)]
12350        pub type DisplayNamesOptions;
12351
12352        #[wasm_bindgen(method, getter = localeMatcher)]
12353        pub fn get_locale_matcher(this: &DisplayNamesOptions) -> Option<LocaleMatcher>;
12354        #[wasm_bindgen(method, setter = localeMatcher)]
12355        pub fn set_locale_matcher(this: &DisplayNamesOptions, value: LocaleMatcher);
12356
12357        #[wasm_bindgen(method, getter = type)]
12358        pub fn get_type(this: &DisplayNamesOptions) -> Option<DisplayNamesType>;
12359        #[wasm_bindgen(method, setter = type)]
12360        pub fn set_type(this: &DisplayNamesOptions, value: DisplayNamesType);
12361
12362        #[wasm_bindgen(method, getter = style)]
12363        pub fn get_style(this: &DisplayNamesOptions) -> Option<DisplayNamesStyle>;
12364        #[wasm_bindgen(method, setter = style)]
12365        pub fn set_style(this: &DisplayNamesOptions, value: DisplayNamesStyle);
12366
12367        #[wasm_bindgen(method, getter = fallback)]
12368        pub fn get_fallback(this: &DisplayNamesOptions) -> Option<DisplayNamesFallback>;
12369        #[wasm_bindgen(method, setter = fallback)]
12370        pub fn set_fallback(this: &DisplayNamesOptions, value: DisplayNamesFallback);
12371
12372        #[wasm_bindgen(method, getter = languageDisplay)]
12373        pub fn get_language_display(
12374            this: &DisplayNamesOptions,
12375        ) -> Option<DisplayNamesLanguageDisplay>;
12376        #[wasm_bindgen(method, setter = languageDisplay)]
12377        pub fn set_language_display(this: &DisplayNamesOptions, value: DisplayNamesLanguageDisplay);
12378    }
12379
12380    impl DisplayNamesOptions {
12381        pub fn new() -> DisplayNamesOptions {
12382            JsCast::unchecked_into(Object::new())
12383        }
12384    }
12385
12386    impl Default for DisplayNamesOptions {
12387        fn default() -> Self {
12388            DisplayNamesOptions::new()
12389        }
12390    }
12391
12392    // Intl.ResolvedDisplayNamesOptions
12393    #[wasm_bindgen]
12394    extern "C" {
12395        /// Resolved options returned by `Intl.DisplayNames.prototype.resolvedOptions()`.
12396        ///
12397        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/resolvedOptions)
12398        #[wasm_bindgen(extends = DisplayNamesOptions)]
12399        #[derive(Clone, Debug)]
12400        pub type ResolvedDisplayNamesOptions;
12401
12402        /// The resolved locale string.
12403        #[wasm_bindgen(method, getter = locale)]
12404        pub fn get_locale(this: &ResolvedDisplayNamesOptions) -> JsString;
12405    }
12406
12407    // Intl.DisplayNames
12408    #[wasm_bindgen]
12409    extern "C" {
12410        /// The `Intl.DisplayNames` object enables the consistent translation of
12411        /// language, region, and script display names.
12412        ///
12413        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames)
12414        #[wasm_bindgen(extends = Object, js_namespace = Intl, typescript_type = "Intl.DisplayNames")]
12415        #[derive(Clone, Debug)]
12416        pub type DisplayNames;
12417
12418        /// Creates a new `Intl.DisplayNames` object.
12419        ///
12420        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/DisplayNames)
12421        #[cfg(not(js_sys_unstable_apis))]
12422        #[wasm_bindgen(constructor, js_namespace = Intl)]
12423        pub fn new(locales: &Array, options: &Object) -> DisplayNames;
12424
12425        /// Creates a new `Intl.DisplayNames` object.
12426        ///
12427        /// Throws a `RangeError` if locales or options contain invalid values.
12428        ///
12429        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/DisplayNames)
12430        #[cfg(js_sys_unstable_apis)]
12431        #[wasm_bindgen(constructor, js_namespace = Intl, catch)]
12432        pub fn new(
12433            locales: &[JsString],
12434            options: &DisplayNamesOptions,
12435        ) -> Result<DisplayNames, JsValue>;
12436
12437        /// Returns the display name for the given code.
12438        ///
12439        /// Returns `undefined` if fallback is "none" and no name is available.
12440        ///
12441        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/of)
12442        #[wasm_bindgen(method, js_class = "Intl.DisplayNames")]
12443        pub fn of(this: &DisplayNames, code: &str) -> Option<JsString>;
12444
12445        /// Returns an object with properties reflecting the options used.
12446        ///
12447        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/resolvedOptions)
12448        #[cfg(not(js_sys_unstable_apis))]
12449        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
12450        pub fn resolved_options(this: &DisplayNames) -> Object;
12451
12452        /// Returns an object with properties reflecting the options used.
12453        ///
12454        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/resolvedOptions)
12455        #[cfg(js_sys_unstable_apis)]
12456        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
12457        pub fn resolved_options(this: &DisplayNames) -> ResolvedDisplayNamesOptions;
12458
12459        /// Returns an array of supported locales.
12460        ///
12461        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/supportedLocalesOf)
12462        #[cfg(not(js_sys_unstable_apis))]
12463        #[wasm_bindgen(static_method_of = DisplayNames, js_namespace = Intl, js_name = supportedLocalesOf)]
12464        pub fn supported_locales_of(locales: &Array, options: &Object) -> Array;
12465
12466        /// Returns an array of supported locales.
12467        ///
12468        /// Throws a `RangeError` if locales contain invalid values.
12469        ///
12470        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/supportedLocalesOf)
12471        #[cfg(js_sys_unstable_apis)]
12472        #[wasm_bindgen(static_method_of = DisplayNames, js_namespace = Intl, js_name = supportedLocalesOf, catch)]
12473        pub fn supported_locales_of(
12474            locales: &[JsString],
12475            options: &LocaleMatcherOptions,
12476        ) -> Result<Array<JsString>, JsValue>;
12477    }
12478
12479    // Intl.Locale
12480    #[wasm_bindgen]
12481    extern "C" {
12482        /// The `Intl.Locale` object is a standard built-in property of the Intl object
12483        /// that represents a Unicode locale identifier.
12484        ///
12485        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale)
12486        #[wasm_bindgen(extends = Object, js_namespace = Intl, typescript_type = "Intl.Locale")]
12487        #[derive(Clone, Debug)]
12488        pub type Locale;
12489
12490        /// Creates a new `Intl.Locale` object.
12491        ///
12492        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/Locale)
12493        #[wasm_bindgen(constructor, js_namespace = Intl, catch)]
12494        pub fn new(tag: &str) -> Result<Locale, JsValue>;
12495
12496        /// Creates a new `Intl.Locale` object with options.
12497        ///
12498        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/Locale)
12499        #[wasm_bindgen(constructor, js_namespace = Intl, catch)]
12500        pub fn new_with_options(tag: &str, options: &Object) -> Result<Locale, JsValue>;
12501
12502        /// The base name of the locale (language + region + script).
12503        ///
12504        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/baseName)
12505        #[wasm_bindgen(method, getter = baseName)]
12506        pub fn base_name(this: &Locale) -> JsString;
12507
12508        /// The calendar type for the locale.
12509        ///
12510        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/calendar)
12511        #[wasm_bindgen(method, getter)]
12512        pub fn calendar(this: &Locale) -> Option<JsString>;
12513
12514        /// The case first sorting option.
12515        ///
12516        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/caseFirst)
12517        #[wasm_bindgen(method, getter = caseFirst)]
12518        pub fn case_first(this: &Locale) -> Option<JsString>;
12519
12520        /// The collation type for the locale.
12521        ///
12522        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/collation)
12523        #[wasm_bindgen(method, getter)]
12524        pub fn collation(this: &Locale) -> Option<JsString>;
12525
12526        /// The hour cycle for the locale.
12527        ///
12528        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/hourCycle)
12529        #[wasm_bindgen(method, getter = hourCycle)]
12530        pub fn hour_cycle(this: &Locale) -> Option<JsString>;
12531
12532        /// The language code for the locale.
12533        ///
12534        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/language)
12535        #[wasm_bindgen(method, getter)]
12536        pub fn language(this: &Locale) -> JsString;
12537
12538        /// The numbering system for the locale.
12539        ///
12540        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/numberingSystem)
12541        #[wasm_bindgen(method, getter = numberingSystem)]
12542        pub fn numbering_system(this: &Locale) -> Option<JsString>;
12543
12544        /// Whether the locale uses numeric collation.
12545        ///
12546        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/numeric)
12547        #[wasm_bindgen(method, getter)]
12548        pub fn numeric(this: &Locale) -> bool;
12549
12550        /// The region code for the locale.
12551        ///
12552        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/region)
12553        #[wasm_bindgen(method, getter)]
12554        pub fn region(this: &Locale) -> Option<JsString>;
12555
12556        /// The script code for the locale.
12557        ///
12558        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/script)
12559        #[wasm_bindgen(method, getter)]
12560        pub fn script(this: &Locale) -> Option<JsString>;
12561
12562        /// Returns an array of available calendars for the locale.
12563        ///
12564        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getCalendars)
12565        #[wasm_bindgen(method, js_class = "Intl.Locale", js_name = getCalendars)]
12566        pub fn get_calendars(this: &Locale) -> Array<JsString>;
12567
12568        /// Returns an array of available collations for the locale.
12569        ///
12570        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getCollations)
12571        #[wasm_bindgen(method, js_class = "Intl.Locale", js_name = getCollations)]
12572        pub fn get_collations(this: &Locale) -> Array<JsString>;
12573
12574        /// Returns an array of available hour cycles for the locale.
12575        ///
12576        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getHourCycles)
12577        #[wasm_bindgen(method, js_class = "Intl.Locale", js_name = getHourCycles)]
12578        pub fn get_hour_cycles(this: &Locale) -> Array<JsString>;
12579
12580        /// Returns an array of available numbering systems for the locale.
12581        ///
12582        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getNumberingSystems)
12583        #[wasm_bindgen(method, js_class = "Intl.Locale", js_name = getNumberingSystems)]
12584        pub fn get_numbering_systems(this: &Locale) -> Array<JsString>;
12585
12586        /// Returns an array of available time zones for the locale's region.
12587        ///
12588        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getTimeZones)
12589        #[wasm_bindgen(method, js_class = "Intl.Locale", js_name = getTimeZones)]
12590        pub fn get_time_zones(this: &Locale) -> Option<Array<JsString>>;
12591
12592        /// Returns week information for the locale.
12593        ///
12594        /// May not be available in all environments.
12595        ///
12596        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getWeekInfo)
12597        #[wasm_bindgen(method, js_class = "Intl.Locale", js_name = getWeekInfo, catch)]
12598        pub fn get_week_info(this: &Locale) -> Result<WeekInfo, JsValue>;
12599
12600        /// Returns text layout information for the locale.
12601        ///
12602        /// May not be available in all environments.
12603        ///
12604        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getTextInfo)
12605        #[wasm_bindgen(method, js_class = "Intl.Locale", js_name = getTextInfo, catch)]
12606        pub fn get_text_info(this: &Locale) -> Result<TextInfo, JsValue>;
12607
12608        /// Returns a new Locale with the specified calendar.
12609        ///
12610        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/maximize)
12611        #[wasm_bindgen(method, js_class = "Intl.Locale")]
12612        pub fn maximize(this: &Locale) -> Locale;
12613
12614        /// Returns a new Locale with the minimal subtags.
12615        ///
12616        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/minimize)
12617        #[wasm_bindgen(method, js_class = "Intl.Locale")]
12618        pub fn minimize(this: &Locale) -> Locale;
12619    }
12620
12621    // Intl.Locale WeekInfo
12622    #[wasm_bindgen]
12623    extern "C" {
12624        /// Week information for a locale.
12625        ///
12626        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getWeekInfo)
12627        #[wasm_bindgen(extends = Object)]
12628        #[derive(Clone, Debug)]
12629        pub type WeekInfo;
12630
12631        /// The first day of the week (1 = Monday, 7 = Sunday).
12632        #[wasm_bindgen(method, getter = firstDay)]
12633        pub fn first_day(this: &WeekInfo) -> u8;
12634
12635        /// Array of weekend days.
12636        #[wasm_bindgen(method, getter)]
12637        pub fn weekend(this: &WeekInfo) -> Array<Number>;
12638
12639        /// Minimal days in the first week of the year.
12640        #[wasm_bindgen(method, getter = minimalDays)]
12641        pub fn minimal_days(this: &WeekInfo) -> u8;
12642    }
12643
12644    // Intl.Locale TextInfo
12645    #[wasm_bindgen]
12646    extern "C" {
12647        /// Text layout information for a locale.
12648        ///
12649        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getTextInfo)
12650        #[wasm_bindgen(extends = Object)]
12651        #[derive(Clone, Debug)]
12652        pub type TextInfo;
12653
12654        /// The text direction ("ltr" or "rtl").
12655        #[wasm_bindgen(method, getter)]
12656        pub fn direction(this: &TextInfo) -> JsString;
12657    }
12658
12659    // Intl.DurationFormat enums
12660
12661    /// The style for duration formatting.
12662    ///
12663    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/DurationFormat#style)
12664    #[wasm_bindgen]
12665    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
12666    pub enum DurationFormatStyle {
12667        Long = "long",
12668        Short = "short",
12669        Narrow = "narrow",
12670        Digital = "digital",
12671    }
12672
12673    /// The display style for individual duration units.
12674    ///
12675    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/DurationFormat#years)
12676    #[wasm_bindgen]
12677    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
12678    pub enum DurationUnitStyle {
12679        Long = "long",
12680        Short = "short",
12681        Narrow = "narrow",
12682    }
12683
12684    /// The display style for time duration units (hours, minutes, seconds).
12685    ///
12686    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/DurationFormat#hours)
12687    #[wasm_bindgen]
12688    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
12689    pub enum DurationTimeUnitStyle {
12690        Long = "long",
12691        Short = "short",
12692        Narrow = "narrow",
12693        Numeric = "numeric",
12694        #[wasm_bindgen(js_name = "2-digit")]
12695        TwoDigit = "2-digit",
12696    }
12697
12698    /// The display option for duration units.
12699    ///
12700    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/DurationFormat#yearsdisplay)
12701    #[wasm_bindgen]
12702    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
12703    pub enum DurationUnitDisplay {
12704        Auto = "auto",
12705        Always = "always",
12706    }
12707
12708    /// The type of a duration format part.
12709    ///
12710    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/formatToParts#type)
12711    #[wasm_bindgen]
12712    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
12713    pub enum DurationFormatPartType {
12714        Years = "years",
12715        Months = "months",
12716        Weeks = "weeks",
12717        Days = "days",
12718        Hours = "hours",
12719        Minutes = "minutes",
12720        Seconds = "seconds",
12721        Milliseconds = "milliseconds",
12722        Microseconds = "microseconds",
12723        Nanoseconds = "nanoseconds",
12724        Literal = "literal",
12725        Integer = "integer",
12726        Decimal = "decimal",
12727        Fraction = "fraction",
12728    }
12729
12730    // Intl.DurationFormatOptions
12731    #[wasm_bindgen]
12732    extern "C" {
12733        /// Options for `Intl.DurationFormat` constructor.
12734        ///
12735        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/DurationFormat#options)
12736        #[wasm_bindgen(extends = Object)]
12737        #[derive(Clone, Debug)]
12738        pub type DurationFormatOptions;
12739
12740        #[wasm_bindgen(method, getter = localeMatcher)]
12741        pub fn get_locale_matcher(this: &DurationFormatOptions) -> Option<LocaleMatcher>;
12742        #[wasm_bindgen(method, setter = localeMatcher)]
12743        pub fn set_locale_matcher(this: &DurationFormatOptions, value: LocaleMatcher);
12744
12745        #[wasm_bindgen(method, getter = style)]
12746        pub fn get_style(this: &DurationFormatOptions) -> Option<DurationFormatStyle>;
12747        #[wasm_bindgen(method, setter = style)]
12748        pub fn set_style(this: &DurationFormatOptions, value: DurationFormatStyle);
12749
12750        #[wasm_bindgen(method, getter = years)]
12751        pub fn get_years(this: &DurationFormatOptions) -> Option<DurationUnitStyle>;
12752        #[wasm_bindgen(method, setter = years)]
12753        pub fn set_years(this: &DurationFormatOptions, value: DurationUnitStyle);
12754
12755        #[wasm_bindgen(method, getter = yearsDisplay)]
12756        pub fn get_years_display(this: &DurationFormatOptions) -> Option<DurationUnitDisplay>;
12757        #[wasm_bindgen(method, setter = yearsDisplay)]
12758        pub fn set_years_display(this: &DurationFormatOptions, value: DurationUnitDisplay);
12759
12760        #[wasm_bindgen(method, getter = months)]
12761        pub fn get_months(this: &DurationFormatOptions) -> Option<DurationUnitStyle>;
12762        #[wasm_bindgen(method, setter = months)]
12763        pub fn set_months(this: &DurationFormatOptions, value: DurationUnitStyle);
12764
12765        #[wasm_bindgen(method, getter = monthsDisplay)]
12766        pub fn get_months_display(this: &DurationFormatOptions) -> Option<DurationUnitDisplay>;
12767        #[wasm_bindgen(method, setter = monthsDisplay)]
12768        pub fn set_months_display(this: &DurationFormatOptions, value: DurationUnitDisplay);
12769
12770        #[wasm_bindgen(method, getter = weeks)]
12771        pub fn get_weeks(this: &DurationFormatOptions) -> Option<DurationUnitStyle>;
12772        #[wasm_bindgen(method, setter = weeks)]
12773        pub fn set_weeks(this: &DurationFormatOptions, value: DurationUnitStyle);
12774
12775        #[wasm_bindgen(method, getter = weeksDisplay)]
12776        pub fn get_weeks_display(this: &DurationFormatOptions) -> Option<DurationUnitDisplay>;
12777        #[wasm_bindgen(method, setter = weeksDisplay)]
12778        pub fn set_weeks_display(this: &DurationFormatOptions, value: DurationUnitDisplay);
12779
12780        #[wasm_bindgen(method, getter = days)]
12781        pub fn get_days(this: &DurationFormatOptions) -> Option<DurationUnitStyle>;
12782        #[wasm_bindgen(method, setter = days)]
12783        pub fn set_days(this: &DurationFormatOptions, value: DurationUnitStyle);
12784
12785        #[wasm_bindgen(method, getter = daysDisplay)]
12786        pub fn get_days_display(this: &DurationFormatOptions) -> Option<DurationUnitDisplay>;
12787        #[wasm_bindgen(method, setter = daysDisplay)]
12788        pub fn set_days_display(this: &DurationFormatOptions, value: DurationUnitDisplay);
12789
12790        #[wasm_bindgen(method, getter = hours)]
12791        pub fn get_hours(this: &DurationFormatOptions) -> Option<DurationTimeUnitStyle>;
12792        #[wasm_bindgen(method, setter = hours)]
12793        pub fn set_hours(this: &DurationFormatOptions, value: DurationTimeUnitStyle);
12794
12795        #[wasm_bindgen(method, getter = hoursDisplay)]
12796        pub fn get_hours_display(this: &DurationFormatOptions) -> Option<DurationUnitDisplay>;
12797        #[wasm_bindgen(method, setter = hoursDisplay)]
12798        pub fn set_hours_display(this: &DurationFormatOptions, value: DurationUnitDisplay);
12799
12800        #[wasm_bindgen(method, getter = minutes)]
12801        pub fn get_minutes(this: &DurationFormatOptions) -> Option<DurationTimeUnitStyle>;
12802        #[wasm_bindgen(method, setter = minutes)]
12803        pub fn set_minutes(this: &DurationFormatOptions, value: DurationTimeUnitStyle);
12804
12805        #[wasm_bindgen(method, getter = minutesDisplay)]
12806        pub fn get_minutes_display(this: &DurationFormatOptions) -> Option<DurationUnitDisplay>;
12807        #[wasm_bindgen(method, setter = minutesDisplay)]
12808        pub fn set_minutes_display(this: &DurationFormatOptions, value: DurationUnitDisplay);
12809
12810        #[wasm_bindgen(method, getter = seconds)]
12811        pub fn get_seconds(this: &DurationFormatOptions) -> Option<DurationTimeUnitStyle>;
12812        #[wasm_bindgen(method, setter = seconds)]
12813        pub fn set_seconds(this: &DurationFormatOptions, value: DurationTimeUnitStyle);
12814
12815        #[wasm_bindgen(method, getter = secondsDisplay)]
12816        pub fn get_seconds_display(this: &DurationFormatOptions) -> Option<DurationUnitDisplay>;
12817        #[wasm_bindgen(method, setter = secondsDisplay)]
12818        pub fn set_seconds_display(this: &DurationFormatOptions, value: DurationUnitDisplay);
12819
12820        #[wasm_bindgen(method, getter = milliseconds)]
12821        pub fn get_milliseconds(this: &DurationFormatOptions) -> Option<DurationUnitStyle>;
12822        #[wasm_bindgen(method, setter = milliseconds)]
12823        pub fn set_milliseconds(this: &DurationFormatOptions, value: DurationUnitStyle);
12824
12825        #[wasm_bindgen(method, getter = millisecondsDisplay)]
12826        pub fn get_milliseconds_display(
12827            this: &DurationFormatOptions,
12828        ) -> Option<DurationUnitDisplay>;
12829        #[wasm_bindgen(method, setter = millisecondsDisplay)]
12830        pub fn set_milliseconds_display(this: &DurationFormatOptions, value: DurationUnitDisplay);
12831
12832        #[wasm_bindgen(method, getter = microseconds)]
12833        pub fn get_microseconds(this: &DurationFormatOptions) -> Option<DurationUnitStyle>;
12834        #[wasm_bindgen(method, setter = microseconds)]
12835        pub fn set_microseconds(this: &DurationFormatOptions, value: DurationUnitStyle);
12836
12837        #[wasm_bindgen(method, getter = microsecondsDisplay)]
12838        pub fn get_microseconds_display(
12839            this: &DurationFormatOptions,
12840        ) -> Option<DurationUnitDisplay>;
12841        #[wasm_bindgen(method, setter = microsecondsDisplay)]
12842        pub fn set_microseconds_display(this: &DurationFormatOptions, value: DurationUnitDisplay);
12843
12844        #[wasm_bindgen(method, getter = nanoseconds)]
12845        pub fn get_nanoseconds(this: &DurationFormatOptions) -> Option<DurationUnitStyle>;
12846        #[wasm_bindgen(method, setter = nanoseconds)]
12847        pub fn set_nanoseconds(this: &DurationFormatOptions, value: DurationUnitStyle);
12848
12849        #[wasm_bindgen(method, getter = nanosecondsDisplay)]
12850        pub fn get_nanoseconds_display(this: &DurationFormatOptions)
12851            -> Option<DurationUnitDisplay>;
12852        #[wasm_bindgen(method, setter = nanosecondsDisplay)]
12853        pub fn set_nanoseconds_display(this: &DurationFormatOptions, value: DurationUnitDisplay);
12854
12855        #[wasm_bindgen(method, getter = fractionalDigits)]
12856        pub fn get_fractional_digits(this: &DurationFormatOptions) -> Option<u8>;
12857        #[wasm_bindgen(method, setter = fractionalDigits)]
12858        pub fn set_fractional_digits(this: &DurationFormatOptions, value: u8);
12859    }
12860
12861    impl DurationFormatOptions {
12862        pub fn new() -> DurationFormatOptions {
12863            JsCast::unchecked_into(Object::new())
12864        }
12865    }
12866
12867    impl Default for DurationFormatOptions {
12868        fn default() -> Self {
12869            DurationFormatOptions::new()
12870        }
12871    }
12872
12873    // Intl.ResolvedDurationFormatOptions
12874    #[wasm_bindgen]
12875    extern "C" {
12876        /// Resolved options returned by `Intl.DurationFormat.prototype.resolvedOptions()`.
12877        ///
12878        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/resolvedOptions)
12879        #[wasm_bindgen(extends = DurationFormatOptions)]
12880        #[derive(Clone, Debug)]
12881        pub type ResolvedDurationFormatOptions;
12882
12883        /// The resolved locale string.
12884        #[wasm_bindgen(method, getter = locale)]
12885        pub fn get_locale(this: &ResolvedDurationFormatOptions) -> JsString;
12886
12887        /// The resolved numbering system.
12888        #[wasm_bindgen(method, getter = numberingSystem)]
12889        pub fn get_numbering_system(this: &ResolvedDurationFormatOptions) -> JsString;
12890    }
12891
12892    // Intl.Duration (input object for DurationFormat)
12893    #[wasm_bindgen]
12894    extern "C" {
12895        /// A duration object used as input to `Intl.DurationFormat.format()`.
12896        ///
12897        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/format#duration)
12898        #[wasm_bindgen(extends = Object)]
12899        #[derive(Clone, Debug)]
12900        pub type Duration;
12901
12902        #[wasm_bindgen(method, getter)]
12903        pub fn years(this: &Duration) -> Option<f64>;
12904        #[wasm_bindgen(method, setter)]
12905        pub fn set_years(this: &Duration, value: f64);
12906
12907        #[wasm_bindgen(method, getter)]
12908        pub fn months(this: &Duration) -> Option<f64>;
12909        #[wasm_bindgen(method, setter)]
12910        pub fn set_months(this: &Duration, value: f64);
12911
12912        #[wasm_bindgen(method, getter)]
12913        pub fn weeks(this: &Duration) -> Option<f64>;
12914        #[wasm_bindgen(method, setter)]
12915        pub fn set_weeks(this: &Duration, value: f64);
12916
12917        #[wasm_bindgen(method, getter)]
12918        pub fn days(this: &Duration) -> Option<f64>;
12919        #[wasm_bindgen(method, setter)]
12920        pub fn set_days(this: &Duration, value: f64);
12921
12922        #[wasm_bindgen(method, getter)]
12923        pub fn hours(this: &Duration) -> Option<f64>;
12924        #[wasm_bindgen(method, setter)]
12925        pub fn set_hours(this: &Duration, value: f64);
12926
12927        #[wasm_bindgen(method, getter)]
12928        pub fn minutes(this: &Duration) -> Option<f64>;
12929        #[wasm_bindgen(method, setter)]
12930        pub fn set_minutes(this: &Duration, value: f64);
12931
12932        #[wasm_bindgen(method, getter)]
12933        pub fn seconds(this: &Duration) -> Option<f64>;
12934        #[wasm_bindgen(method, setter)]
12935        pub fn set_seconds(this: &Duration, value: f64);
12936
12937        #[wasm_bindgen(method, getter)]
12938        pub fn milliseconds(this: &Duration) -> Option<f64>;
12939        #[wasm_bindgen(method, setter)]
12940        pub fn set_milliseconds(this: &Duration, value: f64);
12941
12942        #[wasm_bindgen(method, getter)]
12943        pub fn microseconds(this: &Duration) -> Option<f64>;
12944        #[wasm_bindgen(method, setter)]
12945        pub fn set_microseconds(this: &Duration, value: f64);
12946
12947        #[wasm_bindgen(method, getter)]
12948        pub fn nanoseconds(this: &Duration) -> Option<f64>;
12949        #[wasm_bindgen(method, setter)]
12950        pub fn set_nanoseconds(this: &Duration, value: f64);
12951    }
12952
12953    impl Duration {
12954        pub fn new() -> Duration {
12955            JsCast::unchecked_into(Object::new())
12956        }
12957    }
12958
12959    impl Default for Duration {
12960        fn default() -> Self {
12961            Duration::new()
12962        }
12963    }
12964
12965    // Intl.DurationFormatPart
12966    #[wasm_bindgen]
12967    extern "C" {
12968        /// A part of the formatted duration returned by `formatToParts()`.
12969        ///
12970        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/formatToParts)
12971        #[wasm_bindgen(extends = Object)]
12972        #[derive(Clone, Debug)]
12973        pub type DurationFormatPart;
12974
12975        /// The type of the part.
12976        #[wasm_bindgen(method, getter = type)]
12977        pub fn type_(this: &DurationFormatPart) -> DurationFormatPartType;
12978
12979        /// The value of the part.
12980        #[wasm_bindgen(method, getter)]
12981        pub fn value(this: &DurationFormatPart) -> JsString;
12982
12983        /// The unit this part represents (if applicable).
12984        #[wasm_bindgen(method, getter)]
12985        pub fn unit(this: &DurationFormatPart) -> Option<JsString>;
12986    }
12987
12988    // Intl.DurationFormat
12989    #[wasm_bindgen]
12990    extern "C" {
12991        /// The `Intl.DurationFormat` object enables language-sensitive duration formatting.
12992        ///
12993        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat)
12994        #[wasm_bindgen(extends = Object, js_namespace = Intl, typescript_type = "Intl.DurationFormat")]
12995        #[derive(Clone, Debug)]
12996        pub type DurationFormat;
12997
12998        /// Creates a new `Intl.DurationFormat` object.
12999        ///
13000        /// Throws a `RangeError` if locales or options contain invalid values.
13001        ///
13002        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/DurationFormat)
13003        #[wasm_bindgen(constructor, js_namespace = Intl, catch)]
13004        pub fn new(
13005            locales: &[JsString],
13006            options: &DurationFormatOptions,
13007        ) -> Result<DurationFormat, JsValue>;
13008
13009        /// Formats a duration according to the locale and formatting options.
13010        ///
13011        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/format)
13012        #[wasm_bindgen(method, js_class = "Intl.DurationFormat")]
13013        pub fn format(this: &DurationFormat, duration: &Duration) -> JsString;
13014
13015        /// Returns an array of objects representing the formatted duration in parts.
13016        ///
13017        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/formatToParts)
13018        #[wasm_bindgen(method, js_class = "Intl.DurationFormat", js_name = formatToParts)]
13019        pub fn format_to_parts(
13020            this: &DurationFormat,
13021            duration: &Duration,
13022        ) -> Array<DurationFormatPart>;
13023
13024        /// Returns an object with properties reflecting the options used.
13025        ///
13026        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/resolvedOptions)
13027        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
13028        pub fn resolved_options(this: &DurationFormat) -> ResolvedDurationFormatOptions;
13029
13030        /// Returns an array of supported locales.
13031        ///
13032        /// Throws a `RangeError` if locales contain invalid values.
13033        ///
13034        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/supportedLocalesOf)
13035        #[wasm_bindgen(static_method_of = DurationFormat, js_namespace = Intl, js_name = supportedLocalesOf, catch)]
13036        pub fn supported_locales_of(
13037            locales: &[JsString],
13038            options: &LocaleMatcherOptions,
13039        ) -> Result<Array<JsString>, JsValue>;
13040    }
13041
13042    impl Default for DurationFormat {
13043        fn default() -> Self {
13044            Self::new(&[], &Default::default()).unwrap()
13045        }
13046    }
13047}
13048
13049#[wasm_bindgen]
13050extern "C" {
13051    /// The `PromiseState` object represents the the status of the promise,
13052    /// as used in `allSettled`.
13053    ///
13054    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/allSettled)
13055    #[must_use]
13056    #[wasm_bindgen(extends = Object, typescript_type = "any")]
13057    #[derive(Clone, Debug)]
13058    pub type PromiseState<T = JsValue>;
13059
13060    /// A string, either "fulfilled" or "rejected", indicating the eventual state of the promise.
13061    #[wasm_bindgen(method, getter = status)]
13062    pub fn get_status<T>(this: &PromiseState<T>) -> String;
13063
13064    /// Only present if status is "fulfilled". The value that the promise was fulfilled with.
13065    #[wasm_bindgen(method, getter = value)]
13066    pub fn get_value<T>(this: &PromiseState<T>) -> Option<T>;
13067
13068    /// Only present if status is "rejected". The reason that the promise was rejected with.
13069    #[wasm_bindgen(method, getter = reason)]
13070    pub fn get_reason<T>(this: &PromiseState<T>) -> Option<JsValue>;
13071}
13072
13073impl<T> PromiseState<T> {
13074    pub fn is_fulfilled(&self) -> bool {
13075        self.get_status() == "fulfilled"
13076    }
13077
13078    pub fn is_rejected(&self) -> bool {
13079        self.get_status() == "rejected"
13080    }
13081}
13082
13083/// Converts a `PromiseState<T>` into a `Result<T, JsValue>`, matching the
13084/// spec invariant that exactly one of the fulfilled value or the rejection
13085/// reason is populated per slot.
13086impl<T: JsGeneric + FromWasmAbi> From<PromiseState<T>> for Result<T, JsValue> {
13087    fn from(state: PromiseState<T>) -> Result<T, JsValue> {
13088        if state.is_fulfilled() {
13089            Ok(state.get_value().unwrap())
13090        } else {
13091            Err(state.get_reason().unwrap())
13092        }
13093    }
13094}
13095
13096// Promise
13097#[wasm_bindgen]
13098extern "C" {
13099    /// The `Promise` object represents the eventual completion (or failure) of
13100    /// an asynchronous operation, and its resulting value.
13101    ///
13102    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
13103    #[must_use]
13104    #[wasm_bindgen(extends = Object, typescript_type = "Promise<any>", no_promising)]
13105    #[derive(Clone, Debug)]
13106    pub type Promise<T = JsValue>;
13107
13108    /// Creates a new `Promise` with the provided executor `cb`
13109    ///
13110    /// The `cb` is a function that is passed with the arguments `resolve` and
13111    /// `reject`. The `cb` function is executed immediately by the `Promise`
13112    /// implementation, passing `resolve` and `reject` functions (the executor
13113    /// is called before the `Promise` constructor even returns the created
13114    /// object). The `resolve` and `reject` functions, when called, resolve or
13115    /// reject the promise, respectively. The executor normally initiates
13116    /// some asynchronous work, and then, once that completes, either calls
13117    /// the `resolve` function to resolve the promise or else rejects it if an
13118    /// error occurred.
13119    ///
13120    /// If an error is thrown in the executor function, the promise is rejected.
13121    /// The return value of the executor is ignored.
13122    ///
13123    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
13124    #[cfg(not(js_sys_unstable_apis))]
13125    #[wasm_bindgen(constructor)]
13126    pub fn new(cb: &mut dyn FnMut(Function, Function)) -> Promise;
13127
13128    /// Creates a new `Promise` with the provided executor `cb`
13129    ///
13130    /// The `cb` is a function that is passed with the arguments `resolve` and
13131    /// `reject`. The `cb` function is executed immediately by the `Promise`
13132    /// implementation, passing `resolve` and `reject` functions (the executor
13133    /// is called before the `Promise` constructor even returns the created
13134    /// object). The `resolve` and `reject` functions, when called, resolve or
13135    /// reject the promise, respectively. The executor normally initiates
13136    /// some asynchronous work, and then, once that completes, either calls
13137    /// the `resolve` function to resolve the promise or else rejects it if an
13138    /// error occurred.
13139    ///
13140    /// If an error is thrown in the executor function, the promise is rejected.
13141    /// The return value of the executor is ignored.
13142    ///
13143    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
13144    #[cfg(js_sys_unstable_apis)]
13145    #[wasm_bindgen(constructor)]
13146    pub fn new<T: JsGeneric>(
13147        cb: &mut dyn FnMut(Function<fn(T) -> Undefined>, Function<fn(JsValue) -> Undefined>),
13148    ) -> Promise<T>;
13149
13150    // Next major: deprecate
13151    /// Creates a new `Promise` with the provided executor `cb`
13152    ///
13153    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
13154    #[wasm_bindgen(constructor)]
13155    pub fn new_typed<T: Promising + JsGeneric>(
13156        cb: &mut dyn FnMut(Function<fn(T) -> Undefined>, Function<fn(JsValue) -> Undefined>),
13157    ) -> Promise<<T as Promising>::Resolution>;
13158
13159    /// The `Promise.all(iterable)` method returns a single `Promise` that
13160    /// resolves when all of the promises in the iterable argument have resolved
13161    /// or when the iterable argument contains no promises. It rejects with the
13162    /// reason of the first promise that rejects.
13163    ///
13164    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all)
13165    #[cfg(not(js_sys_unstable_apis))]
13166    #[wasm_bindgen(static_method_of = Promise)]
13167    pub fn all(obj: &JsValue) -> Promise;
13168
13169    /// The `Promise.all(iterable)` method returns a single `Promise` that
13170    /// resolves when all of the promises in the iterable argument have resolved
13171    /// or when the iterable argument contains no promises. It rejects with the
13172    /// reason of the first promise that rejects.
13173    ///
13174    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all)
13175    #[cfg(js_sys_unstable_apis)]
13176    #[wasm_bindgen(static_method_of = Promise, js_name = all)]
13177    pub fn all<I: Iterable>(obj: &I) -> Promise<Array<<I::Item as Promising>::Resolution>>
13178    where
13179        I::Item: Promising;
13180
13181    // Next major: deprecate
13182    /// The `Promise.all(iterable)` method returns a single `Promise` that
13183    /// resolves when all of the promises in the iterable argument have resolved
13184    /// or when the iterable argument contains no promises. It rejects with the
13185    /// reason of the first promise that rejects.
13186    ///
13187    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all)
13188    #[wasm_bindgen(static_method_of = Promise, js_name = all)]
13189    pub fn all_iterable<I: Iterable>(obj: &I) -> Promise<Array<<I::Item as Promising>::Resolution>>
13190    where
13191        I::Item: Promising;
13192
13193    /// The `Promise.allSettled(iterable)` method returns a single `Promise` that
13194    /// resolves when all of the promises in the iterable argument have either
13195    /// fulfilled or rejected or when the iterable argument contains no promises.
13196    ///
13197    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/allSettled)
13198    #[cfg(not(js_sys_unstable_apis))]
13199    #[wasm_bindgen(static_method_of = Promise, js_name = allSettled)]
13200    pub fn all_settled(obj: &JsValue) -> Promise;
13201
13202    /// The `Promise.allSettled(iterable)` method returns a single `Promise` that
13203    /// resolves when all of the promises in the iterable argument have either
13204    /// fulfilled or rejected or when the iterable argument contains no promises.
13205    ///
13206    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/allSettled)
13207    #[cfg(js_sys_unstable_apis)]
13208    #[wasm_bindgen(static_method_of = Promise, js_name = allSettled)]
13209    pub fn all_settled<I: Iterable>(
13210        obj: &I,
13211    ) -> Promise<Array<PromiseState<<I::Item as Promising>::Resolution>>>
13212    where
13213        I::Item: Promising;
13214
13215    // Next major: deprecate
13216    /// The `Promise.allSettled(iterable)` method returns a single `Promise` that
13217    /// resolves when all of the promises in the iterable argument have either
13218    /// fulfilled or rejected or when the iterable argument contains no promises.
13219    ///
13220    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/allSettled)
13221    #[wasm_bindgen(static_method_of = Promise, js_name = allSettled)]
13222    pub fn all_settled_iterable<I: Iterable>(
13223        obj: &I,
13224    ) -> Promise<Array<PromiseState<<I::Item as Promising>::Resolution>>>
13225    where
13226        I::Item: Promising;
13227
13228    /// The `Promise.any(iterable)` method returns a single `Promise` that
13229    /// resolves when any of the promises in the iterable argument have resolved
13230    /// or when the iterable argument contains no promises. It rejects with an
13231    /// `AggregateError` if all promises in the iterable rejected.
13232    ///
13233    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/any)
13234    #[cfg(not(js_sys_unstable_apis))]
13235    #[wasm_bindgen(static_method_of = Promise)]
13236    pub fn any(obj: &JsValue) -> Promise;
13237
13238    /// The `Promise.any(iterable)` method returns a single `Promise` that
13239    /// resolves when any of the promises in the iterable argument have resolved
13240    /// or when the iterable argument contains no promises. It rejects with an
13241    /// `AggregateError` if all promises in the iterable rejected.
13242    ///
13243    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/any)
13244    #[cfg(js_sys_unstable_apis)]
13245    #[wasm_bindgen(static_method_of = Promise, js_name = any)]
13246    pub fn any<I: Iterable>(obj: &I) -> Promise<<I::Item as Promising>::Resolution>
13247    where
13248        I::Item: Promising;
13249
13250    // Next major: deprecate
13251    /// The `Promise.any(iterable)` method returns a single `Promise` that
13252    /// resolves when any of the promises in the iterable argument have resolved
13253    /// or when the iterable argument contains no promises. It rejects with an
13254    /// `AggregateError` if all promises in the iterable rejected.
13255    ///
13256    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/any)
13257    #[wasm_bindgen(static_method_of = Promise, js_name = any)]
13258    pub fn any_iterable<I: Iterable>(obj: &I) -> Promise<<I::Item as Promising>::Resolution>
13259    where
13260        I::Item: Promising;
13261
13262    /// The `Promise.race(iterable)` method returns a promise that resolves or
13263    /// rejects as soon as one of the promises in the iterable resolves or
13264    /// rejects, with the value or reason from that promise.
13265    ///
13266    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/race)
13267    #[cfg(not(js_sys_unstable_apis))]
13268    #[wasm_bindgen(static_method_of = Promise)]
13269    pub fn race(obj: &JsValue) -> Promise;
13270
13271    /// The `Promise.race(iterable)` method returns a promise that resolves or
13272    /// rejects as soon as one of the promises in the iterable resolves or
13273    /// rejects, with the value or reason from that promise.
13274    ///
13275    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/race)
13276    #[cfg(js_sys_unstable_apis)]
13277    #[wasm_bindgen(static_method_of = Promise, js_name = race)]
13278    pub fn race<I: Iterable>(obj: &I) -> Promise<<I::Item as Promising>::Resolution>
13279    where
13280        I::Item: Promising;
13281
13282    // Next major: deprecate
13283    /// The `Promise.race(iterable)` method returns a promise that resolves or
13284    /// rejects as soon as one of the promises in the iterable resolves or
13285    /// rejects, with the value or reason from that promise.
13286    ///
13287    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/race)
13288    #[wasm_bindgen(static_method_of = Promise, js_name = race)]
13289    pub fn race_iterable<I: Iterable>(obj: &I) -> Promise<<I::Item as Promising>::Resolution>
13290    where
13291        I::Item: Promising;
13292
13293    /// The `Promise.reject(reason)` method returns a `Promise` object that is
13294    /// rejected with the given reason.
13295    ///
13296    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/reject)
13297    #[cfg(not(js_sys_unstable_apis))]
13298    #[wasm_bindgen(static_method_of = Promise)]
13299    pub fn reject(obj: &JsValue) -> Promise;
13300
13301    /// The `Promise.reject(reason)` method returns a `Promise` object that is
13302    /// rejected with the given reason.
13303    ///
13304    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/reject)
13305    #[cfg(js_sys_unstable_apis)]
13306    #[wasm_bindgen(static_method_of = Promise, js_name = reject)]
13307    pub fn reject<T>(obj: &JsValue) -> Promise<T>;
13308
13309    // Next major: deprecate
13310    /// The `Promise.reject(reason)` method returns a `Promise` object that is
13311    /// rejected with the given reason.
13312    ///
13313    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/reject)
13314    #[wasm_bindgen(static_method_of = Promise, js_name = reject)]
13315    pub fn reject_typed<T>(obj: &JsValue) -> Promise<T>;
13316
13317    /// The `Promise.resolve(value)` method returns a `Promise` object that is
13318    /// resolved with the given value. If the value is a promise, that promise
13319    /// is returned; if the value is a thenable (i.e. has a "then" method), the
13320    /// returned promise will "follow" that thenable, adopting its eventual
13321    /// state; otherwise the returned promise will be fulfilled with the value.
13322    ///
13323    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/resolve)
13324    #[wasm_bindgen(static_method_of = Promise, js_name = resolve)]
13325    pub fn resolve<U: Promising>(obj: &U) -> Promise<U::Resolution>;
13326
13327    /// The `catch()` method returns a `Promise` and deals with rejected cases
13328    /// only.  It behaves the same as calling `Promise.prototype.then(undefined,
13329    /// onRejected)` (in fact, calling `obj.catch(onRejected)` internally calls
13330    /// `obj.then(undefined, onRejected)`).
13331    ///
13332    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/catch)
13333    #[cfg(not(js_sys_unstable_apis))]
13334    #[wasm_bindgen(method)]
13335    pub fn catch<T>(this: &Promise<T>, cb: &ScopedClosure<dyn FnMut(JsValue)>) -> Promise<JsValue>;
13336
13337    /// The `catch()` method returns a `Promise` and deals with rejected cases
13338    /// only.  It behaves the same as calling `Promise.prototype.then(undefined,
13339    /// onRejected)` (in fact, calling `obj.catch(onRejected)` internally calls
13340    /// `obj.then(undefined, onRejected)`).
13341    ///
13342    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/catch)
13343    #[cfg(js_sys_unstable_apis)]
13344    #[wasm_bindgen(method, js_name = catch)]
13345    pub fn catch<'a, T, R: Promising>(
13346        this: &Promise<T>,
13347        cb: &ScopedClosure<'a, dyn FnMut(T) -> Result<R, JsError>>,
13348    ) -> Promise<R::Resolution>;
13349
13350    // Next major: deprecate
13351    /// Same as `catch`, but returning a result to become the new Promise value.
13352    #[wasm_bindgen(method, js_name = catch)]
13353    pub fn catch_map<'a, T, R: Promising>(
13354        this: &Promise<T>,
13355        cb: &ScopedClosure<'a, dyn FnMut(T) -> Result<R, JsError>>,
13356    ) -> Promise<R::Resolution>;
13357
13358    /// The `then()` method returns a `Promise`. It takes up to two arguments:
13359    /// callback functions for the success and failure cases of the `Promise`.
13360    ///
13361    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then)
13362    #[cfg(not(js_sys_unstable_apis))]
13363    #[wasm_bindgen(method)]
13364    pub fn then<'a, T>(this: &Promise<T>, cb: &ScopedClosure<'a, dyn FnMut(T)>)
13365        -> Promise<JsValue>;
13366
13367    /// The `then()` method returns a `Promise`. It takes up to two arguments:
13368    /// callback functions for the success and failure cases of the `Promise`.
13369    ///
13370    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then)
13371    #[cfg(js_sys_unstable_apis)]
13372    #[wasm_bindgen(method, js_name = then)]
13373    pub fn then<'a, T, R: Promising>(
13374        this: &Promise<T>,
13375        cb: &ScopedClosure<'a, dyn FnMut(T) -> Result<R, JsError>>,
13376    ) -> Promise<R::Resolution>;
13377
13378    /// The `then()` method returns a `Promise`. It takes up to two arguments:
13379    /// callback functions for the success and failure cases of the `Promise`.
13380    ///
13381    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then)
13382    #[wasm_bindgen(method, js_name = then)]
13383    pub fn then_with_reject<'a, T, R: Promising>(
13384        this: &Promise<T>,
13385        resolve: &ScopedClosure<'a, dyn FnMut(T) -> Result<R, JsError>>,
13386        reject: &ScopedClosure<'a, dyn FnMut(JsValue) -> Result<R, JsError>>,
13387    ) -> Promise<R::Resolution>;
13388
13389    // Next major: deprecate
13390    /// Alias for `then()` with a return value.
13391    /// The `then()` method returns a `Promise`. It takes up to two arguments:
13392    /// callback functions for the success and failure cases of the `Promise`.
13393    ///
13394    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then)
13395    #[wasm_bindgen(method, js_name = then)]
13396    pub fn then_map<'a, T, R: Promising>(
13397        this: &Promise<T>,
13398        cb: &ScopedClosure<'a, dyn FnMut(T) -> Result<R, JsError>>,
13399    ) -> Promise<R::Resolution>;
13400
13401    /// Same as `then`, only with both arguments provided.
13402    ///
13403    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then)
13404    #[wasm_bindgen(method, js_name = then)]
13405    pub fn then2(
13406        this: &Promise,
13407        resolve: &ScopedClosure<dyn FnMut(JsValue)>,
13408        reject: &ScopedClosure<dyn FnMut(JsValue)>,
13409    ) -> Promise;
13410
13411    /// The `finally()` method returns a `Promise`. When the promise is settled,
13412    /// whether fulfilled or rejected, the specified callback function is
13413    /// executed. This provides a way for code that must be executed once the
13414    /// `Promise` has been dealt with to be run whether the promise was
13415    /// fulfilled successfully or rejected.
13416    ///
13417    /// This lets you avoid duplicating code in both the promise's `then()` and
13418    /// `catch()` handlers.
13419    ///
13420    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/finally)
13421    #[wasm_bindgen(method)]
13422    pub fn finally<T>(this: &Promise<T>, cb: &ScopedClosure<dyn FnMut()>) -> Promise<JsValue>;
13423}
13424
13425impl<T: JsGeneric> Promising for Promise<T> {
13426    type Resolution = T;
13427}
13428
13429/// Internal: maps a tuple of `Promise<T_i>` to the result shapes of
13430/// [`Promise::all_tuple`] and [`Promise::all_settled_tuple`].
13431///
13432/// Implemented for every tuple arity 1..=8 of `Promise<T: JsGeneric>`. The
13433/// associated `Joined` / `Settled` types pin down the [`ArrayTuple`] shape
13434/// of the result so the one [`JsCast::unchecked_into`] needed to reinterpret
13435/// the [`Array<JsValue>`] returned by `Promise.all` / `Promise.allSettled`
13436/// is encapsulated inside each impl — the caller sees a fully-typed
13437/// `Promise<ArrayTuple<...>>`.
13438///
13439/// The soundness of the `unchecked_into`s here rests on `Promise.all` and
13440/// `Promise.allSettled` preserving input order and arity, which they do by
13441/// spec.
13442///
13443/// You normally call [`Promise::all_tuple`] / [`Promise::all_settled_tuple`]
13444/// rather than using this trait directly.
13445#[doc(hidden)]
13446pub trait PromiseTuple {
13447    /// The typed `ArrayTuple` shape the joined promise resolves to.
13448    ///
13449    /// For a tuple `(Promise<T1>, Promise<T2>, ...)` this is
13450    /// `ArrayTuple<(T1, T2, ...)>`.
13451    type Joined: JsGeneric;
13452
13453    /// The typed `ArrayTuple` shape the all-settled promise resolves to.
13454    ///
13455    /// For a tuple `(Promise<T1>, Promise<T2>, ...)` this is
13456    /// `ArrayTuple<(PromiseState<T1>, PromiseState<T2>, ...)>`.
13457    type Settled: JsGeneric;
13458
13459    /// Join via `Promise.all`, returning a typed `Promise`.
13460    fn all(self) -> Promise<Self::Joined>;
13461
13462    /// Settle via `Promise.allSettled`, returning a typed `Promise`.
13463    fn all_settled(self) -> Promise<Self::Settled>;
13464}
13465
13466macro_rules! impl_promise_tuple {
13467    ([$($T:ident)+] [$($idx:tt)+]) => {
13468        // Rust tuple of `Promise<T_i>`. Builds the heterogeneous
13469        // `ArrayTuple` of promises via the existing `From<(...)>` impl
13470        // (each element upcasts through `JsGeneric`), then delegates to
13471        // the `ArrayTuple` impl below.
13472        impl<$($T: JsGeneric),+> PromiseTuple for ($(Promise<$T>,)+) {
13473            type Joined = ArrayTuple<($($T,)+)>;
13474            type Settled = ArrayTuple<($(PromiseState<$T>,)+)>;
13475
13476            fn all(self) -> Promise<Self::Joined> {
13477                let tuple: ArrayTuple<($(Promise<$T>,)+)> = ($(self.$idx,)+).into();
13478                tuple.all()
13479            }
13480
13481            fn all_settled(self) -> Promise<Self::Settled> {
13482                let tuple: ArrayTuple<($(Promise<$T>,)+)> = ($(self.$idx,)+).into();
13483                tuple.all_settled()
13484            }
13485        }
13486
13487        // `ArrayTuple<(Promise<T_1>, ..., Promise<T_n>)>` — callers who
13488        // already have an `ArrayTuple` (e.g. from a binding that returns
13489        // one, or built via `.into()` earlier in a pipeline) can pass it
13490        // directly without unpacking into a Rust tuple.
13491        //
13492        // Hands the `ArrayTuple` straight to `Promise.all_iterable` /
13493        // `Promise.allSettled_iterable` and reinterprets the result
13494        // `Array<JsValue>` as the intended typed `ArrayTuple`. Safe because
13495        // `Promise.all` / `Promise.allSettled` preserve input order and
13496        // arity by spec.
13497        impl<$($T: JsGeneric),+> PromiseTuple for ArrayTuple<($(Promise<$T>,)+)> {
13498            type Joined = ArrayTuple<($($T,)+)>;
13499            type Settled = ArrayTuple<($(PromiseState<$T>,)+)>;
13500
13501            fn all(self) -> Promise<Self::Joined> {
13502                use wasm_bindgen::JsCast;
13503                Promise::all_iterable(&self).unchecked_into()
13504            }
13505
13506            fn all_settled(self) -> Promise<Self::Settled> {
13507                use wasm_bindgen::JsCast;
13508                Promise::all_settled_iterable(&self).unchecked_into()
13509            }
13510        }
13511    };
13512}
13513
13514impl_promise_tuple!([T1][0]);
13515impl_promise_tuple!([T1 T2] [0 1]);
13516impl_promise_tuple!([T1 T2 T3] [0 1 2]);
13517impl_promise_tuple!([T1 T2 T3 T4] [0 1 2 3]);
13518impl_promise_tuple!([T1 T2 T3 T4 T5] [0 1 2 3 4]);
13519impl_promise_tuple!([T1 T2 T3 T4 T5 T6] [0 1 2 3 4 5]);
13520impl_promise_tuple!([T1 T2 T3 T4 T5 T6 T7] [0 1 2 3 4 5 6]);
13521impl_promise_tuple!([T1 T2 T3 T4 T5 T6 T7 T8] [0 1 2 3 4 5 6 7]);
13522
13523impl Promise {
13524    /// Heterogeneous counterpart to [`Promise::all_iterable`]: accepts a Rust
13525    /// tuple of `Promise<T_i>` and returns a single [`Promise`] resolving to a
13526    /// typed [`ArrayTuple<(T_1, T_2, ..., T_n)>`].
13527    ///
13528    /// Destructure the awaited result via [`ArrayTuple::into_tuple`] to get
13529    /// the individual values back as a native Rust tuple. Implemented for
13530    /// arity 1..=8.
13531    ///
13532    /// Rejects with the first rejection, matching `Promise.all` semantics.
13533    ///
13534    /// # Example
13535    ///
13536    /// ```ignore
13537    /// use js_sys::Promise;
13538    ///
13539    /// let (response, buffer) = Promise::all_tuple((fetch_promise, buffer_promise))
13540    ///     .await?
13541    ///     .into_tuple();
13542    /// ```
13543    #[inline]
13544    pub fn all_tuple<T: PromiseTuple>(promises: T) -> Promise<T::Joined> {
13545        promises.all()
13546    }
13547
13548    /// Heterogeneous counterpart to [`Promise::all_settled_iterable`]: accepts
13549    /// a Rust tuple of `Promise<T_i>` and returns a single [`Promise`]
13550    /// resolving to a typed
13551    /// `ArrayTuple<(PromiseState<T_1>, ..., PromiseState<T_n>)>`.
13552    ///
13553    /// Unlike [`Promise::all_tuple`], this never rejects early: every input
13554    /// settles (fulfills or rejects) and is reflected by its [`PromiseState`]
13555    /// slot in the result tuple. Implemented for arity 1..=8.
13556    ///
13557    /// # Example
13558    ///
13559    /// ```ignore
13560    /// use js_sys::Promise;
13561    ///
13562    /// let results = Promise::all_settled_tuple((fetch_promise, buffer_promise)).await?;
13563    /// let (response_state, buffer_state) = results.into_tuple();
13564    /// ```
13565    #[inline]
13566    pub fn all_settled_tuple<T: PromiseTuple>(promises: T) -> Promise<T::Settled> {
13567        promises.all_settled()
13568    }
13569}
13570
13571/// Returns a handle to the global scope object.
13572///
13573/// This allows access to the global properties and global names by accessing
13574/// the `Object` returned.
13575pub fn global() -> Object {
13576    use wasm_bindgen::__rt::LazyCell;
13577
13578    #[cfg_attr(target_feature = "atomics", thread_local)]
13579    static GLOBAL: LazyCell<Object> = LazyCell::new(get_global_object);
13580
13581    return GLOBAL.clone();
13582
13583    fn get_global_object() -> Object {
13584        // Accessing the global object is not an easy thing to do, and what we
13585        // basically want is `globalThis` but we can't rely on that existing
13586        // everywhere. In the meantime we've got the fallbacks mentioned in:
13587        //
13588        // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis
13589        //
13590        // Note that this is pretty heavy code-size wise but it at least gets
13591        // the job largely done for now and avoids the `Function` constructor at
13592        // the end which triggers CSP errors.
13593        #[wasm_bindgen]
13594        extern "C" {
13595            #[derive(Clone, Debug)]
13596            type Global;
13597
13598            #[wasm_bindgen(thread_local_v2, js_name = globalThis)]
13599            static GLOBAL_THIS: Option<Object>;
13600
13601            #[wasm_bindgen(thread_local_v2, js_name = self)]
13602            static SELF: Option<Object>;
13603
13604            #[wasm_bindgen(thread_local_v2, js_name = window)]
13605            static WINDOW: Option<Object>;
13606
13607            #[wasm_bindgen(thread_local_v2, js_name = global)]
13608            static GLOBAL: Option<Object>;
13609        }
13610
13611        // The order is important: in Firefox Extension Content Scripts `globalThis`
13612        // is a Sandbox (not Window), so `globalThis` must be checked after `window`.
13613        let static_object = SELF
13614            .with(Option::clone)
13615            .or_else(|| WINDOW.with(Option::clone))
13616            .or_else(|| GLOBAL_THIS.with(Option::clone))
13617            .or_else(|| GLOBAL.with(Option::clone));
13618        if let Some(obj) = static_object {
13619            if !obj.is_undefined() {
13620                return obj;
13621            }
13622        }
13623
13624        // Global object not found
13625        JsValue::undefined().unchecked_into()
13626    }
13627}
13628
13629// Float16Array
13630//
13631// Rust does not yet have a stable builtin `f16`, so the raw JS bindings live
13632// here and any Rust-side helper APIs use explicit `u16` / `f32` naming. The
13633// unsuffixed float APIs are reserved for a future native `f16` binding.
13634#[wasm_bindgen]
13635extern "C" {
13636    #[wasm_bindgen(extends = Object, typescript_type = "Float16Array")]
13637    #[derive(Clone, Debug)]
13638    pub type Float16Array;
13639
13640    /// The `Float16Array()` constructor creates a new array.
13641    ///
13642    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float16Array)
13643    #[wasm_bindgen(constructor)]
13644    pub fn new(constructor_arg: &JsValue) -> Float16Array;
13645
13646    /// The `Float16Array()` constructor creates an array with an internal
13647    /// buffer large enough for `length` elements.
13648    ///
13649    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float16Array)
13650    #[wasm_bindgen(constructor)]
13651    pub fn new_with_length(length: u32) -> Float16Array;
13652
13653    /// The `Float16Array()` constructor creates an array with the given
13654    /// buffer but is a view starting at `byte_offset`.
13655    ///
13656    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float16Array)
13657    #[wasm_bindgen(constructor)]
13658    pub fn new_with_byte_offset(buffer: &JsValue, byte_offset: u32) -> Float16Array;
13659
13660    /// The `Float16Array()` constructor creates an array with the given
13661    /// buffer but is a view starting at `byte_offset` for `length` elements.
13662    ///
13663    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float16Array)
13664    #[wasm_bindgen(constructor)]
13665    pub fn new_with_byte_offset_and_length(
13666        buffer: &JsValue,
13667        byte_offset: u32,
13668        length: u32,
13669    ) -> Float16Array;
13670
13671    /// The `fill()` method fills all elements from a start index to an end
13672    /// index with a static `f32` value.
13673    ///
13674    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/fill)
13675    #[wasm_bindgen(method, js_name = fill)]
13676    pub fn fill_with_f32(this: &Float16Array, value: f32, start: u32, end: u32) -> Float16Array;
13677
13678    /// The buffer accessor property represents the `ArrayBuffer` referenced
13679    /// by a `TypedArray` at construction time.
13680    #[wasm_bindgen(getter, method)]
13681    pub fn buffer(this: &Float16Array) -> ArrayBuffer;
13682
13683    /// The `subarray()` method returns a new `TypedArray` on the same
13684    /// `ArrayBuffer` store and with the same element types as this array.
13685    #[wasm_bindgen(method)]
13686    pub fn subarray(this: &Float16Array, begin: u32, end: u32) -> Float16Array;
13687
13688    /// The `slice()` method returns a shallow copy of a portion of a typed
13689    /// array into a new typed array object.
13690    #[wasm_bindgen(method)]
13691    pub fn slice(this: &Float16Array, begin: u32, end: u32) -> Float16Array;
13692
13693    /// The `forEach()` method executes a provided function once per array
13694    /// element, passing values as `f32`.
13695    #[wasm_bindgen(method, js_name = forEach)]
13696    pub fn for_each_as_f32(this: &Float16Array, callback: &mut dyn FnMut(f32, u32, Float16Array));
13697
13698    /// The `forEach()` method executes a provided function once per array
13699    /// element, passing values as `f32`.
13700    #[wasm_bindgen(method, js_name = forEach, catch)]
13701    pub fn try_for_each_as_f32(
13702        this: &Float16Array,
13703        callback: &mut dyn FnMut(f32, u32, Float16Array) -> Result<(), JsError>,
13704    ) -> Result<(), JsValue>;
13705
13706    /// The length accessor property represents the length (in elements) of a
13707    /// typed array.
13708    #[wasm_bindgen(method, getter)]
13709    pub fn length(this: &Float16Array) -> u32;
13710
13711    /// The byteLength accessor property represents the length (in bytes) of a
13712    /// typed array.
13713    #[wasm_bindgen(method, getter, js_name = byteLength)]
13714    pub fn byte_length(this: &Float16Array) -> u32;
13715
13716    /// The byteOffset accessor property represents the offset (in bytes) of a
13717    /// typed array from the start of its `ArrayBuffer`.
13718    #[wasm_bindgen(method, getter, js_name = byteOffset)]
13719    pub fn byte_offset(this: &Float16Array) -> u32;
13720
13721    /// The `set()` method stores multiple values in the typed array, reading
13722    /// input values from a specified array.
13723    #[wasm_bindgen(method)]
13724    pub fn set(this: &Float16Array, src: &JsValue, offset: u32);
13725
13726    /// Gets the value at `idx` as an `f32`, counting from the end if negative.
13727    #[wasm_bindgen(method, js_name = at)]
13728    pub fn at_as_f32(this: &Float16Array, idx: i32) -> Option<f32>;
13729
13730    /// The `copyWithin()` method shallow copies part of a typed array to another
13731    /// location in the same typed array and returns it, without modifying its size.
13732    ///
13733    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/copyWithin)
13734    #[wasm_bindgen(method, js_name = copyWithin)]
13735    pub fn copy_within(this: &Float16Array, target: i32, start: i32, end: i32) -> Float16Array;
13736
13737    /// Gets the value at `idx` as an `f32`, equivalent to JavaScript
13738    /// `arr[idx]`.
13739    #[wasm_bindgen(method, indexing_getter)]
13740    pub fn get_index_as_f32(this: &Float16Array, idx: u32) -> f32;
13741
13742    /// Sets the value at `idx` from an `f32`, equivalent to JavaScript
13743    /// `arr[idx] = value`.
13744    #[wasm_bindgen(method, indexing_setter)]
13745    pub fn set_index_from_f32(this: &Float16Array, idx: u32, value: f32);
13746}
13747
13748impl Default for Float16Array {
13749    fn default() -> Self {
13750        Self::new(&JsValue::UNDEFINED.unchecked_into())
13751    }
13752}
13753
13754impl TypedArray for Float16Array {}
13755
13756impl Float16Array {
13757    fn as_uint16_view(&self) -> Uint16Array {
13758        let buffer = self.buffer();
13759        Uint16Array::new_with_byte_offset_and_length(
13760            buffer.as_ref(),
13761            self.byte_offset(),
13762            self.length(),
13763        )
13764    }
13765
13766    /// Creates an array from raw IEEE 754 binary16 bit patterns.
13767    ///
13768    /// This pairs naturally with the optional `half` crate:
13769    ///
13770    /// ```rust
13771    /// use half::f16;
13772    /// use js_sys::Float16Array;
13773    ///
13774    /// let values = [f16::from_f32(1.0), f16::from_f32(-2.0)];
13775    /// let bits = values.map(f16::to_bits);
13776    /// let array = Float16Array::new_from_u16_slice(&bits);
13777    /// ```
13778    pub fn new_from_u16_slice(slice: &[u16]) -> Float16Array {
13779        let array = Float16Array::new_with_length(slice.len() as u32);
13780        array.copy_from_u16_slice(slice);
13781        array
13782    }
13783
13784    /// Copy the raw IEEE 754 binary16 bit patterns from this JS typed array
13785    /// into the destination Rust slice.
13786    ///
13787    /// # Panics
13788    ///
13789    /// This function will panic if this typed array's length is different than
13790    /// the length of the provided `dst` array.
13791    ///
13792    /// Values copied into `dst` can be converted back into `half::f16` with
13793    /// `half::f16::from_bits`.
13794    pub fn copy_to_u16_slice(&self, dst: &mut [u16]) {
13795        self.as_uint16_view().copy_to(dst);
13796    }
13797
13798    /// Copy raw IEEE 754 binary16 bit patterns from the source Rust slice into
13799    /// this JS typed array.
13800    ///
13801    /// # Panics
13802    ///
13803    /// This function will panic if this typed array's length is different than
13804    /// the length of the provided `src` array.
13805    ///
13806    /// When using the optional `half` crate, populate `src` with
13807    /// `half::f16::to_bits()`.
13808    pub fn copy_from_u16_slice(&self, src: &[u16]) {
13809        self.as_uint16_view().copy_from(src);
13810    }
13811
13812    /// Efficiently copies the contents of this JS typed array into a new Vec of
13813    /// raw IEEE 754 binary16 bit patterns.
13814    ///
13815    /// This makes it easy to round-trip through the optional `half` crate:
13816    ///
13817    /// ```rust
13818    /// use half::f16;
13819    ///
13820    /// let bits = array.to_u16_vec();
13821    /// let values: Vec<f16> = bits.into_iter().map(f16::from_bits).collect();
13822    /// ```
13823    pub fn to_u16_vec(&self) -> Vec<u16> {
13824        self.as_uint16_view().to_vec()
13825    }
13826}
13827
13828macro_rules! arrays {
13829    ($(#[doc = $ctor:literal] #[doc = $mdn:literal] $name:ident: $ty:ident,)*) => ($(
13830        #[wasm_bindgen]
13831        extern "C" {
13832            #[wasm_bindgen(extends = Object, typescript_type = $name)]
13833            #[derive(Clone, Debug)]
13834            pub type $name;
13835
13836            /// The
13837            #[doc = $ctor]
13838            /// constructor creates a new array.
13839            ///
13840            /// [MDN documentation](
13841            #[doc = $mdn]
13842            /// )
13843            #[wasm_bindgen(constructor)]
13844            pub fn new(constructor_arg: &JsValue) -> $name;
13845
13846            /// An
13847            #[doc = $ctor]
13848            /// which creates an array with an internal buffer large
13849            /// enough for `length` elements.
13850            ///
13851            /// [MDN documentation](
13852            #[doc = $mdn]
13853            /// )
13854            #[wasm_bindgen(constructor)]
13855            pub fn new_with_length(length: u32) -> $name;
13856
13857            /// An
13858            #[doc = $ctor]
13859            /// which creates an array from a Rust slice.
13860            ///
13861            /// [MDN documentation](
13862            #[doc = $mdn]
13863            /// )
13864            #[wasm_bindgen(constructor)]
13865            pub fn new_from_slice(slice: &[$ty]) -> $name;
13866
13867            /// An
13868            #[doc = $ctor]
13869            /// which creates an array with the given buffer but is a
13870            /// view starting at `byte_offset`.
13871            ///
13872            /// [MDN documentation](
13873            #[doc = $mdn]
13874            /// )
13875            #[wasm_bindgen(constructor)]
13876            pub fn new_with_byte_offset(buffer: &JsValue, byte_offset: u32) -> $name;
13877
13878            /// An
13879            #[doc = $ctor]
13880            /// which creates an array with the given buffer but is a
13881            /// view starting at `byte_offset` for `length` elements.
13882            ///
13883            /// [MDN documentation](
13884            #[doc = $mdn]
13885            /// )
13886            #[wasm_bindgen(constructor)]
13887            pub fn new_with_byte_offset_and_length(
13888                buffer: &JsValue,
13889                byte_offset: u32,
13890                length: u32,
13891            ) -> $name;
13892
13893            /// The `fill()` method fills all the elements of an array from a start index
13894            /// to an end index with a static value. The end index is not included.
13895            ///
13896            /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/fill)
13897            #[wasm_bindgen(method)]
13898            pub fn fill(this: &$name, value: $ty, start: u32, end: u32) -> $name;
13899
13900            /// The buffer accessor property represents the `ArrayBuffer` referenced
13901            /// by a `TypedArray` at construction time.
13902            #[wasm_bindgen(getter, method)]
13903            pub fn buffer(this: &$name) -> ArrayBuffer;
13904
13905            /// The `subarray()` method returns a new `TypedArray` on the same
13906            /// `ArrayBuffer` store and with the same element types as for this
13907            /// `TypedArray` object.
13908            #[wasm_bindgen(method)]
13909            pub fn subarray(this: &$name, begin: u32, end: u32) -> $name;
13910
13911            /// The `slice()` method returns a shallow copy of a portion of a typed
13912            /// array into a new typed array object. This method has the same algorithm
13913            /// as `Array.prototype.slice()`.
13914            #[wasm_bindgen(method)]
13915            pub fn slice(this: &$name, begin: u32, end: u32) -> $name;
13916
13917            /// The `forEach()` method executes a provided function once per array
13918            /// element. This method has the same algorithm as
13919            /// `Array.prototype.forEach()`. `TypedArray` is one of the typed array
13920            /// types here.
13921            #[wasm_bindgen(method, js_name = forEach)]
13922            pub fn for_each(this: &$name, callback: &mut dyn FnMut($ty, u32, $name));
13923
13924            /// The `forEach()` method executes a provided function once per array
13925            /// element. This method has the same algorithm as
13926            /// `Array.prototype.forEach()`. `TypedArray` is one of the typed array
13927            /// types here.
13928            #[wasm_bindgen(method, js_name = forEach, catch)]
13929            pub fn try_for_each(this: &$name, callback: &mut dyn FnMut($ty, u32, $name) -> Result<(), JsError>) -> Result<(), JsValue>;
13930
13931            /// The length accessor property represents the length (in elements) of a
13932            /// typed array.
13933            #[wasm_bindgen(method, getter)]
13934            pub fn length(this: &$name) -> u32;
13935
13936            /// The byteLength accessor property represents the length (in bytes) of a
13937            /// typed array.
13938            #[wasm_bindgen(method, getter, js_name = byteLength)]
13939            pub fn byte_length(this: &$name) -> u32;
13940
13941            /// The byteOffset accessor property represents the offset (in bytes) of a
13942            /// typed array from the start of its `ArrayBuffer`.
13943            #[wasm_bindgen(method, getter, js_name = byteOffset)]
13944            pub fn byte_offset(this: &$name) -> u32;
13945
13946            /// The `set()` method stores multiple values in the typed array, reading
13947            /// input values from a specified array.
13948            #[wasm_bindgen(method)]
13949            pub fn set(this: &$name, src: &JsValue, offset: u32);
13950
13951            /// Gets the value at `idx`, counting from the end if negative.
13952            #[wasm_bindgen(method)]
13953            pub fn at(this: &$name, idx: i32) -> Option<$ty>;
13954
13955            /// The `copyWithin()` method shallow copies part of a typed array to another
13956            /// location in the same typed array and returns it, without modifying its size.
13957            ///
13958            /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/copyWithin)
13959            #[wasm_bindgen(method, js_name = copyWithin)]
13960            pub fn copy_within(this: &$name, target: i32, start: i32, end: i32) -> $name;
13961
13962            /// Gets the value at `idx`, equivalent to the javascript `my_var = arr[idx]`.
13963            #[wasm_bindgen(method, indexing_getter)]
13964            pub fn get_index(this: &$name, idx: u32) -> $ty;
13965
13966            /// Sets the value at `idx`, equivalent to the javascript `arr[idx] = value`.
13967            #[wasm_bindgen(method, indexing_setter)]
13968            pub fn set_index(this: &$name, idx: u32, value: $ty);
13969
13970            /// Copies the Rust slice's data to self.
13971            ///
13972            /// This method is not expected to be public. It requires the length of the
13973            /// TypedArray to be the same as the slice, use `self.copy_from(slice)` instead.
13974            #[wasm_bindgen(method, js_name = set)]
13975            fn copy_from_slice(this: &$name, slice: &[$ty]);
13976
13977            /// Copies this TypedArray's data to Rust slice;
13978            ///
13979            /// This method is not expected to be public. It requires the length of the
13980            /// TypedArray to be the same as the slice, use `self.copy_to(slice)` instead.
13981            ///
13982            /// # Workaround
13983            ///
13984            /// We actually need `slice.set(typed_array)` here, but since slice cannot be treated as
13985            /// `Uint8Array` on the Rust side, we use `Uint8Array.prototype.set.call`, which allows
13986            /// us to specify the `this` value inside the function.
13987            ///
13988            /// Therefore, `Uint8Array.prototype.set.call(slice, typed_array)` is equivalent to
13989            /// `slice.set(typed_array)`.
13990            #[wasm_bindgen(js_namespace = $name, js_name = "prototype.set.call")]
13991            fn copy_to_slice(slice: &mut [$ty], this: &$name);
13992        }
13993
13994        impl $name {
13995            /// Creates a JS typed array which is a view into wasm's linear
13996            /// memory at the slice specified.
13997            ///
13998            /// This function returns a new typed array which is a view into
13999            /// wasm's memory. This view does not copy the underlying data.
14000            ///
14001            /// # Safety
14002            ///
14003            /// Views into WebAssembly memory are only valid so long as the
14004            /// backing buffer isn't resized in JS. Once this function is called
14005            /// any future calls to `Box::new` (or malloc of any form) may cause
14006            /// the returned value here to be invalidated. Use with caution!
14007            ///
14008            /// Additionally the returned object can be safely mutated but the
14009            /// input slice isn't guaranteed to be mutable.
14010            ///
14011            /// Finally, the returned object is disconnected from the input
14012            /// slice's lifetime, so there's no guarantee that the data is read
14013            /// at the right time.
14014            pub unsafe fn view(rust: &[$ty]) -> $name {
14015                wasm_bindgen::__rt::wbg_cast(rust)
14016            }
14017
14018            /// Creates a JS typed array which is a view into wasm's linear
14019            /// memory at the specified pointer with specified length.
14020            ///
14021            /// This function returns a new typed array which is a view into
14022            /// wasm's memory. This view does not copy the underlying data.
14023            ///
14024            /// # Safety
14025            ///
14026            /// Views into WebAssembly memory are only valid so long as the
14027            /// backing buffer isn't resized in JS. Once this function is called
14028            /// any future calls to `Box::new` (or malloc of any form) may cause
14029            /// the returned value here to be invalidated. Use with caution!
14030            ///
14031            /// Additionally the returned object can be safely mutated,
14032            /// the changes are guaranteed to be reflected in the input array.
14033            pub unsafe fn view_mut_raw(ptr: *mut $ty, length: usize) -> $name {
14034                let slice = core::slice::from_raw_parts_mut(ptr, length);
14035                Self::view(slice)
14036            }
14037
14038            /// Copy the contents of this JS typed array into the destination
14039            /// Rust pointer.
14040            ///
14041            /// This function will efficiently copy the memory from a typed
14042            /// array into this Wasm module's own linear memory, initializing
14043            /// the memory destination provided.
14044            ///
14045            /// # Safety
14046            ///
14047            /// This function requires `dst` to point to a buffer
14048            /// large enough to fit this array's contents.
14049            pub unsafe fn raw_copy_to_ptr(&self, dst: *mut $ty) {
14050                let slice = core::slice::from_raw_parts_mut(dst, self.length() as usize);
14051                self.copy_to(slice);
14052            }
14053
14054            /// Copy the contents of this JS typed array into the destination
14055            /// Rust slice.
14056            ///
14057            /// This function will efficiently copy the memory from a typed
14058            /// array into this Wasm module's own linear memory, initializing
14059            /// the memory destination provided.
14060            ///
14061            /// # Panics
14062            ///
14063            /// This function will panic if this typed array's length is
14064            /// different than the length of the provided `dst` array.
14065            pub fn copy_to(&self, dst: &mut [$ty]) {
14066                core::assert_eq!(self.length() as usize, dst.len());
14067                $name::copy_to_slice(dst, self);
14068            }
14069
14070            /// Copy the contents of this JS typed array into the destination
14071            /// Rust slice.
14072            ///
14073            /// This function will efficiently copy the memory from a typed
14074            /// array into this Wasm module's own linear memory, initializing
14075            /// the memory destination provided.
14076            ///
14077            /// # Panics
14078            ///
14079            /// This function will panic if this typed array's length is
14080            /// different than the length of the provided `dst` array.
14081            pub fn copy_to_uninit<'dst>(&self, dst: &'dst mut [MaybeUninit<$ty>]) -> &'dst mut [$ty] {
14082                core::assert_eq!(self.length() as usize, dst.len());
14083                let dst = unsafe { &mut *(dst as *mut [MaybeUninit<$ty>] as *mut [$ty]) };
14084                self.copy_to(dst);
14085                dst
14086            }
14087
14088            /// Copy the contents of the source Rust slice into this
14089            /// JS typed array.
14090            ///
14091            /// This function will efficiently copy the memory from within
14092            /// the Wasm module's own linear memory to this typed array.
14093            ///
14094            /// # Panics
14095            ///
14096            /// This function will panic if this typed array's length is
14097            /// different than the length of the provided `src` array.
14098            pub fn copy_from(&self, src: &[$ty]) {
14099                core::assert_eq!(self.length() as usize, src.len());
14100                self.copy_from_slice(src);
14101            }
14102
14103            /// Efficiently copies the contents of this JS typed array into a new Vec.
14104            pub fn to_vec(&self) -> Vec<$ty> {
14105                let len = self.length() as usize;
14106                let mut output = Vec::with_capacity(len);
14107                // Safety: the capacity has been set
14108                unsafe {
14109                    self.raw_copy_to_ptr(output.as_mut_ptr());
14110                    output.set_len(len);
14111                }
14112                output
14113            }
14114        }
14115
14116        impl<'a> From<&'a [$ty]> for $name {
14117            #[inline]
14118            fn from(slice: &'a [$ty]) -> $name {
14119                // This is safe because the `new` function makes a copy if its argument is a TypedArray
14120                $name::new_from_slice(slice)
14121            }
14122        }
14123
14124        impl Default for $name {
14125            fn default() -> Self {
14126                Self::new(&JsValue::UNDEFINED.unchecked_into())
14127            }
14128        }
14129
14130        impl TypedArray for $name {}
14131
14132
14133    )*);
14134}
14135
14136arrays! {
14137    /// `Int8Array()`
14138    /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int8Array
14139    Int8Array: i8,
14140
14141    /// `Int16Array()`
14142    /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int16Array
14143    Int16Array: i16,
14144
14145    /// `Int32Array()`
14146    /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int32Array
14147    Int32Array: i32,
14148
14149    /// `Uint8Array()`
14150    /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array
14151    Uint8Array: u8,
14152
14153    /// `Uint8ClampedArray()`
14154    /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8ClampedArray
14155    Uint8ClampedArray: u8,
14156
14157    /// `Uint16Array()`
14158    /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint16Array
14159    Uint16Array: u16,
14160
14161    /// `Uint32Array()`
14162    /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint32Array
14163    Uint32Array: u32,
14164
14165    /// `Float32Array()`
14166    /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float32Array
14167    Float32Array: f32,
14168
14169    /// `Float64Array()`
14170    /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float64Array
14171    Float64Array: f64,
14172
14173    /// `BigInt64Array()`
14174    /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt64Array
14175    BigInt64Array: i64,
14176
14177    /// `BigUint64Array()`
14178    /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigUint64Array
14179    BigUint64Array: u64,
14180}
14181
14182/// Bridging between JavaScript `Promise`s and Rust `Future`s.
14183///
14184/// Enables `promise.await` directly on any [`Promise`].
14185/// This module is also re-exported by `wasm-bindgen-futures` for backwards compatibility.
14186pub mod futures;