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#![doc(html_root_url = "https://docs.rs/js-sys/0.2")]
20#![cfg_attr(not(feature = "std"), no_std)]
21#![cfg_attr(
22    all(not(feature = "std"), target_feature = "atomics"),
23    feature(thread_local)
24)]
25
26extern crate alloc;
27
28use alloc::string::String;
29use alloc::vec::Vec;
30use core::cmp::Ordering;
31use core::convert::{self, Infallible, TryFrom};
32use core::f64;
33use core::fmt;
34use core::iter::{self, Product, Sum};
35use core::mem;
36use core::ops::{Add, BitAnd, BitOr, BitXor, Div, Mul, Neg, Not, Rem, Shl, Shr, Sub};
37use core::str;
38use core::str::FromStr;
39
40pub use wasm_bindgen;
41use wasm_bindgen::prelude::*;
42
43// When adding new imports:
44//
45// * Keep imports in alphabetical order.
46//
47// * Rename imports with `js_name = ...` according to the note about `camelCase`
48//   and `snake_case` in the module's documentation above.
49//
50// * Include the one sentence summary of the import from the MDN link in the
51//   module's documentation above, and the MDN link itself.
52//
53// * If a function or method can throw an exception, make it catchable by adding
54//   `#[wasm_bindgen(catch)]`.
55//
56// * Add a new `#[test]` into the appropriate file in the
57//   `crates/js-sys/tests/wasm/` directory. If the imported function or method
58//   can throw an exception, make sure to also add test coverage for that case.
59//
60// * Arguments that are `JsValue`s or imported JavaScript types should be taken
61//   by reference.
62
63macro_rules! forward_deref_unop {
64    (impl $imp:ident, $method:ident for $t:ty) => {
65        impl $imp for $t {
66            type Output = <&'static $t as $imp>::Output;
67
68            #[inline]
69            fn $method(self) -> Self::Output {
70                $imp::$method(&self)
71            }
72        }
73    };
74}
75
76macro_rules! forward_deref_binop {
77    (impl $imp:ident, $method:ident for $t:ty) => {
78        impl<'a> $imp<$t> for &'a $t {
79            type Output = <&'static $t as $imp<&'static $t>>::Output;
80
81            #[inline]
82            fn $method(self, other: $t) -> Self::Output {
83                $imp::$method(self, &other)
84            }
85        }
86
87        impl $imp<&$t> for $t {
88            type Output = <&'static $t as $imp<&'static $t>>::Output;
89
90            #[inline]
91            fn $method(self, other: &$t) -> Self::Output {
92                $imp::$method(&self, other)
93            }
94        }
95
96        impl $imp<$t> for $t {
97            type Output = <&'static $t as $imp<&'static $t>>::Output;
98
99            #[inline]
100            fn $method(self, other: $t) -> Self::Output {
101                $imp::$method(&self, &other)
102            }
103        }
104    };
105}
106
107macro_rules! forward_js_unop {
108    (impl $imp:ident, $method:ident for $t:ty) => {
109        impl $imp for &$t {
110            type Output = $t;
111
112            #[inline]
113            fn $method(self) -> Self::Output {
114                $imp::$method(JsValue::as_ref(self)).unchecked_into()
115            }
116        }
117
118        forward_deref_unop!(impl $imp, $method for $t);
119    };
120}
121
122macro_rules! forward_js_binop {
123    (impl $imp:ident, $method:ident for $t:ty) => {
124        impl $imp<&$t> for &$t {
125            type Output = $t;
126
127            #[inline]
128            fn $method(self, other: &$t) -> Self::Output {
129                $imp::$method(JsValue::as_ref(self), JsValue::as_ref(other)).unchecked_into()
130            }
131        }
132
133        forward_deref_binop!(impl $imp, $method for $t);
134    };
135}
136
137macro_rules! sum_product {
138    ($($a:ident)*) => ($(
139        impl Sum for $a {
140            #[inline]
141            fn sum<I: iter::Iterator<Item=Self>>(iter: I) -> Self {
142                iter.fold(
143                    $a::from(0),
144                    |a, b| a + b,
145                )
146            }
147        }
148
149        impl Product for $a {
150            #[inline]
151            fn product<I: iter::Iterator<Item=Self>>(iter: I) -> Self {
152                iter.fold(
153                    $a::from(1),
154                    |a, b| a * b,
155                )
156            }
157        }
158
159        impl<'a> Sum<&'a $a> for $a {
160            fn sum<I: iter::Iterator<Item=&'a Self>>(iter: I) -> Self {
161                iter.fold(
162                    $a::from(0),
163                    |a, b| a + b,
164                )
165            }
166        }
167
168        impl<'a> Product<&'a $a> for $a {
169            #[inline]
170            fn product<I: iter::Iterator<Item=&'a Self>>(iter: I) -> Self {
171                iter.fold(
172                    $a::from(1),
173                    |a, b| a * b,
174                )
175            }
176        }
177    )*)
178}
179
180macro_rules! partialord_ord {
181    ($t:ident) => {
182        impl PartialOrd for $t {
183            #[inline]
184            fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
185                Some(self.cmp(other))
186            }
187
188            #[inline]
189            fn lt(&self, other: &Self) -> bool {
190                JsValue::as_ref(self).lt(JsValue::as_ref(other))
191            }
192
193            #[inline]
194            fn le(&self, other: &Self) -> bool {
195                JsValue::as_ref(self).le(JsValue::as_ref(other))
196            }
197
198            #[inline]
199            fn ge(&self, other: &Self) -> bool {
200                JsValue::as_ref(self).ge(JsValue::as_ref(other))
201            }
202
203            #[inline]
204            fn gt(&self, other: &Self) -> bool {
205                JsValue::as_ref(self).gt(JsValue::as_ref(other))
206            }
207        }
208
209        impl Ord for $t {
210            #[inline]
211            fn cmp(&self, other: &Self) -> Ordering {
212                if self == other {
213                    Ordering::Equal
214                } else if self.lt(other) {
215                    Ordering::Less
216                } else {
217                    Ordering::Greater
218                }
219            }
220        }
221    };
222}
223
224#[wasm_bindgen]
225extern "C" {
226    /// The `decodeURI()` function decodes a Uniform Resource Identifier (URI)
227    /// previously created by `encodeURI` or by a similar routine.
228    ///
229    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURI)
230    #[wasm_bindgen(catch, js_name = decodeURI)]
231    pub fn decode_uri(encoded: &str) -> Result<JsString, JsValue>;
232
233    /// The `decodeURIComponent()` function decodes a Uniform Resource Identifier (URI) component
234    /// previously created by `encodeURIComponent` or by a similar routine.
235    ///
236    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent)
237    #[wasm_bindgen(catch, js_name = decodeURIComponent)]
238    pub fn decode_uri_component(encoded: &str) -> Result<JsString, JsValue>;
239
240    /// The `encodeURI()` function encodes a Uniform Resource Identifier (URI)
241    /// by replacing each instance of certain characters by one, two, three, or
242    /// four escape sequences representing the UTF-8 encoding of the character
243    /// (will only be four escape sequences for characters composed of two
244    /// "surrogate" characters).
245    ///
246    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI)
247    #[wasm_bindgen(js_name = encodeURI)]
248    pub fn encode_uri(decoded: &str) -> JsString;
249
250    /// The `encodeURIComponent()` function encodes a Uniform Resource Identifier (URI) component
251    /// by replacing each instance of certain characters by one, two, three, or four escape sequences
252    /// representing the UTF-8 encoding of the character
253    /// (will only be four escape sequences for characters composed of two "surrogate" characters).
254    ///
255    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent)
256    #[wasm_bindgen(js_name = encodeURIComponent)]
257    pub fn encode_uri_component(decoded: &str) -> JsString;
258
259    /// The `eval()` function evaluates JavaScript code represented as a string.
260    ///
261    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval)
262    #[wasm_bindgen(catch)]
263    pub fn eval(js_source_text: &str) -> Result<JsValue, JsValue>;
264
265    /// The global `isFinite()` function determines whether the passed value is a finite number.
266    /// If needed, the parameter is first converted to a number.
267    ///
268    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/isFinite)
269    #[wasm_bindgen(js_name = isFinite)]
270    pub fn is_finite(value: &JsValue) -> bool;
271
272    /// The `parseInt()` function parses a string argument and returns an integer
273    /// of the specified radix (the base in mathematical numeral systems), or NaN on error.
274    ///
275    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt)
276    #[wasm_bindgen(js_name = parseInt)]
277    pub fn parse_int(text: &str, radix: u8) -> f64;
278
279    /// The `parseFloat()` function parses an argument and returns a floating point number,
280    /// or NaN on error.
281    ///
282    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseFloat)
283    #[wasm_bindgen(js_name = parseFloat)]
284    pub fn parse_float(text: &str) -> f64;
285
286    /// The `escape()` function computes a new string in which certain characters have been
287    /// replaced by a hexadecimal escape sequence.
288    ///
289    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/escape)
290    #[wasm_bindgen]
291    pub fn escape(string: &str) -> JsString;
292
293    /// The `unescape()` function computes a new string in which hexadecimal escape
294    /// sequences are replaced with the character that it represents. The escape sequences might
295    /// be introduced by a function like `escape`. Usually, `decodeURI` or `decodeURIComponent`
296    /// are preferred over `unescape`.
297    ///
298    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/unescape)
299    #[wasm_bindgen]
300    pub fn unescape(string: &str) -> JsString;
301}
302
303// Array
304#[wasm_bindgen]
305extern "C" {
306    #[wasm_bindgen(extends = Object, is_type_of = Array::is_array, typescript_type = "Array<any>")]
307    #[derive(Clone, Debug, PartialEq, Eq)]
308    pub type Array;
309
310    /// Creates a new empty array.
311    #[wasm_bindgen(constructor)]
312    pub fn new() -> Array;
313
314    /// Creates a new array with the specified length (elements are initialized to `undefined`).
315    #[wasm_bindgen(constructor)]
316    pub fn new_with_length(len: u32) -> Array;
317
318    /// Retrieves the element at the index, counting from the end if negative
319    /// (returns `undefined` if the index is out of range).
320    #[wasm_bindgen(method)]
321    pub fn at(this: &Array, index: i32) -> JsValue;
322
323    /// Retrieves the element at the index (returns `undefined` if the index is out of range).
324    #[wasm_bindgen(method, structural, indexing_getter)]
325    pub fn get(this: &Array, index: u32) -> JsValue;
326
327    /// Sets the element at the index (auto-enlarges the array if the index is out of range).
328    #[wasm_bindgen(method, structural, indexing_setter)]
329    pub fn set(this: &Array, index: u32, value: JsValue);
330
331    /// Deletes the element at the index (does nothing if the index is out of range).
332    ///
333    /// The element at the index is set to `undefined`.
334    ///
335    /// This does not resize the array, the array will still be the same length.
336    #[wasm_bindgen(method, structural, indexing_deleter)]
337    pub fn delete(this: &Array, index: u32);
338
339    /// The `Array.from()` method creates a new, shallow-copied `Array` instance
340    /// from an array-like or iterable object.
341    #[wasm_bindgen(static_method_of = Array)]
342    pub fn from(val: &JsValue) -> Array;
343
344    /// The `copyWithin()` method shallow copies part of an array to another
345    /// location in the same array and returns it, without modifying its size.
346    ///
347    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin)
348    #[wasm_bindgen(method, js_name = copyWithin)]
349    pub fn copy_within(this: &Array, target: i32, start: i32, end: i32) -> Array;
350
351    /// The `concat()` method is used to merge two or more arrays. This method
352    /// does not change the existing arrays, but instead returns a new array.
353    ///
354    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat)
355    #[wasm_bindgen(method)]
356    pub fn concat(this: &Array, array: &Array) -> Array;
357
358    /// The `every()` method tests whether all elements in the array pass the test
359    /// implemented by the provided function.
360    ///
361    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every)
362    #[wasm_bindgen(method)]
363    pub fn every(this: &Array, predicate: &mut dyn FnMut(JsValue, u32, Array) -> bool) -> bool;
364
365    /// The `fill()` method fills all the elements of an array from a start index
366    /// to an end index with a static value. The end index is not included.
367    ///
368    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fill)
369    #[wasm_bindgen(method)]
370    pub fn fill(this: &Array, value: &JsValue, start: u32, end: u32) -> Array;
371
372    /// The `filter()` method creates a new array with all elements that pass the
373    /// test implemented by the provided function.
374    ///
375    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter)
376    #[wasm_bindgen(method)]
377    pub fn filter(this: &Array, predicate: &mut dyn FnMut(JsValue, u32, Array) -> bool) -> Array;
378
379    /// The `find()` method returns the value of the first element in the array that satisfies
380    ///  the provided testing function. Otherwise `undefined` is returned.
381    ///
382    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find)
383    #[wasm_bindgen(method)]
384    pub fn find(this: &Array, predicate: &mut dyn FnMut(JsValue, u32, Array) -> bool) -> JsValue;
385
386    /// The `findIndex()` method returns the index of the first element in the array that
387    /// satisfies the provided testing function. Otherwise -1 is returned.
388    ///
389    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex)
390    #[wasm_bindgen(method, js_name = findIndex)]
391    pub fn find_index(this: &Array, predicate: &mut dyn FnMut(JsValue, u32, Array) -> bool) -> i32;
392
393    /// The `findLast()` method of Array instances iterates the array in reverse order
394    /// and returns the value of the first element that satisfies the provided testing function.
395    /// If no elements satisfy the testing function, undefined is returned.
396    ///
397    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findLast)
398    #[wasm_bindgen(method, js_name = findLast)]
399    pub fn find_last(
400        this: &Array,
401        predicate: &mut dyn FnMut(JsValue, u32, Array) -> bool,
402    ) -> JsValue;
403
404    /// The `findLastIndex()` method of Array instances iterates the array in reverse order
405    /// and returns the index of the first element that satisfies the provided testing function.
406    /// If no elements satisfy the testing function, -1 is returned.
407    ///
408    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findLastIndex)
409    #[wasm_bindgen(method, js_name = findLastIndex)]
410    pub fn find_last_index(
411        this: &Array,
412        predicate: &mut dyn FnMut(JsValue, u32, Array) -> bool,
413    ) -> i32;
414
415    /// The `flat()` method creates a new array with all sub-array elements concatenated into it
416    /// recursively up to the specified depth.
417    ///
418    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat)
419    #[wasm_bindgen(method)]
420    pub fn flat(this: &Array, depth: i32) -> Array;
421
422    /// The `flatMap()` method first maps each element using a mapping function, then flattens
423    /// the result into a new array.
424    ///
425    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap)
426    #[wasm_bindgen(method, js_name = flatMap)]
427    pub fn flat_map(
428        this: &Array,
429        callback: &mut dyn FnMut(JsValue, u32, Array) -> Vec<JsValue>,
430    ) -> Array;
431
432    /// The `forEach()` method executes a provided function once for each array element.
433    ///
434    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach)
435    #[wasm_bindgen(method, js_name = forEach)]
436    pub fn for_each(this: &Array, callback: &mut dyn FnMut(JsValue, u32, Array));
437
438    /// The `includes()` method determines whether an array includes a certain
439    /// element, returning true or false as appropriate.
440    ///
441    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes)
442    #[wasm_bindgen(method)]
443    pub fn includes(this: &Array, value: &JsValue, from_index: i32) -> bool;
444
445    /// The `indexOf()` method returns the first index at which a given element
446    /// can be found in the array, or -1 if it is not present.
447    ///
448    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf)
449    #[wasm_bindgen(method, js_name = indexOf)]
450    pub fn index_of(this: &Array, value: &JsValue, from_index: i32) -> i32;
451
452    /// The `Array.isArray()` method determines whether the passed value is an Array.
453    ///
454    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray)
455    #[wasm_bindgen(static_method_of = Array, js_name = isArray)]
456    pub fn is_array(value: &JsValue) -> bool;
457
458    /// The `join()` method joins all elements of an array (or an array-like object)
459    /// into a string and returns this string.
460    ///
461    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join)
462    #[wasm_bindgen(method)]
463    pub fn join(this: &Array, delimiter: &str) -> JsString;
464
465    /// The `lastIndexOf()` method returns the last index at which a given element
466    /// can be found in the array, or -1 if it is not present. The array is
467    /// searched backwards, starting at fromIndex.
468    ///
469    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf)
470    #[wasm_bindgen(method, js_name = lastIndexOf)]
471    pub fn last_index_of(this: &Array, value: &JsValue, from_index: i32) -> i32;
472
473    /// The length property of an object which is an instance of type Array
474    /// sets or returns the number of elements in that array. The value is an
475    /// unsigned, 32-bit integer that is always numerically greater than the
476    /// highest index in the array.
477    ///
478    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/length)
479    #[wasm_bindgen(method, getter, structural)]
480    pub fn length(this: &Array) -> u32;
481
482    /// Sets the length of the array.
483    ///
484    /// If it is set to less than the current length of the array, it will
485    /// shrink the array.
486    ///
487    /// If it is set to more than the current length of the array, it will
488    /// increase the length of the array, filling the new space with empty
489    /// slots.
490    ///
491    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/length)
492    #[wasm_bindgen(method, setter)]
493    pub fn set_length(this: &Array, value: u32);
494
495    /// `map()` calls a provided callback function once for each element in an array,
496    /// in order, and constructs a new array from the results. callback is invoked
497    /// only for indexes of the array which have assigned values, including undefined.
498    /// It is not called for missing elements of the array (that is, indexes that have
499    /// never been set, which have been deleted or which have never been assigned a value).
500    ///
501    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map)
502    #[wasm_bindgen(method)]
503    pub fn map(this: &Array, predicate: &mut dyn FnMut(JsValue, u32, Array) -> JsValue) -> Array;
504
505    /// The `Array.of()` method creates a new Array instance with a variable
506    /// number of arguments, regardless of number or type of the arguments.
507    ///
508    /// The difference between `Array.of()` and the `Array` constructor is in the
509    /// handling of integer arguments: `Array.of(7)` creates an array with a single
510    /// element, `7`, whereas `Array(7)` creates an empty array with a `length`
511    /// property of `7` (Note: this implies an array of 7 empty slots, not slots
512    /// with actual undefined values).
513    ///
514    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/of)
515    ///
516    /// # Notes
517    ///
518    /// There are a few bindings to `of` in `js-sys`: `of1`, `of2`, etc...
519    /// with different arities.
520    #[wasm_bindgen(static_method_of = Array, js_name = of)]
521    pub fn of1(a: &JsValue) -> Array;
522
523    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/of)
524    #[wasm_bindgen(static_method_of = Array, js_name = of)]
525    pub fn of2(a: &JsValue, b: &JsValue) -> Array;
526
527    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/of)
528    #[wasm_bindgen(static_method_of = Array, js_name = of)]
529    pub fn of3(a: &JsValue, b: &JsValue, c: &JsValue) -> Array;
530
531    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/of)
532    #[wasm_bindgen(static_method_of = Array, js_name = of)]
533    pub fn of4(a: &JsValue, b: &JsValue, c: &JsValue, d: &JsValue) -> Array;
534
535    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/of)
536    #[wasm_bindgen(static_method_of = Array, js_name = of)]
537    pub fn of5(a: &JsValue, b: &JsValue, c: &JsValue, d: &JsValue, e: &JsValue) -> Array;
538
539    /// The `pop()` method removes the last element from an array and returns that
540    /// element. This method changes the length of the array.
541    ///
542    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/pop)
543    #[wasm_bindgen(method)]
544    pub fn pop(this: &Array) -> JsValue;
545
546    /// The `push()` method adds one or more elements to the end of an array and
547    /// returns the new length of the array.
548    ///
549    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push)
550    #[wasm_bindgen(method)]
551    pub fn push(this: &Array, value: &JsValue) -> u32;
552
553    /// The `reduce()` method applies a function against an accumulator and each element in
554    /// the array (from left to right) to reduce it to a single value.
555    ///
556    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce)
557    #[wasm_bindgen(method)]
558    pub fn reduce(
559        this: &Array,
560        predicate: &mut dyn FnMut(JsValue, JsValue, u32, Array) -> JsValue,
561        initial_value: &JsValue,
562    ) -> JsValue;
563
564    /// The `reduceRight()` method applies a function against an accumulator and each value
565    /// of the array (from right-to-left) to reduce it to a single value.
566    ///
567    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/ReduceRight)
568    #[wasm_bindgen(method, js_name = reduceRight)]
569    pub fn reduce_right(
570        this: &Array,
571        predicate: &mut dyn FnMut(JsValue, JsValue, u32, Array) -> JsValue,
572        initial_value: &JsValue,
573    ) -> JsValue;
574
575    /// The `reverse()` method reverses an array in place. The first array
576    /// element becomes the last, and the last array element becomes the first.
577    ///
578    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse)
579    #[wasm_bindgen(method)]
580    pub fn reverse(this: &Array) -> Array;
581
582    /// The `shift()` method removes the first element from an array and returns
583    /// that removed element. This method changes the length of the array.
584    ///
585    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/shift)
586    #[wasm_bindgen(method)]
587    pub fn shift(this: &Array) -> JsValue;
588
589    /// The `slice()` method returns a shallow copy of a portion of an array into
590    /// a new array object selected from begin to end (end not included).
591    /// The original array will not be modified.
592    ///
593    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice)
594    #[wasm_bindgen(method)]
595    pub fn slice(this: &Array, start: u32, end: u32) -> Array;
596
597    /// The `some()` method tests whether at least one element in the array passes the test implemented
598    /// by the provided function.
599    /// Note: This method returns false for any condition put on an empty array.
600    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some)
601    #[wasm_bindgen(method)]
602    pub fn some(this: &Array, predicate: &mut dyn FnMut(JsValue) -> bool) -> bool;
603
604    /// The `sort()` method sorts the elements of an array in place and returns
605    /// the array. The sort is not necessarily stable. The default sort
606    /// order is according to string Unicode code points.
607    ///
608    /// The time and space complexity of the sort cannot be guaranteed as it
609    /// is implementation dependent.
610    ///
611    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort)
612    #[wasm_bindgen(method)]
613    pub fn sort(this: &Array) -> Array;
614
615    /// The `splice()` method changes the contents of an array by removing existing elements and/or
616    /// adding new elements.
617    ///
618    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice)
619    #[wasm_bindgen(method)]
620    pub fn splice(this: &Array, start: u32, delete_count: u32, item: &JsValue) -> Array;
621
622    /// The `toLocaleString()` method returns a string representing the elements of the array.
623    /// The elements are converted to Strings using their toLocaleString methods and these
624    /// Strings are separated by a locale-specific String (such as a comma “,”).
625    ///
626    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toLocaleString)
627    #[wasm_bindgen(method, js_name = toLocaleString)]
628    pub fn to_locale_string(this: &Array, locales: &JsValue, options: &JsValue) -> JsString;
629
630    /// The `toString()` method returns a string representing the specified array
631    /// and its elements.
632    ///
633    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toString)
634    #[wasm_bindgen(method, js_name = toString)]
635    pub fn to_string(this: &Array) -> JsString;
636
637    /// The `unshift()` method adds one or more elements to the beginning of an
638    /// array and returns the new length of the array.
639    ///
640    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/unshift)
641    #[wasm_bindgen(method)]
642    pub fn unshift(this: &Array, value: &JsValue) -> u32;
643}
644
645/// Iterator returned by `Array::into_iter`
646#[derive(Debug, Clone)]
647pub struct ArrayIntoIter {
648    range: core::ops::Range<u32>,
649    array: Array,
650}
651
652impl core::iter::Iterator for ArrayIntoIter {
653    type Item = JsValue;
654
655    fn next(&mut self) -> Option<Self::Item> {
656        let index = self.range.next()?;
657        Some(self.array.get(index))
658    }
659
660    #[inline]
661    fn size_hint(&self) -> (usize, Option<usize>) {
662        self.range.size_hint()
663    }
664
665    #[inline]
666    fn count(self) -> usize
667    where
668        Self: Sized,
669    {
670        self.range.count()
671    }
672
673    #[inline]
674    fn last(self) -> Option<Self::Item>
675    where
676        Self: Sized,
677    {
678        let Self { range, array } = self;
679        range.last().map(|index| array.get(index))
680    }
681
682    #[inline]
683    fn nth(&mut self, n: usize) -> Option<Self::Item> {
684        self.range.nth(n).map(|index| self.array.get(index))
685    }
686}
687
688impl core::iter::DoubleEndedIterator for ArrayIntoIter {
689    fn next_back(&mut self) -> Option<Self::Item> {
690        let index = self.range.next_back()?;
691        Some(self.array.get(index))
692    }
693
694    fn nth_back(&mut self, n: usize) -> Option<Self::Item> {
695        self.range.nth_back(n).map(|index| self.array.get(index))
696    }
697}
698
699impl core::iter::FusedIterator for ArrayIntoIter {}
700
701impl core::iter::ExactSizeIterator for ArrayIntoIter {}
702
703/// Iterator returned by `Array::iter`
704#[derive(Debug, Clone)]
705pub struct ArrayIter<'a> {
706    range: core::ops::Range<u32>,
707    array: &'a Array,
708}
709
710impl core::iter::Iterator for ArrayIter<'_> {
711    type Item = JsValue;
712
713    fn next(&mut self) -> Option<Self::Item> {
714        let index = self.range.next()?;
715        Some(self.array.get(index))
716    }
717
718    #[inline]
719    fn size_hint(&self) -> (usize, Option<usize>) {
720        self.range.size_hint()
721    }
722
723    #[inline]
724    fn count(self) -> usize
725    where
726        Self: Sized,
727    {
728        self.range.count()
729    }
730
731    #[inline]
732    fn last(self) -> Option<Self::Item>
733    where
734        Self: Sized,
735    {
736        let Self { range, array } = self;
737        range.last().map(|index| array.get(index))
738    }
739
740    #[inline]
741    fn nth(&mut self, n: usize) -> Option<Self::Item> {
742        self.range.nth(n).map(|index| self.array.get(index))
743    }
744}
745
746impl core::iter::DoubleEndedIterator for ArrayIter<'_> {
747    fn next_back(&mut self) -> Option<Self::Item> {
748        let index = self.range.next_back()?;
749        Some(self.array.get(index))
750    }
751
752    fn nth_back(&mut self, n: usize) -> Option<Self::Item> {
753        self.range.nth_back(n).map(|index| self.array.get(index))
754    }
755}
756
757impl core::iter::FusedIterator for ArrayIter<'_> {}
758
759impl core::iter::ExactSizeIterator for ArrayIter<'_> {}
760
761impl Array {
762    /// Returns an iterator over the values of the JS array.
763    pub fn iter(&self) -> ArrayIter<'_> {
764        ArrayIter {
765            range: 0..self.length(),
766            array: self,
767        }
768    }
769
770    /// Converts the JS array into a new Vec.
771    pub fn to_vec(&self) -> Vec<JsValue> {
772        let len = self.length();
773
774        let mut output = Vec::with_capacity(len as usize);
775
776        for i in 0..len {
777            output.push(self.get(i));
778        }
779
780        output
781    }
782}
783
784impl core::iter::IntoIterator for Array {
785    type Item = JsValue;
786    type IntoIter = ArrayIntoIter;
787
788    fn into_iter(self) -> Self::IntoIter {
789        ArrayIntoIter {
790            range: 0..self.length(),
791            array: self,
792        }
793    }
794}
795
796// TODO pre-initialize the Array with the correct length using TrustedLen
797impl<A> core::iter::FromIterator<A> for Array
798where
799    A: AsRef<JsValue>,
800{
801    fn from_iter<T>(iter: T) -> Array
802    where
803        T: IntoIterator<Item = A>,
804    {
805        let mut out = Array::new();
806        out.extend(iter);
807        out
808    }
809}
810
811impl<A> core::iter::Extend<A> for Array
812where
813    A: AsRef<JsValue>,
814{
815    fn extend<T>(&mut self, iter: T)
816    where
817        T: IntoIterator<Item = A>,
818    {
819        for value in iter {
820            self.push(value.as_ref());
821        }
822    }
823}
824
825impl Default for Array {
826    fn default() -> Self {
827        Self::new()
828    }
829}
830
831// ArrayBuffer
832#[wasm_bindgen]
833extern "C" {
834    #[wasm_bindgen(extends = Object, typescript_type = "ArrayBuffer")]
835    #[derive(Clone, Debug, PartialEq, Eq)]
836    pub type ArrayBuffer;
837
838    /// The `ArrayBuffer` object is used to represent a generic,
839    /// fixed-length raw binary data buffer. You cannot directly
840    /// manipulate the contents of an `ArrayBuffer`; instead, you
841    /// create one of the typed array objects or a `DataView` object
842    /// which represents the buffer in a specific format, and use that
843    /// to read and write the contents of the buffer.
844    ///
845    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer)
846    #[wasm_bindgen(constructor)]
847    pub fn new(length: u32) -> ArrayBuffer;
848
849    /// The byteLength property of an object which is an instance of type ArrayBuffer
850    /// it's an accessor property whose set accessor function is undefined,
851    /// meaning that you can only read this property.
852    /// The value is established when the array is constructed and cannot be changed.
853    /// This property returns 0 if this ArrayBuffer has been detached.
854    ///
855    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/byteLength)
856    #[wasm_bindgen(method, getter, js_name = byteLength)]
857    pub fn byte_length(this: &ArrayBuffer) -> u32;
858
859    /// The `isView()` method returns true if arg is one of the `ArrayBuffer`
860    /// views, such as typed array objects or a DataView; false otherwise.
861    ///
862    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/isView)
863    #[wasm_bindgen(static_method_of = ArrayBuffer, js_name = isView)]
864    pub fn is_view(value: &JsValue) -> bool;
865
866    /// The `slice()` method returns a new `ArrayBuffer` whose contents
867    /// are a copy of this `ArrayBuffer`'s bytes from begin, inclusive,
868    /// up to end, exclusive.
869    ///
870    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/slice)
871    #[wasm_bindgen(method)]
872    pub fn slice(this: &ArrayBuffer, begin: u32) -> ArrayBuffer;
873
874    /// Like `slice()` but with the `end` argument.
875    ///
876    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/slice)
877    #[wasm_bindgen(method, js_name = slice)]
878    pub fn slice_with_end(this: &ArrayBuffer, begin: u32, end: u32) -> ArrayBuffer;
879}
880
881// SharedArrayBuffer
882#[wasm_bindgen]
883extern "C" {
884    #[wasm_bindgen(extends = Object, typescript_type = "SharedArrayBuffer")]
885    #[derive(Clone, Debug)]
886    pub type SharedArrayBuffer;
887
888    /// The `SharedArrayBuffer` object is used to represent a generic,
889    /// fixed-length raw binary data buffer, similar to the `ArrayBuffer`
890    /// object, but in a way that they can be used to create views
891    /// on shared memory. Unlike an `ArrayBuffer`, a `SharedArrayBuffer`
892    /// cannot become detached.
893    ///
894    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer)
895    #[wasm_bindgen(constructor)]
896    pub fn new(length: u32) -> SharedArrayBuffer;
897
898    /// The byteLength accessor property represents the length of
899    /// an `SharedArrayBuffer` in bytes. This is established when
900    /// the `SharedArrayBuffer` is constructed and cannot be changed.
901    ///
902    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/byteLength)
903    #[wasm_bindgen(method, getter, js_name = byteLength)]
904    pub fn byte_length(this: &SharedArrayBuffer) -> u32;
905
906    /// The `slice()` method returns a new `SharedArrayBuffer` whose contents
907    /// are a copy of this `SharedArrayBuffer`'s bytes from begin, inclusive,
908    /// up to end, exclusive.
909    ///
910    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/slice)
911    #[wasm_bindgen(method)]
912    pub fn slice(this: &SharedArrayBuffer, begin: u32) -> SharedArrayBuffer;
913
914    /// Like `slice()` but with the `end` argument.
915    ///
916    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/slice)
917    #[wasm_bindgen(method, js_name = slice)]
918    pub fn slice_with_end(this: &SharedArrayBuffer, begin: u32, end: u32) -> SharedArrayBuffer;
919}
920
921// Array Iterator
922#[wasm_bindgen]
923extern "C" {
924    /// The `keys()` method returns a new Array Iterator object that contains the
925    /// keys for each index in the array.
926    ///
927    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/keys)
928    #[wasm_bindgen(method)]
929    pub fn keys(this: &Array) -> Iterator;
930
931    /// The `entries()` method returns a new Array Iterator object that contains
932    /// the key/value pairs for each index in the array.
933    ///
934    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/entries)
935    #[wasm_bindgen(method)]
936    pub fn entries(this: &Array) -> Iterator;
937
938    /// The `values()` method returns a new Array Iterator object that
939    /// contains the values for each index in the array.
940    ///
941    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/values)
942    #[wasm_bindgen(method)]
943    pub fn values(this: &Array) -> Iterator;
944}
945
946/// The `Atomics` object provides atomic operations as static methods.
947/// They are used with `SharedArrayBuffer` objects.
948///
949/// The Atomic operations are installed on an `Atomics` module. Unlike
950/// the other global objects, `Atomics` is not a constructor. You cannot
951/// use it with a new operator or invoke the `Atomics` object as a
952/// function. All properties and methods of `Atomics` are static
953/// (as is the case with the Math object, for example).
954/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics)
955#[allow(non_snake_case)]
956pub mod Atomics {
957    use super::*;
958
959    #[wasm_bindgen]
960    extern "C" {
961        /// The static `Atomics.add()` method adds a given value at a given
962        /// position in the array and returns the old value at that position.
963        /// This atomic operation guarantees that no other write happens
964        /// until the modified value is written back.
965        ///
966        /// You should use `add_bigint` to operate on a `BigInt64Array` or a `BigUint64Array`.
967        ///
968        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/add)
969        #[wasm_bindgen(js_namespace = Atomics, catch)]
970        pub fn add(typed_array: &JsValue, index: u32, value: i32) -> Result<i32, JsValue>;
971
972        /// The static `Atomics.add()` method adds a given value at a given
973        /// position in the array and returns the old value at that position.
974        /// This atomic operation guarantees that no other write happens
975        /// until the modified value is written back.
976        ///
977        /// This method is used to operate on a `BigInt64Array` or a `BigUint64Array`.
978        ///
979        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/add)
980        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = add)]
981        pub fn add_bigint(typed_array: &JsValue, index: u32, value: i64) -> Result<i64, JsValue>;
982
983        /// The static `Atomics.and()` method computes a bitwise AND with a given
984        /// value at a given position in the array, and returns the old value
985        /// at that position.
986        /// This atomic operation guarantees that no other write happens
987        /// until the modified value is written back.
988        ///
989        /// You should use `and_bigint` to operate on a `BigInt64Array` or a `BigUint64Array`.
990        ///
991        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/and)
992        #[wasm_bindgen(js_namespace = Atomics, catch)]
993        pub fn and(typed_array: &JsValue, index: u32, value: i32) -> Result<i32, JsValue>;
994
995        /// The static `Atomics.and()` method computes a bitwise AND with a given
996        /// value at a given position in the array, and returns the old value
997        /// at that position.
998        /// This atomic operation guarantees that no other write happens
999        /// until the modified value is written back.
1000        ///
1001        /// This method is used to operate on a `BigInt64Array` or a `BigUint64Array`.
1002        ///
1003        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/and)
1004        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = and)]
1005        pub fn and_bigint(typed_array: &JsValue, index: u32, value: i64) -> Result<i64, JsValue>;
1006
1007        /// The static `Atomics.compareExchange()` method exchanges a given
1008        /// replacement value at a given position in the array, if a given expected
1009        /// value equals the old value. It returns the old value at that position
1010        /// whether it was equal to the expected value or not.
1011        /// This atomic operation guarantees that no other write happens
1012        /// until the modified value is written back.
1013        ///
1014        /// You should use `compare_exchange_bigint` to operate on a `BigInt64Array` or a `BigUint64Array`.
1015        ///
1016        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/compareExchange)
1017        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = compareExchange)]
1018        pub fn compare_exchange(
1019            typed_array: &JsValue,
1020            index: u32,
1021            expected_value: i32,
1022            replacement_value: i32,
1023        ) -> Result<i32, JsValue>;
1024
1025        /// The static `Atomics.compareExchange()` method exchanges a given
1026        /// replacement value at a given position in the array, if a given expected
1027        /// value equals the old value. It returns the old value at that position
1028        /// whether it was equal to the expected value or not.
1029        /// This atomic operation guarantees that no other write happens
1030        /// until the modified value is written back.
1031        ///
1032        /// This method is used to operate on a `BigInt64Array` or a `BigUint64Array`.
1033        ///
1034        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/compareExchange)
1035        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = compareExchange)]
1036        pub fn compare_exchange_bigint(
1037            typed_array: &JsValue,
1038            index: u32,
1039            expected_value: i64,
1040            replacement_value: i64,
1041        ) -> Result<i64, JsValue>;
1042
1043        /// The static `Atomics.exchange()` method stores a given value at a given
1044        /// position in the array and returns the old value at that position.
1045        /// This atomic operation guarantees that no other write happens
1046        /// until the modified value is written back.
1047        ///
1048        /// You should use `exchange_bigint` to operate on a `BigInt64Array` or a `BigUint64Array`.
1049        ///
1050        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/exchange)
1051        #[wasm_bindgen(js_namespace = Atomics, catch)]
1052        pub fn exchange(typed_array: &JsValue, index: u32, value: i32) -> Result<i32, JsValue>;
1053
1054        /// The static `Atomics.exchange()` method stores a given value at a given
1055        /// position in the array and returns the old value at that position.
1056        /// This atomic operation guarantees that no other write happens
1057        /// until the modified value is written back.
1058        ///
1059        /// This method is used to operate on a `BigInt64Array` or a `BigUint64Array`.
1060        ///
1061        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/exchange)
1062        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = exchange)]
1063        pub fn exchange_bigint(
1064            typed_array: &JsValue,
1065            index: u32,
1066            value: i64,
1067        ) -> Result<i64, JsValue>;
1068
1069        /// The static `Atomics.isLockFree()` method is used to determine
1070        /// whether to use locks or atomic operations. It returns true,
1071        /// if the given size is one of the `BYTES_PER_ELEMENT` property
1072        /// of integer `TypedArray` types.
1073        ///
1074        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/isLockFree)
1075        #[wasm_bindgen(js_namespace = Atomics, js_name = isLockFree)]
1076        pub fn is_lock_free(size: u32) -> bool;
1077
1078        /// The static `Atomics.load()` method returns a value at a given
1079        /// position in the array.
1080        ///
1081        /// You should use `load_bigint` to operate on a `BigInt64Array` or a `BigUint64Array`.
1082        ///
1083        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/load)
1084        #[wasm_bindgen(js_namespace = Atomics, catch)]
1085        pub fn load(typed_array: &JsValue, index: u32) -> Result<i32, JsValue>;
1086
1087        /// The static `Atomics.load()` method returns a value at a given
1088        /// position in the array.
1089        ///
1090        /// This method is used to operate on a `BigInt64Array` or a `BigUint64Array`.
1091        ///
1092        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/load)
1093        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = load)]
1094        pub fn load_bigint(typed_array: &JsValue, index: i64) -> Result<i64, JsValue>;
1095
1096        /// The static `Atomics.notify()` method notifies up some agents that
1097        /// are sleeping in the wait queue.
1098        /// Note: This operation works with a shared `Int32Array` only.
1099        /// If `count` is not provided, notifies all the agents in the queue.
1100        ///
1101        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/notify)
1102        #[wasm_bindgen(js_namespace = Atomics, catch)]
1103        pub fn notify(typed_array: &Int32Array, index: u32) -> Result<u32, JsValue>;
1104
1105        /// Notifies up to `count` agents in the wait queue.
1106        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = notify)]
1107        pub fn notify_with_count(
1108            typed_array: &Int32Array,
1109            index: u32,
1110            count: u32,
1111        ) -> Result<u32, JsValue>;
1112
1113        /// The static `Atomics.or()` method computes a bitwise OR with a given value
1114        /// at a given position in the array, and returns the old value at that position.
1115        /// This atomic operation guarantees that no other write happens
1116        /// until the modified value is written back.
1117        ///
1118        /// You should use `or_bigint` to operate on a `BigInt64Array` or a `BigUint64Array`.
1119        ///
1120        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/or)
1121        #[wasm_bindgen(js_namespace = Atomics, catch)]
1122        pub fn or(typed_array: &JsValue, index: u32, value: i32) -> Result<i32, JsValue>;
1123
1124        /// The static `Atomics.or()` method computes a bitwise OR with a given value
1125        /// at a given position in the array, and returns the old value at that position.
1126        /// This atomic operation guarantees that no other write happens
1127        /// until the modified value is written back.
1128        ///
1129        /// This method is used to operate on a `BigInt64Array` or a `BigUint64Array`.
1130        ///
1131        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/or)
1132        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = or)]
1133        pub fn or_bigint(typed_array: &JsValue, index: u32, value: i64) -> Result<i64, JsValue>;
1134
1135        /// The static `Atomics.store()` method stores a given value at the given
1136        /// position in the array and returns that value.
1137        ///
1138        /// You should use `store_bigint` to operate on a `BigInt64Array` or a `BigUint64Array`.
1139        ///
1140        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/store)
1141        #[wasm_bindgen(js_namespace = Atomics, catch)]
1142        pub fn store(typed_array: &JsValue, index: u32, value: i32) -> Result<i32, JsValue>;
1143
1144        /// The static `Atomics.store()` method stores a given value at the given
1145        /// position in the array and returns that value.
1146        ///
1147        /// This method is used to operate on a `BigInt64Array` or a `BigUint64Array`.
1148        ///
1149        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/store)
1150        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = store)]
1151        pub fn store_bigint(typed_array: &JsValue, index: u32, value: i64) -> Result<i64, JsValue>;
1152
1153        /// The static `Atomics.sub()` method subtracts a given value at a
1154        /// given position in the array and returns the old value at that position.
1155        /// This atomic operation guarantees that no other write happens
1156        /// until the modified value is written back.
1157        ///
1158        /// You should use `sub_bigint` to operate on a `BigInt64Array` or a `BigUint64Array`.
1159        ///
1160        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/sub)
1161        #[wasm_bindgen(js_namespace = Atomics, catch)]
1162        pub fn sub(typed_array: &JsValue, index: u32, value: i32) -> Result<i32, JsValue>;
1163
1164        /// The static `Atomics.sub()` method subtracts a given value at a
1165        /// given position in the array and returns the old value at that position.
1166        /// This atomic operation guarantees that no other write happens
1167        /// until the modified value is written back.
1168        ///
1169        /// This method is used to operate on a `BigInt64Array` or a `BigUint64Array`.
1170        ///
1171        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/sub)
1172        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = sub)]
1173        pub fn sub_bigint(typed_array: &JsValue, index: u32, value: i64) -> Result<i64, JsValue>;
1174
1175        /// The static `Atomics.wait()` method verifies that a given
1176        /// position in an `Int32Array` still contains a given value
1177        /// and if so sleeps, awaiting a wakeup or a timeout.
1178        /// It returns a string which is either "ok", "not-equal", or "timed-out".
1179        /// Note: This operation only works with a shared `Int32Array`
1180        /// and may not be allowed on the main thread.
1181        ///
1182        /// You should use `wait_bigint` to operate on a `BigInt64Array`.
1183        ///
1184        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/wait)
1185        #[wasm_bindgen(js_namespace = Atomics, catch)]
1186        pub fn wait(typed_array: &Int32Array, index: u32, value: i32) -> Result<JsString, JsValue>;
1187
1188        /// The static `Atomics.wait()` method verifies that a given
1189        /// position in an `BigInt64Array` still contains a given value
1190        /// and if so sleeps, awaiting a wakeup or a timeout.
1191        /// It returns a string which is either "ok", "not-equal", or "timed-out".
1192        /// Note: This operation only works with a shared `BigInt64Array`
1193        /// and may not be allowed on the main thread.
1194        ///
1195        /// You should use `wait` to operate on a `Int32Array`.
1196        ///
1197        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/wait)
1198        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = wait)]
1199        pub fn wait_bigint(
1200            typed_array: &BigInt64Array,
1201            index: u32,
1202            value: i64,
1203        ) -> Result<JsString, JsValue>;
1204
1205        /// Like `wait()`, but with timeout
1206        ///
1207        /// You should use `wait_with_timeout_bigint` to operate on a `BigInt64Array`.
1208        ///
1209        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/wait)
1210        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = wait)]
1211        pub fn wait_with_timeout(
1212            typed_array: &Int32Array,
1213            index: u32,
1214            value: i32,
1215            timeout: f64,
1216        ) -> Result<JsString, JsValue>;
1217
1218        /// Like `wait()`, but with timeout
1219        ///
1220        /// You should use `wait_with_timeout` to operate on a `Int32Array`.
1221        ///
1222        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/wait)
1223        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = wait)]
1224        pub fn wait_with_timeout_bigint(
1225            typed_array: &BigInt64Array,
1226            index: u32,
1227            value: i64,
1228            timeout: f64,
1229        ) -> Result<JsString, JsValue>;
1230
1231        /// The static `Atomics.waitAsync()` method verifies that a given position in an
1232        /// `Int32Array` still contains a given value and if so sleeps, awaiting a
1233        /// wakeup or a timeout. It returns an object with two properties. The first
1234        /// property `async` is a boolean which if true indicates that the second
1235        /// property `value` is a promise. If `async` is false then value is a string
1236        /// whether equal to either "not-equal" or "timed-out".
1237        /// Note: This operation only works with a shared `Int32Array` and may be used
1238        /// on the main thread.
1239        ///
1240        /// You should use `wait_async_bigint` to operate on a `BigInt64Array`.
1241        ///
1242        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/waitAsync)
1243        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = waitAsync)]
1244        pub fn wait_async(
1245            typed_array: &Int32Array,
1246            index: u32,
1247            value: i32,
1248        ) -> Result<Object, JsValue>;
1249
1250        /// The static `Atomics.waitAsync()` method verifies that a given position in an
1251        /// `Int32Array` still contains a given value and if so sleeps, awaiting a
1252        /// wakeup or a timeout. It returns an object with two properties. The first
1253        /// property `async` is a boolean which if true indicates that the second
1254        /// property `value` is a promise. If `async` is false then value is a string
1255        /// whether equal to either "not-equal" or "timed-out".
1256        /// Note: This operation only works with a shared `BigInt64Array` and may be used
1257        /// on the main thread.
1258        ///
1259        /// You should use `wait_async` to operate on a `Int32Array`.
1260        ///
1261        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/waitAsync)
1262        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = waitAsync)]
1263        pub fn wait_async_bigint(
1264            typed_array: &BigInt64Array,
1265            index: u32,
1266            value: i64,
1267        ) -> Result<Object, JsValue>;
1268
1269        /// Like `waitAsync()`, but with timeout
1270        ///
1271        /// You should use `wait_async_with_timeout_bigint` to operate on a `BigInt64Array`.
1272        ///
1273        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/waitAsync)
1274        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = waitAsync)]
1275        pub fn wait_async_with_timeout(
1276            typed_array: &Int32Array,
1277            index: u32,
1278            value: i32,
1279            timeout: f64,
1280        ) -> Result<Object, JsValue>;
1281
1282        /// Like `waitAsync()`, but with timeout
1283        ///
1284        /// You should use `wait_async_with_timeout` to operate on a `Int32Array`.
1285        ///
1286        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/waitAsync)
1287        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = waitAsync)]
1288        pub fn wait_async_with_timeout_bigint(
1289            typed_array: &BigInt64Array,
1290            index: u32,
1291            value: i64,
1292            timeout: f64,
1293        ) -> Result<Object, JsValue>;
1294
1295        /// The static `Atomics.xor()` method computes a bitwise XOR
1296        /// with a given value at a given position in the array,
1297        /// and returns the old value at that position.
1298        /// This atomic operation guarantees that no other write happens
1299        /// until the modified value is written back.
1300        ///
1301        /// You should use `xor_bigint` to operate on a `BigInt64Array` or a `BigUint64Array`.
1302        ///
1303        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/xor)
1304        #[wasm_bindgen(js_namespace = Atomics, catch)]
1305        pub fn xor(typed_array: &JsValue, index: u32, value: i32) -> Result<i32, JsValue>;
1306
1307        /// The static `Atomics.xor()` method computes a bitwise XOR
1308        /// with a given value at a given position in the array,
1309        /// and returns the old value at that position.
1310        /// This atomic operation guarantees that no other write happens
1311        /// until the modified value is written back.
1312        ///
1313        /// This method is used to operate on a `BigInt64Array` or a `BigUint64Array`.
1314        ///
1315        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/xor)
1316        #[wasm_bindgen(js_namespace = Atomics, catch, js_name = xor)]
1317        pub fn xor_bigint(typed_array: &JsValue, index: u32, value: i64) -> Result<i64, JsValue>;
1318    }
1319}
1320
1321// BigInt
1322#[wasm_bindgen]
1323extern "C" {
1324    #[wasm_bindgen(extends = Object, is_type_of = |v| v.is_bigint(), typescript_type = "bigint")]
1325    #[derive(Clone, PartialEq, Eq)]
1326    pub type BigInt;
1327
1328    #[wasm_bindgen(catch, js_name = BigInt)]
1329    fn new_bigint(value: &JsValue) -> Result<BigInt, Error>;
1330
1331    #[wasm_bindgen(js_name = BigInt)]
1332    fn new_bigint_unchecked(value: &JsValue) -> BigInt;
1333
1334    /// Clamps a BigInt value to a signed integer value, and returns that value.
1335    ///
1336    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/asIntN)
1337    #[wasm_bindgen(static_method_of = BigInt, js_name = asIntN)]
1338    pub fn as_int_n(bits: f64, bigint: &BigInt) -> BigInt;
1339
1340    /// Clamps a BigInt value to an unsigned integer value, and returns that value.
1341    ///
1342    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/asUintN)
1343    #[wasm_bindgen(static_method_of = BigInt, js_name = asUintN)]
1344    pub fn as_uint_n(bits: f64, bigint: &BigInt) -> BigInt;
1345
1346    /// 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.
1347    ///
1348    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/toLocaleString)
1349    #[wasm_bindgen(method, js_name = toLocaleString)]
1350    pub fn to_locale_string(this: &BigInt, locales: &JsValue, options: &JsValue) -> JsString;
1351
1352    /// 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.
1353    ///
1354    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/toString)
1355    #[wasm_bindgen(catch, method, js_name = toString)]
1356    pub fn to_string(this: &BigInt, radix: u8) -> Result<JsString, RangeError>;
1357
1358    #[wasm_bindgen(method, js_name = toString)]
1359    fn to_string_unchecked(this: &BigInt, radix: u8) -> String;
1360
1361    /// Returns this BigInt value. Overrides the [`Object.prototype.valueOf()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/valueOf) method.
1362    ///
1363    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/valueOf)
1364    #[wasm_bindgen(method, js_name = valueOf)]
1365    pub fn value_of(this: &BigInt, radix: u8) -> BigInt;
1366}
1367
1368impl BigInt {
1369    /// Creates a new BigInt value.
1370    ///
1371    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/BigInt)
1372    #[inline]
1373    pub fn new(value: &JsValue) -> Result<BigInt, Error> {
1374        new_bigint(value)
1375    }
1376
1377    /// Applies the binary `/` JS operator on two `BigInt`s, catching and returning any `RangeError` thrown.
1378    ///
1379    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Division)
1380    pub fn checked_div(&self, rhs: &Self) -> Result<Self, RangeError> {
1381        let result = JsValue::as_ref(self).checked_div(JsValue::as_ref(rhs));
1382
1383        if result.is_instance_of::<RangeError>() {
1384            Err(result.unchecked_into())
1385        } else {
1386            Ok(result.unchecked_into())
1387        }
1388    }
1389
1390    /// Applies the binary `**` JS operator on the two `BigInt`s.
1391    ///
1392    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Exponentiation)
1393    #[inline]
1394    pub fn pow(&self, rhs: &Self) -> Self {
1395        JsValue::as_ref(self)
1396            .pow(JsValue::as_ref(rhs))
1397            .unchecked_into()
1398    }
1399
1400    /// Returns a tuple of this [`BigInt`]'s absolute value along with a
1401    /// [`bool`] indicating whether the [`BigInt`] was negative.
1402    fn abs(&self) -> (Self, bool) {
1403        if self < &BigInt::from(0) {
1404            (-self, true)
1405        } else {
1406            (self.clone(), false)
1407        }
1408    }
1409}
1410
1411macro_rules! bigint_from {
1412    ($($x:ident)*) => ($(
1413        impl From<$x> for BigInt {
1414            #[inline]
1415            fn from(x: $x) -> BigInt {
1416                new_bigint_unchecked(&JsValue::from(x))
1417            }
1418        }
1419
1420        impl PartialEq<$x> for BigInt {
1421            #[inline]
1422            fn eq(&self, other: &$x) -> bool {
1423                JsValue::from(self) == JsValue::from(BigInt::from(*other))
1424            }
1425        }
1426    )*)
1427}
1428bigint_from!(i8 u8 i16 u16 i32 u32 isize usize);
1429
1430macro_rules! bigint_from_big {
1431    ($($x:ident)*) => ($(
1432        impl From<$x> for BigInt {
1433            #[inline]
1434            fn from(x: $x) -> BigInt {
1435                JsValue::from(x).unchecked_into()
1436            }
1437        }
1438
1439        impl PartialEq<$x> for BigInt {
1440            #[inline]
1441            fn eq(&self, other: &$x) -> bool {
1442                self == &BigInt::from(*other)
1443            }
1444        }
1445
1446        impl TryFrom<BigInt> for $x {
1447            type Error = BigInt;
1448
1449            #[inline]
1450            fn try_from(x: BigInt) -> Result<Self, BigInt> {
1451                Self::try_from(JsValue::from(x)).map_err(JsCast::unchecked_into)
1452            }
1453        }
1454    )*)
1455}
1456bigint_from_big!(i64 u64 i128 u128);
1457
1458impl PartialEq<Number> for BigInt {
1459    #[inline]
1460    fn eq(&self, other: &Number) -> bool {
1461        JsValue::as_ref(self).loose_eq(JsValue::as_ref(other))
1462    }
1463}
1464
1465impl Not for &BigInt {
1466    type Output = BigInt;
1467
1468    #[inline]
1469    fn not(self) -> Self::Output {
1470        JsValue::as_ref(self).bit_not().unchecked_into()
1471    }
1472}
1473
1474forward_deref_unop!(impl Not, not for BigInt);
1475forward_js_unop!(impl Neg, neg for BigInt);
1476forward_js_binop!(impl BitAnd, bitand for BigInt);
1477forward_js_binop!(impl BitOr, bitor for BigInt);
1478forward_js_binop!(impl BitXor, bitxor for BigInt);
1479forward_js_binop!(impl Shl, shl for BigInt);
1480forward_js_binop!(impl Shr, shr for BigInt);
1481forward_js_binop!(impl Add, add for BigInt);
1482forward_js_binop!(impl Sub, sub for BigInt);
1483forward_js_binop!(impl Div, div for BigInt);
1484forward_js_binop!(impl Mul, mul for BigInt);
1485forward_js_binop!(impl Rem, rem for BigInt);
1486sum_product!(BigInt);
1487
1488partialord_ord!(BigInt);
1489
1490impl Default for BigInt {
1491    fn default() -> Self {
1492        BigInt::from(i32::default())
1493    }
1494}
1495
1496impl FromStr for BigInt {
1497    type Err = Error;
1498
1499    #[inline]
1500    fn from_str(s: &str) -> Result<Self, Self::Err> {
1501        BigInt::new(&s.into())
1502    }
1503}
1504
1505impl fmt::Debug for BigInt {
1506    #[inline]
1507    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1508        fmt::Display::fmt(self, f)
1509    }
1510}
1511
1512impl fmt::Display for BigInt {
1513    #[inline]
1514    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1515        let (abs, is_neg) = self.abs();
1516        f.pad_integral(!is_neg, "", &abs.to_string_unchecked(10))
1517    }
1518}
1519
1520impl fmt::Binary for BigInt {
1521    #[inline]
1522    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1523        let (abs, is_neg) = self.abs();
1524        f.pad_integral(!is_neg, "0b", &abs.to_string_unchecked(2))
1525    }
1526}
1527
1528impl fmt::Octal for BigInt {
1529    #[inline]
1530    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1531        let (abs, is_neg) = self.abs();
1532        f.pad_integral(!is_neg, "0o", &abs.to_string_unchecked(8))
1533    }
1534}
1535
1536impl fmt::LowerHex for BigInt {
1537    #[inline]
1538    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1539        let (abs, is_neg) = self.abs();
1540        f.pad_integral(!is_neg, "0x", &abs.to_string_unchecked(16))
1541    }
1542}
1543
1544impl fmt::UpperHex for BigInt {
1545    #[inline]
1546    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1547        let (abs, is_neg) = self.abs();
1548        let mut s: String = abs.to_string_unchecked(16);
1549        s.make_ascii_uppercase();
1550        f.pad_integral(!is_neg, "0x", &s)
1551    }
1552}
1553
1554// Boolean
1555#[wasm_bindgen]
1556extern "C" {
1557    #[wasm_bindgen(extends = Object, is_type_of = |v| v.as_bool().is_some(), typescript_type = "boolean")]
1558    #[derive(Clone, PartialEq, Eq)]
1559    pub type Boolean;
1560
1561    /// The `Boolean()` constructor creates an object wrapper for a boolean value.
1562    ///
1563    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)
1564    #[wasm_bindgen(constructor)]
1565    #[deprecated(note = "recommended to use `Boolean::from` instead")]
1566    #[allow(deprecated)]
1567    pub fn new(value: &JsValue) -> Boolean;
1568
1569    /// The `valueOf()` method returns the primitive value of a `Boolean` object.
1570    ///
1571    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean/valueOf)
1572    #[wasm_bindgen(method, js_name = valueOf)]
1573    pub fn value_of(this: &Boolean) -> bool;
1574}
1575
1576impl From<bool> for Boolean {
1577    #[inline]
1578    fn from(b: bool) -> Boolean {
1579        Boolean::unchecked_from_js(JsValue::from(b))
1580    }
1581}
1582
1583impl From<Boolean> for bool {
1584    #[inline]
1585    fn from(b: Boolean) -> bool {
1586        b.value_of()
1587    }
1588}
1589
1590impl PartialEq<bool> for Boolean {
1591    #[inline]
1592    fn eq(&self, other: &bool) -> bool {
1593        self.value_of() == *other
1594    }
1595}
1596
1597impl fmt::Debug for Boolean {
1598    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1599        fmt::Debug::fmt(&self.value_of(), f)
1600    }
1601}
1602
1603impl fmt::Display for Boolean {
1604    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1605        fmt::Display::fmt(&self.value_of(), f)
1606    }
1607}
1608
1609impl Default for Boolean {
1610    fn default() -> Self {
1611        Self::from(bool::default())
1612    }
1613}
1614
1615impl Not for &Boolean {
1616    type Output = Boolean;
1617
1618    #[inline]
1619    fn not(self) -> Self::Output {
1620        (!JsValue::as_ref(self)).into()
1621    }
1622}
1623
1624forward_deref_unop!(impl Not, not for Boolean);
1625
1626partialord_ord!(Boolean);
1627
1628// DataView
1629#[wasm_bindgen]
1630extern "C" {
1631    #[wasm_bindgen(extends = Object, typescript_type = "DataView")]
1632    #[derive(Clone, Debug, PartialEq, Eq)]
1633    pub type DataView;
1634
1635    /// The `DataView` view provides a low-level interface for reading and
1636    /// writing multiple number types in an `ArrayBuffer` irrespective of the
1637    /// platform's endianness.
1638    ///
1639    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView)
1640    #[wasm_bindgen(constructor)]
1641    pub fn new(buffer: &ArrayBuffer, byteOffset: usize, byteLength: usize) -> DataView;
1642
1643    /// The `DataView` view provides a low-level interface for reading and
1644    /// writing multiple number types in an `ArrayBuffer` irrespective of the
1645    /// platform's endianness.
1646    ///
1647    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView)
1648    #[wasm_bindgen(constructor)]
1649    pub fn new_with_shared_array_buffer(
1650        buffer: &SharedArrayBuffer,
1651        byteOffset: usize,
1652        byteLength: usize,
1653    ) -> DataView;
1654
1655    /// The ArrayBuffer referenced by this view. Fixed at construction time and thus read only.
1656    ///
1657    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/buffer)
1658    #[wasm_bindgen(method, getter, structural)]
1659    pub fn buffer(this: &DataView) -> ArrayBuffer;
1660
1661    /// The length (in bytes) of this view from the start of its ArrayBuffer.
1662    /// Fixed at construction time and thus read only.
1663    ///
1664    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/byteLength)
1665    #[wasm_bindgen(method, getter, structural, js_name = byteLength)]
1666    pub fn byte_length(this: &DataView) -> usize;
1667
1668    /// The offset (in bytes) of this view from the start of its ArrayBuffer.
1669    /// Fixed at construction time and thus read only.
1670    ///
1671    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/byteOffset)
1672    #[wasm_bindgen(method, getter, structural, js_name = byteOffset)]
1673    pub fn byte_offset(this: &DataView) -> usize;
1674
1675    /// The `getInt8()` method gets a signed 8-bit integer (byte) at the
1676    /// specified byte offset from the start of the DataView.
1677    ///
1678    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getInt8)
1679    #[wasm_bindgen(method, js_name = getInt8)]
1680    pub fn get_int8(this: &DataView, byte_offset: usize) -> i8;
1681
1682    /// The `getUint8()` method gets a unsigned 8-bit integer (byte) at the specified
1683    /// byte offset from the start of the DataView.
1684    ///
1685    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getUint8)
1686    #[wasm_bindgen(method, js_name = getUint8)]
1687    pub fn get_uint8(this: &DataView, byte_offset: usize) -> u8;
1688
1689    /// The `getInt16()` method gets a signed 16-bit integer (short) at the specified
1690    /// byte offset from the start of the DataView.
1691    ///
1692    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getInt16)
1693    #[wasm_bindgen(method, js_name = getInt16)]
1694    pub fn get_int16(this: &DataView, byte_offset: usize) -> i16;
1695
1696    /// The `getInt16()` method gets a signed 16-bit integer (short) at the specified
1697    /// byte offset from the start of the DataView.
1698    ///
1699    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getInt16)
1700    #[wasm_bindgen(method, js_name = getInt16)]
1701    pub fn get_int16_endian(this: &DataView, byte_offset: usize, little_endian: bool) -> i16;
1702
1703    /// The `getUint16()` method gets an unsigned 16-bit integer (unsigned short) at the specified
1704    /// byte offset from the start of the view.
1705    ///
1706    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getUint16)
1707    #[wasm_bindgen(method, js_name = getUint16)]
1708    pub fn get_uint16(this: &DataView, byte_offset: usize) -> u16;
1709
1710    /// The `getUint16()` method gets an unsigned 16-bit integer (unsigned short) at the specified
1711    /// byte offset from the start of the view.
1712    ///
1713    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getUint16)
1714    #[wasm_bindgen(method, js_name = getUint16)]
1715    pub fn get_uint16_endian(this: &DataView, byte_offset: usize, little_endian: bool) -> u16;
1716
1717    /// The `getInt32()` method gets a signed 32-bit integer (long) at the specified
1718    /// byte offset from the start of the DataView.
1719    ///
1720    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getInt32)
1721    #[wasm_bindgen(method, js_name = getInt32)]
1722    pub fn get_int32(this: &DataView, byte_offset: usize) -> i32;
1723
1724    /// The `getInt32()` method gets a signed 32-bit integer (long) at the specified
1725    /// byte offset from the start of the DataView.
1726    ///
1727    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getInt32)
1728    #[wasm_bindgen(method, js_name = getInt32)]
1729    pub fn get_int32_endian(this: &DataView, byte_offset: usize, little_endian: bool) -> i32;
1730
1731    /// The `getUint32()` method gets an unsigned 32-bit integer (unsigned long) at the specified
1732    /// byte offset from the start of the view.
1733    ///
1734    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getUint32)
1735    #[wasm_bindgen(method, js_name = getUint32)]
1736    pub fn get_uint32(this: &DataView, byte_offset: usize) -> u32;
1737
1738    /// The `getUint32()` method gets an unsigned 32-bit integer (unsigned long) at the specified
1739    /// byte offset from the start of the view.
1740    ///
1741    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getUint32)
1742    #[wasm_bindgen(method, js_name = getUint32)]
1743    pub fn get_uint32_endian(this: &DataView, byte_offset: usize, little_endian: bool) -> u32;
1744
1745    /// The `getFloat32()` method gets a signed 32-bit float (float) at the specified
1746    /// byte offset from the start of the DataView.
1747    ///
1748    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getFloat32)
1749    #[wasm_bindgen(method, js_name = getFloat32)]
1750    pub fn get_float32(this: &DataView, byte_offset: usize) -> f32;
1751
1752    /// The `getFloat32()` method gets a signed 32-bit float (float) at the specified
1753    /// byte offset from the start of the DataView.
1754    ///
1755    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getFloat32)
1756    #[wasm_bindgen(method, js_name = getFloat32)]
1757    pub fn get_float32_endian(this: &DataView, byte_offset: usize, little_endian: bool) -> f32;
1758
1759    /// The `getFloat64()` method gets a signed 64-bit float (double) at the specified
1760    /// byte offset from the start of the DataView.
1761    ///
1762    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getFloat64)
1763    #[wasm_bindgen(method, js_name = getFloat64)]
1764    pub fn get_float64(this: &DataView, byte_offset: usize) -> f64;
1765
1766    /// The `getFloat64()` method gets a signed 64-bit float (double) at the specified
1767    /// byte offset from the start of the DataView.
1768    ///
1769    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getFloat64)
1770    #[wasm_bindgen(method, js_name = getFloat64)]
1771    pub fn get_float64_endian(this: &DataView, byte_offset: usize, little_endian: bool) -> f64;
1772
1773    /// The `setInt8()` method stores a signed 8-bit integer (byte) value at the
1774    /// specified byte offset from the start of the DataView.
1775    ///
1776    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setInt8)
1777    #[wasm_bindgen(method, js_name = setInt8)]
1778    pub fn set_int8(this: &DataView, byte_offset: usize, value: i8);
1779
1780    /// The `setUint8()` method stores an unsigned 8-bit integer (byte) value at the
1781    /// specified byte offset from the start of the DataView.
1782    ///
1783    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setUint8)
1784    #[wasm_bindgen(method, js_name = setUint8)]
1785    pub fn set_uint8(this: &DataView, byte_offset: usize, value: u8);
1786
1787    /// The `setInt16()` method stores a signed 16-bit integer (short) value at the
1788    /// specified byte offset from the start of the DataView.
1789    ///
1790    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setInt16)
1791    #[wasm_bindgen(method, js_name = setInt16)]
1792    pub fn set_int16(this: &DataView, byte_offset: usize, value: i16);
1793
1794    /// The `setInt16()` method stores a signed 16-bit integer (short) value at the
1795    /// specified byte offset from the start of the DataView.
1796    ///
1797    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setInt16)
1798    #[wasm_bindgen(method, js_name = setInt16)]
1799    pub fn set_int16_endian(this: &DataView, byte_offset: usize, value: i16, little_endian: bool);
1800
1801    /// The `setUint16()` method stores an unsigned 16-bit integer (unsigned short) value at the
1802    /// specified byte offset from the start of the DataView.
1803    ///
1804    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setUint16)
1805    #[wasm_bindgen(method, js_name = setUint16)]
1806    pub fn set_uint16(this: &DataView, byte_offset: usize, value: u16);
1807
1808    /// The `setUint16()` method stores an unsigned 16-bit integer (unsigned short) value at the
1809    /// specified byte offset from the start of the DataView.
1810    ///
1811    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setUint16)
1812    #[wasm_bindgen(method, js_name = setUint16)]
1813    pub fn set_uint16_endian(this: &DataView, byte_offset: usize, value: u16, little_endian: bool);
1814
1815    /// The `setInt32()` method stores a signed 32-bit integer (long) value at the
1816    /// specified byte offset from the start of the DataView.
1817    ///
1818    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setInt32)
1819    #[wasm_bindgen(method, js_name = setInt32)]
1820    pub fn set_int32(this: &DataView, byte_offset: usize, value: i32);
1821
1822    /// The `setInt32()` method stores a signed 32-bit integer (long) value at the
1823    /// specified byte offset from the start of the DataView.
1824    ///
1825    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setInt32)
1826    #[wasm_bindgen(method, js_name = setInt32)]
1827    pub fn set_int32_endian(this: &DataView, byte_offset: usize, value: i32, little_endian: bool);
1828
1829    /// The `setUint32()` method stores an unsigned 32-bit integer (unsigned long) value at the
1830    /// specified byte offset from the start of the DataView.
1831    ///
1832    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setUint32)
1833    #[wasm_bindgen(method, js_name = setUint32)]
1834    pub fn set_uint32(this: &DataView, byte_offset: usize, value: u32);
1835
1836    /// The `setUint32()` method stores an unsigned 32-bit integer (unsigned long) value at the
1837    /// specified byte offset from the start of the DataView.
1838    ///
1839    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setUint32)
1840    #[wasm_bindgen(method, js_name = setUint32)]
1841    pub fn set_uint32_endian(this: &DataView, byte_offset: usize, value: u32, little_endian: bool);
1842
1843    /// The `setFloat32()` method stores a signed 32-bit float (float) value at the
1844    /// specified byte offset from the start of the DataView.
1845    ///
1846    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setFloat32)
1847    #[wasm_bindgen(method, js_name = setFloat32)]
1848    pub fn set_float32(this: &DataView, byte_offset: usize, value: f32);
1849
1850    /// The `setFloat32()` method stores a signed 32-bit float (float) value at the
1851    /// specified byte offset from the start of the DataView.
1852    ///
1853    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setFloat32)
1854    #[wasm_bindgen(method, js_name = setFloat32)]
1855    pub fn set_float32_endian(this: &DataView, byte_offset: usize, value: f32, little_endian: bool);
1856
1857    /// The `setFloat64()` method stores a signed 64-bit float (double) value at the
1858    /// specified byte offset from the start of the DataView.
1859    ///
1860    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setFloat64)
1861    #[wasm_bindgen(method, js_name = setFloat64)]
1862    pub fn set_float64(this: &DataView, byte_offset: usize, value: f64);
1863
1864    /// The `setFloat64()` method stores a signed 64-bit float (double) value at the
1865    /// specified byte offset from the start of the DataView.
1866    ///
1867    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setFloat64)
1868    #[wasm_bindgen(method, js_name = setFloat64)]
1869    pub fn set_float64_endian(this: &DataView, byte_offset: usize, value: f64, little_endian: bool);
1870}
1871
1872// Error
1873#[wasm_bindgen]
1874extern "C" {
1875    #[wasm_bindgen(extends = Object, typescript_type = "Error")]
1876    #[derive(Clone, Debug, PartialEq, Eq)]
1877    pub type Error;
1878
1879    /// The Error constructor creates an error object.
1880    /// Instances of Error objects are thrown when runtime errors occur.
1881    /// The Error object can also be used as a base object for user-defined exceptions.
1882    /// See below for standard built-in error types.
1883    ///
1884    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error)
1885    #[wasm_bindgen(constructor)]
1886    pub fn new(message: &str) -> Error;
1887    #[wasm_bindgen(constructor)]
1888    pub fn new_with_options(message: &str, options: &Object) -> Error;
1889
1890    /// The cause property is the underlying cause of the error.
1891    /// Usually this is used to add context to re-thrown errors.
1892    ///
1893    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error#differentiate_between_similar_errors)
1894    #[wasm_bindgen(method, getter, structural)]
1895    pub fn cause(this: &Error) -> JsValue;
1896    #[wasm_bindgen(method, setter, structural)]
1897    pub fn set_cause(this: &Error, cause: &JsValue);
1898
1899    /// The message property is a human-readable description of the error.
1900    ///
1901    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/message)
1902    #[wasm_bindgen(method, getter, structural)]
1903    pub fn message(this: &Error) -> JsString;
1904    #[wasm_bindgen(method, setter, structural)]
1905    pub fn set_message(this: &Error, message: &str);
1906
1907    /// The name property represents a name for the type of error. The initial value is "Error".
1908    ///
1909    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/name)
1910    #[wasm_bindgen(method, getter, structural)]
1911    pub fn name(this: &Error) -> JsString;
1912    #[wasm_bindgen(method, setter, structural)]
1913    pub fn set_name(this: &Error, name: &str);
1914
1915    /// The `toString()` method returns a string representing the specified Error object
1916    ///
1917    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/toString)
1918    #[wasm_bindgen(method, js_name = toString)]
1919    pub fn to_string(this: &Error) -> JsString;
1920}
1921
1922partialord_ord!(JsString);
1923
1924// EvalError
1925#[wasm_bindgen]
1926extern "C" {
1927    #[wasm_bindgen(extends = Object, extends = Error, typescript_type = "EvalError")]
1928    #[derive(Clone, Debug, PartialEq, Eq)]
1929    pub type EvalError;
1930
1931    /// The EvalError object indicates an error regarding the global eval() function. This
1932    /// exception is not thrown by JavaScript anymore, however the EvalError object remains for
1933    /// compatibility.
1934    ///
1935    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError)
1936    #[wasm_bindgen(constructor)]
1937    pub fn new(message: &str) -> EvalError;
1938}
1939
1940// Function
1941#[wasm_bindgen]
1942extern "C" {
1943    #[wasm_bindgen(extends = Object, is_type_of = JsValue::is_function, typescript_type = "Function")]
1944    #[derive(Clone, Debug, PartialEq, Eq)]
1945    pub type Function;
1946
1947    /// The `Function` constructor creates a new `Function` object. Calling the
1948    /// constructor directly can create functions dynamically, but suffers from
1949    /// security and similar (but far less significant) performance issues
1950    /// similar to `eval`. However, unlike `eval`, the `Function` constructor
1951    /// allows executing code in the global scope, prompting better programming
1952    /// habits and allowing for more efficient code minification.
1953    ///
1954    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function)
1955    #[wasm_bindgen(constructor)]
1956    pub fn new_with_args(args: &str, body: &str) -> Function;
1957
1958    /// The `Function` constructor creates a new `Function` object. Calling the
1959    /// constructor directly can create functions dynamically, but suffers from
1960    /// security and similar (but far less significant) performance issues
1961    /// similar to `eval`. However, unlike `eval`, the `Function` constructor
1962    /// allows executing code in the global scope, prompting better programming
1963    /// habits and allowing for more efficient code minification.
1964    ///
1965    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function)
1966    #[wasm_bindgen(constructor)]
1967    pub fn new_no_args(body: &str) -> Function;
1968
1969    /// The `apply()` method calls a function with a given this value, and arguments provided as an array
1970    /// (or an array-like object).
1971    ///
1972    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/apply)
1973    #[wasm_bindgen(method, catch)]
1974    pub fn apply(this: &Function, context: &JsValue, args: &Array) -> Result<JsValue, JsValue>;
1975
1976    /// The `call()` method calls a function with a given this value and
1977    /// arguments provided individually.
1978    ///
1979    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
1980    #[wasm_bindgen(method, catch, js_name = call)]
1981    pub fn call0(this: &Function, context: &JsValue) -> Result<JsValue, JsValue>;
1982
1983    /// The `call()` method calls a function with a given this value and
1984    /// arguments provided individually.
1985    ///
1986    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
1987    #[wasm_bindgen(method, catch, js_name = call)]
1988    pub fn call1(this: &Function, context: &JsValue, arg1: &JsValue) -> Result<JsValue, JsValue>;
1989
1990    /// The `call()` method calls a function with a given this value and
1991    /// arguments provided individually.
1992    ///
1993    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
1994    #[wasm_bindgen(method, catch, js_name = call)]
1995    pub fn call2(
1996        this: &Function,
1997        context: &JsValue,
1998        arg1: &JsValue,
1999        arg2: &JsValue,
2000    ) -> Result<JsValue, JsValue>;
2001
2002    /// The `call()` method calls a function with a given this value and
2003    /// arguments provided individually.
2004    ///
2005    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
2006    #[wasm_bindgen(method, catch, js_name = call)]
2007    pub fn call3(
2008        this: &Function,
2009        context: &JsValue,
2010        arg1: &JsValue,
2011        arg2: &JsValue,
2012        arg3: &JsValue,
2013    ) -> Result<JsValue, JsValue>;
2014
2015    /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
2016    /// with a given sequence of arguments preceding any provided when the new function is called.
2017    ///
2018    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
2019    #[wasm_bindgen(method, js_name = bind)]
2020    pub fn bind(this: &Function, context: &JsValue) -> Function;
2021
2022    /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
2023    /// with a given sequence of arguments preceding any provided when the new function is called.
2024    ///
2025    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
2026    #[wasm_bindgen(method, js_name = bind)]
2027    pub fn bind0(this: &Function, context: &JsValue) -> Function;
2028
2029    /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
2030    /// with a given sequence of arguments preceding any provided when the new function is called.
2031    ///
2032    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
2033    #[wasm_bindgen(method, js_name = bind)]
2034    pub fn bind1(this: &Function, context: &JsValue, arg1: &JsValue) -> Function;
2035
2036    /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
2037    /// with a given sequence of arguments preceding any provided when the new function is called.
2038    ///
2039    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
2040    #[wasm_bindgen(method, js_name = bind)]
2041    pub fn bind2(this: &Function, context: &JsValue, arg1: &JsValue, arg2: &JsValue) -> Function;
2042
2043    /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
2044    /// with a given sequence of arguments preceding any provided when the new function is called.
2045    ///
2046    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
2047    #[wasm_bindgen(method, js_name = bind)]
2048    pub fn bind3(
2049        this: &Function,
2050        context: &JsValue,
2051        arg1: &JsValue,
2052        arg2: &JsValue,
2053        arg3: &JsValue,
2054    ) -> Function;
2055
2056    /// The length property indicates the number of arguments expected by the function.
2057    ///
2058    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/length)
2059    #[wasm_bindgen(method, getter, structural)]
2060    pub fn length(this: &Function) -> u32;
2061
2062    /// A Function object's read-only name property indicates the function's
2063    /// name as specified when it was created or "anonymous" for functions
2064    /// created anonymously.
2065    ///
2066    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name)
2067    #[wasm_bindgen(method, getter, structural)]
2068    pub fn name(this: &Function) -> JsString;
2069
2070    /// The `toString()` method returns a string representing the source code of the function.
2071    ///
2072    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/toString)
2073    #[wasm_bindgen(method, js_name = toString)]
2074    pub fn to_string(this: &Function) -> JsString;
2075}
2076
2077impl Function {
2078    /// Returns the `Function` value of this JS value if it's an instance of a
2079    /// function.
2080    ///
2081    /// If this JS value is not an instance of a function then this returns
2082    /// `None`.
2083    #[deprecated(note = "recommended to use dyn_ref instead which is now equivalent")]
2084    pub fn try_from(val: &JsValue) -> Option<&Function> {
2085        val.dyn_ref()
2086    }
2087}
2088
2089impl Default for Function {
2090    fn default() -> Self {
2091        Self::new_no_args("")
2092    }
2093}
2094
2095// Generator
2096#[wasm_bindgen]
2097extern "C" {
2098    #[wasm_bindgen(extends = Object, typescript_type = "Generator<any, any, any>")]
2099    #[derive(Clone, Debug, PartialEq, Eq)]
2100    pub type Generator;
2101
2102    /// The `next()` method returns an object with two properties done and value.
2103    /// You can also provide a parameter to the next method to send a value to the generator.
2104    ///
2105    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/next)
2106    #[wasm_bindgen(method, structural, catch)]
2107    pub fn next(this: &Generator, value: &JsValue) -> Result<JsValue, JsValue>;
2108
2109    /// The `return()` method returns the given value and finishes the generator.
2110    ///
2111    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/return)
2112    #[wasm_bindgen(method, structural, js_name = return)]
2113    pub fn return_(this: &Generator, value: &JsValue) -> JsValue;
2114
2115    /// The `throw()` method resumes the execution of a generator by throwing an error into it
2116    /// and returns an object with two properties done and value.
2117    ///
2118    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/throw)
2119    #[wasm_bindgen(method, structural, catch)]
2120    pub fn throw(this: &Generator, error: &Error) -> Result<JsValue, JsValue>;
2121}
2122
2123// Map
2124#[wasm_bindgen]
2125extern "C" {
2126    #[wasm_bindgen(extends = Object, typescript_type = "Map<any, any>")]
2127    #[derive(Clone, Debug, PartialEq, Eq)]
2128    pub type Map;
2129
2130    /// The `clear()` method removes all elements from a Map object.
2131    ///
2132    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/clear)
2133    #[wasm_bindgen(method)]
2134    pub fn clear(this: &Map);
2135
2136    /// The `delete()` method removes the specified element from a Map object.
2137    ///
2138    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/delete)
2139    #[wasm_bindgen(method)]
2140    pub fn delete(this: &Map, key: &JsValue) -> bool;
2141
2142    /// The `forEach()` method executes a provided function once per each
2143    /// key/value pair in the Map object, in insertion order.
2144    /// Note that in Javascript land the `Key` and `Value` are reversed compared to normal expectations:
2145    /// # Examples
2146    /// ```
2147    /// let js_map = Map::new();
2148    /// js_map.for_each(&mut |value, key| {
2149    ///     // Do something here...
2150    /// })
2151    /// ```
2152    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/forEach)
2153    #[wasm_bindgen(method, js_name = forEach)]
2154    pub fn for_each(this: &Map, callback: &mut dyn FnMut(JsValue, JsValue));
2155
2156    /// The `get()` method returns a specified element from a Map object.
2157    ///
2158    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/get)
2159    #[wasm_bindgen(method)]
2160    pub fn get(this: &Map, key: &JsValue) -> JsValue;
2161
2162    /// The `has()` method returns a boolean indicating whether an element with
2163    /// the specified key exists or not.
2164    ///
2165    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/has)
2166    #[wasm_bindgen(method)]
2167    pub fn has(this: &Map, key: &JsValue) -> bool;
2168
2169    /// The Map object holds key-value pairs. Any value (both objects and
2170    /// primitive values) maybe used as either a key or a value.
2171    ///
2172    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map)
2173    #[wasm_bindgen(constructor)]
2174    pub fn new() -> Map;
2175
2176    /// The `set()` method adds or updates an element with a specified key
2177    /// and value to a Map object.
2178    ///
2179    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/set)
2180    #[wasm_bindgen(method)]
2181    pub fn set(this: &Map, key: &JsValue, value: &JsValue) -> Map;
2182
2183    /// The value of size is an integer representing how many entries
2184    /// the Map object has. A set accessor function for size is undefined;
2185    /// you can not change this property.
2186    ///
2187    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/size)
2188    #[wasm_bindgen(method, getter, structural)]
2189    pub fn size(this: &Map) -> u32;
2190}
2191
2192impl Default for Map {
2193    fn default() -> Self {
2194        Self::new()
2195    }
2196}
2197
2198// Map Iterator
2199#[wasm_bindgen]
2200extern "C" {
2201    /// The `entries()` method returns a new Iterator object that contains
2202    /// the [key, value] pairs for each element in the Map object in
2203    /// insertion order.
2204    ///
2205    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/entries)
2206    #[wasm_bindgen(method)]
2207    pub fn entries(this: &Map) -> Iterator;
2208
2209    /// The `keys()` method returns a new Iterator object that contains the
2210    /// keys for each element in the Map object in insertion order.
2211    ///
2212    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/keys)
2213    #[wasm_bindgen(method)]
2214    pub fn keys(this: &Map) -> Iterator;
2215
2216    /// The `values()` method returns a new Iterator object that contains the
2217    /// values for each element in the Map object in insertion order.
2218    ///
2219    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/values)
2220    #[wasm_bindgen(method)]
2221    pub fn values(this: &Map) -> Iterator;
2222}
2223
2224// Iterator
2225#[wasm_bindgen]
2226extern "C" {
2227    /// Any object that conforms to the JS iterator protocol. For example,
2228    /// something returned by `myArray[Symbol.iterator]()`.
2229    ///
2230    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols)
2231    #[derive(Clone, Debug)]
2232    #[wasm_bindgen(is_type_of = Iterator::looks_like_iterator, typescript_type = "Iterator<any>")]
2233    pub type Iterator;
2234
2235    /// The `next()` method always has to return an object with appropriate
2236    /// properties including done and value. If a non-object value gets returned
2237    /// (such as false or undefined), a TypeError ("iterator.next() returned a
2238    /// non-object value") will be thrown.
2239    #[wasm_bindgen(catch, method, structural)]
2240    pub fn next(this: &Iterator) -> Result<IteratorNext, JsValue>;
2241}
2242
2243impl Iterator {
2244    fn looks_like_iterator(it: &JsValue) -> bool {
2245        #[wasm_bindgen]
2246        extern "C" {
2247            type MaybeIterator;
2248
2249            #[wasm_bindgen(method, getter)]
2250            fn next(this: &MaybeIterator) -> JsValue;
2251        }
2252
2253        if !it.is_object() {
2254            return false;
2255        }
2256
2257        let it = it.unchecked_ref::<MaybeIterator>();
2258
2259        it.next().is_function()
2260    }
2261}
2262
2263// Async Iterator
2264#[wasm_bindgen]
2265extern "C" {
2266    /// Any object that conforms to the JS async iterator protocol. For example,
2267    /// something returned by `myObject[Symbol.asyncIterator]()`.
2268    ///
2269    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of)
2270    #[derive(Clone, Debug)]
2271    #[wasm_bindgen(is_type_of = Iterator::looks_like_iterator, typescript_type = "AsyncIterator<any>")]
2272    pub type AsyncIterator;
2273
2274    /// The `next()` method always has to return a Promise which resolves to an object
2275    /// with appropriate properties including done and value. If a non-object value
2276    /// gets returned (such as false or undefined), a TypeError ("iterator.next()
2277    /// returned a non-object value") will be thrown.
2278    #[wasm_bindgen(catch, method, structural)]
2279    pub fn next(this: &AsyncIterator) -> Result<Promise, JsValue>;
2280}
2281
2282/// An iterator over the JS `Symbol.iterator` iteration protocol.
2283///
2284/// Use the `IntoIterator for &js_sys::Iterator` implementation to create this.
2285pub struct Iter<'a> {
2286    js: &'a Iterator,
2287    state: IterState,
2288}
2289
2290/// An iterator over the JS `Symbol.iterator` iteration protocol.
2291///
2292/// Use the `IntoIterator for js_sys::Iterator` implementation to create this.
2293pub struct IntoIter {
2294    js: Iterator,
2295    state: IterState,
2296}
2297
2298struct IterState {
2299    done: bool,
2300}
2301
2302impl<'a> IntoIterator for &'a Iterator {
2303    type Item = Result<JsValue, JsValue>;
2304    type IntoIter = Iter<'a>;
2305
2306    fn into_iter(self) -> Iter<'a> {
2307        Iter {
2308            js: self,
2309            state: IterState::new(),
2310        }
2311    }
2312}
2313
2314impl core::iter::Iterator for Iter<'_> {
2315    type Item = Result<JsValue, JsValue>;
2316
2317    fn next(&mut self) -> Option<Self::Item> {
2318        self.state.next(self.js)
2319    }
2320}
2321
2322impl IntoIterator for Iterator {
2323    type Item = Result<JsValue, JsValue>;
2324    type IntoIter = IntoIter;
2325
2326    fn into_iter(self) -> IntoIter {
2327        IntoIter {
2328            js: self,
2329            state: IterState::new(),
2330        }
2331    }
2332}
2333
2334impl core::iter::Iterator for IntoIter {
2335    type Item = Result<JsValue, JsValue>;
2336
2337    fn next(&mut self) -> Option<Self::Item> {
2338        self.state.next(&self.js)
2339    }
2340}
2341
2342impl IterState {
2343    fn new() -> IterState {
2344        IterState { done: false }
2345    }
2346
2347    fn next(&mut self, js: &Iterator) -> Option<Result<JsValue, JsValue>> {
2348        if self.done {
2349            return None;
2350        }
2351        let next = match js.next() {
2352            Ok(val) => val,
2353            Err(e) => {
2354                self.done = true;
2355                return Some(Err(e));
2356            }
2357        };
2358        if next.done() {
2359            self.done = true;
2360            None
2361        } else {
2362            Some(Ok(next.value()))
2363        }
2364    }
2365}
2366
2367/// Create an iterator over `val` using the JS iteration protocol and
2368/// `Symbol.iterator`.
2369pub fn try_iter(val: &JsValue) -> Result<Option<IntoIter>, JsValue> {
2370    let iter_sym = Symbol::iterator();
2371    let iter_fn = Reflect::get(val, iter_sym.as_ref())?;
2372
2373    let iter_fn: Function = match iter_fn.dyn_into() {
2374        Ok(iter_fn) => iter_fn,
2375        Err(_) => return Ok(None),
2376    };
2377
2378    let it: Iterator = match iter_fn.call0(val)?.dyn_into() {
2379        Ok(it) => it,
2380        Err(_) => return Ok(None),
2381    };
2382
2383    Ok(Some(it.into_iter()))
2384}
2385
2386// IteratorNext
2387#[wasm_bindgen]
2388extern "C" {
2389    /// The result of calling `next()` on a JS iterator.
2390    ///
2391    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols)
2392    #[wasm_bindgen(extends = Object, typescript_type = "IteratorResult<any>")]
2393    #[derive(Clone, Debug, PartialEq, Eq)]
2394    pub type IteratorNext;
2395
2396    /// Has the value `true` if the iterator is past the end of the iterated
2397    /// sequence. In this case value optionally specifies the return value of
2398    /// the iterator.
2399    ///
2400    /// Has the value `false` if the iterator was able to produce the next value
2401    /// in the sequence. This is equivalent of not specifying the done property
2402    /// altogether.
2403    #[wasm_bindgen(method, getter, structural)]
2404    pub fn done(this: &IteratorNext) -> bool;
2405
2406    /// Any JavaScript value returned by the iterator. Can be omitted when done
2407    /// is true.
2408    #[wasm_bindgen(method, getter, structural)]
2409    pub fn value(this: &IteratorNext) -> JsValue;
2410}
2411
2412#[allow(non_snake_case)]
2413pub mod Math {
2414    use super::*;
2415
2416    // Math
2417    #[wasm_bindgen]
2418    extern "C" {
2419        /// The `Math.abs()` function returns the absolute value of a number, that is
2420        /// Math.abs(x) = |x|
2421        ///
2422        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/abs)
2423        #[wasm_bindgen(js_namespace = Math)]
2424        pub fn abs(x: f64) -> f64;
2425
2426        /// The `Math.acos()` function returns the arccosine (in radians) of a
2427        /// number, that is ∀x∊[-1;1]
2428        /// Math.acos(x) = arccos(x) = the unique y∊[0;π] such that cos(y)=x
2429        ///
2430        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/acos)
2431        #[wasm_bindgen(js_namespace = Math)]
2432        pub fn acos(x: f64) -> f64;
2433
2434        /// The `Math.acosh()` function returns the hyperbolic arc-cosine of a
2435        /// number, that is ∀x ≥ 1
2436        /// Math.acosh(x) = arcosh(x) = the unique y ≥ 0 such that cosh(y) = x
2437        ///
2438        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/acosh)
2439        #[wasm_bindgen(js_namespace = Math)]
2440        pub fn acosh(x: f64) -> f64;
2441
2442        /// The `Math.asin()` function returns the arcsine (in radians) of a
2443        /// number, that is ∀x ∊ [-1;1]
2444        /// Math.asin(x) = arcsin(x) = the unique y∊[-π2;π2] such that sin(y) = x
2445        ///
2446        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/asin)
2447        #[wasm_bindgen(js_namespace = Math)]
2448        pub fn asin(x: f64) -> f64;
2449
2450        /// The `Math.asinh()` function returns the hyperbolic arcsine of a
2451        /// number, that is Math.asinh(x) = arsinh(x) = the unique y such that sinh(y) = x
2452        ///
2453        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/asinh)
2454        #[wasm_bindgen(js_namespace = Math)]
2455        pub fn asinh(x: f64) -> f64;
2456
2457        /// The `Math.atan()` function returns the arctangent (in radians) of a
2458        /// number, that is Math.atan(x) = arctan(x) = the unique y ∊ [-π2;π2]such that
2459        /// tan(y) = x
2460        #[wasm_bindgen(js_namespace = Math)]
2461        pub fn atan(x: f64) -> f64;
2462
2463        /// The `Math.atan2()` function returns the arctangent of the quotient of
2464        /// its arguments.
2465        ///
2466        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atan2)
2467        #[wasm_bindgen(js_namespace = Math)]
2468        pub fn atan2(y: f64, x: f64) -> f64;
2469
2470        /// The `Math.atanh()` function returns the hyperbolic arctangent of a number,
2471        /// that is ∀x ∊ (-1,1), Math.atanh(x) = arctanh(x) = the unique y such that
2472        /// tanh(y) = x
2473        ///
2474        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atanh)
2475        #[wasm_bindgen(js_namespace = Math)]
2476        pub fn atanh(x: f64) -> f64;
2477
2478        /// The `Math.cbrt() `function returns the cube root of a number, that is
2479        /// Math.cbrt(x) = ∛x = the unique y such that y^3 = x
2480        ///
2481        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cbrt)
2482        #[wasm_bindgen(js_namespace = Math)]
2483        pub fn cbrt(x: f64) -> f64;
2484
2485        /// The `Math.ceil()` function returns the smallest integer greater than
2486        /// or equal to a given number.
2487        ///
2488        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/ceil)
2489        #[wasm_bindgen(js_namespace = Math)]
2490        pub fn ceil(x: f64) -> f64;
2491
2492        /// The `Math.clz32()` function returns the number of leading zero bits in
2493        /// the 32-bit binary representation of a number.
2494        ///
2495        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/clz32)
2496        #[wasm_bindgen(js_namespace = Math)]
2497        pub fn clz32(x: i32) -> u32;
2498
2499        /// The `Math.cos()` static function returns the cosine of the specified angle,
2500        /// which must be specified in radians. This value is length(adjacent)/length(hypotenuse).
2501        ///
2502        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cos)
2503        #[wasm_bindgen(js_namespace = Math)]
2504        pub fn cos(x: f64) -> f64;
2505
2506        /// The `Math.cosh()` function returns the hyperbolic cosine of a number,
2507        /// that can be expressed using the constant e.
2508        ///
2509        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cosh)
2510        #[wasm_bindgen(js_namespace = Math)]
2511        pub fn cosh(x: f64) -> f64;
2512
2513        /// The `Math.exp()` function returns e^x, where x is the argument, and e is Euler's number
2514        /// (also known as Napier's constant), the base of the natural logarithms.
2515        ///
2516        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/exp)
2517        #[wasm_bindgen(js_namespace = Math)]
2518        pub fn exp(x: f64) -> f64;
2519
2520        /// The `Math.expm1()` function returns e^x - 1, where x is the argument, and e the base of the
2521        /// natural logarithms.
2522        ///
2523        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/expm1)
2524        #[wasm_bindgen(js_namespace = Math)]
2525        pub fn expm1(x: f64) -> f64;
2526
2527        /// The `Math.floor()` function returns the largest integer less than or
2528        /// equal to a given number.
2529        ///
2530        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/floor)
2531        #[wasm_bindgen(js_namespace = Math)]
2532        pub fn floor(x: f64) -> f64;
2533
2534        /// The `Math.fround()` function returns the nearest 32-bit single precision float representation
2535        /// of a Number.
2536        ///
2537        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/fround)
2538        #[wasm_bindgen(js_namespace = Math)]
2539        pub fn fround(x: f64) -> f32;
2540
2541        /// The `Math.hypot()` function returns the square root of the sum of squares of its arguments.
2542        ///
2543        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/hypot)
2544        #[wasm_bindgen(js_namespace = Math)]
2545        pub fn hypot(x: f64, y: f64) -> f64;
2546
2547        /// The `Math.imul()` function returns the result of the C-like 32-bit multiplication of the
2548        /// two parameters.
2549        ///
2550        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul)
2551        #[wasm_bindgen(js_namespace = Math)]
2552        pub fn imul(x: i32, y: i32) -> i32;
2553
2554        /// The `Math.log()` function returns the natural logarithm (base e) of a number.
2555        /// The JavaScript `Math.log()` function is equivalent to ln(x) in mathematics.
2556        ///
2557        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log)
2558        #[wasm_bindgen(js_namespace = Math)]
2559        pub fn log(x: f64) -> f64;
2560
2561        /// The `Math.log10()` function returns the base 10 logarithm of a number.
2562        ///
2563        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log10)
2564        #[wasm_bindgen(js_namespace = Math)]
2565        pub fn log10(x: f64) -> f64;
2566
2567        /// The `Math.log1p()` function returns the natural logarithm (base e) of 1 + a number.
2568        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log1p)
2569        #[wasm_bindgen(js_namespace = Math)]
2570        pub fn log1p(x: f64) -> f64;
2571
2572        /// The `Math.log2()` function returns the base 2 logarithm of a number.
2573        ///
2574        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log2)
2575        #[wasm_bindgen(js_namespace = Math)]
2576        pub fn log2(x: f64) -> f64;
2577
2578        /// The `Math.max()` function returns the largest of two numbers.
2579        ///
2580        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/max)
2581        #[wasm_bindgen(js_namespace = Math)]
2582        pub fn max(x: f64, y: f64) -> f64;
2583
2584        /// The static function `Math.min()` returns the lowest-valued number passed into it.
2585        ///
2586        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/min)
2587        #[wasm_bindgen(js_namespace = Math)]
2588        pub fn min(x: f64, y: f64) -> f64;
2589
2590        /// The `Math.pow()` function returns the base to the exponent power, that is, base^exponent.
2591        ///
2592        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/pow)
2593        #[wasm_bindgen(js_namespace = Math)]
2594        pub fn pow(base: f64, exponent: f64) -> f64;
2595
2596        /// The `Math.random()` function returns a floating-point, pseudo-random number
2597        /// in the range 0–1 (inclusive of 0, but not 1) with approximately uniform distribution
2598        /// over that range — which you can then scale to your desired range.
2599        /// The implementation selects the initial seed to the random number generation algorithm;
2600        /// it cannot be chosen or reset by the user.
2601        ///
2602        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random)
2603        #[wasm_bindgen(js_namespace = Math)]
2604        pub fn random() -> f64;
2605
2606        /// The `Math.round()` function returns the value of a number rounded to the nearest integer.
2607        ///
2608        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/round)
2609        #[wasm_bindgen(js_namespace = Math)]
2610        pub fn round(x: f64) -> f64;
2611
2612        /// The `Math.sign()` function returns the sign of a number, indicating whether the number is
2613        /// positive, negative or zero.
2614        ///
2615        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sign)
2616        #[wasm_bindgen(js_namespace = Math)]
2617        pub fn sign(x: f64) -> f64;
2618
2619        /// The `Math.sin()` function returns the sine of a number.
2620        ///
2621        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sin)
2622        #[wasm_bindgen(js_namespace = Math)]
2623        pub fn sin(x: f64) -> f64;
2624
2625        /// The `Math.sinh()` function returns the hyperbolic sine of a number, that can be expressed
2626        /// using the constant e: Math.sinh(x) = (e^x - e^-x)/2
2627        ///
2628        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sinh)
2629        #[wasm_bindgen(js_namespace = Math)]
2630        pub fn sinh(x: f64) -> f64;
2631
2632        /// The `Math.sqrt()` function returns the square root of a number, that is
2633        /// ∀x ≥ 0, Math.sqrt(x) = √x = the unique y ≥ 0 such that y^2 = x
2634        ///
2635        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sqrt)
2636        #[wasm_bindgen(js_namespace = Math)]
2637        pub fn sqrt(x: f64) -> f64;
2638
2639        /// The `Math.tan()` function returns the tangent of a number.
2640        ///
2641        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/tan)
2642        #[wasm_bindgen(js_namespace = Math)]
2643        pub fn tan(x: f64) -> f64;
2644
2645        /// The `Math.tanh()` function returns the hyperbolic tangent of a number, that is
2646        /// tanh x = sinh x / cosh x = (e^x - e^-x)/(e^x + e^-x) = (e^2x - 1)/(e^2x + 1)
2647        ///
2648        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/tanh)
2649        #[wasm_bindgen(js_namespace = Math)]
2650        pub fn tanh(x: f64) -> f64;
2651
2652        /// The `Math.trunc()` function returns the integer part of a number by removing any fractional
2653        /// digits.
2654        ///
2655        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/trunc)
2656        #[wasm_bindgen(js_namespace = Math)]
2657        pub fn trunc(x: f64) -> f64;
2658    }
2659}
2660
2661// Number.
2662#[wasm_bindgen]
2663extern "C" {
2664    #[wasm_bindgen(extends = Object, is_type_of = |v| v.as_f64().is_some(), typescript_type = "number")]
2665    #[derive(Clone, PartialEq)]
2666    pub type Number;
2667
2668    /// The `Number.isFinite()` method determines whether the passed value is a finite number.
2669    ///
2670    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isFinite)
2671    #[wasm_bindgen(static_method_of = Number, js_name = isFinite)]
2672    pub fn is_finite(value: &JsValue) -> bool;
2673
2674    /// The `Number.isInteger()` method determines whether the passed value is an integer.
2675    ///
2676    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger)
2677    #[wasm_bindgen(static_method_of = Number, js_name = isInteger)]
2678    pub fn is_integer(value: &JsValue) -> bool;
2679
2680    /// The `Number.isNaN()` method determines whether the passed value is `NaN` and its type is Number.
2681    /// It is a more robust version of the original, global isNaN().
2682    ///
2683    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isNaN)
2684    #[wasm_bindgen(static_method_of = Number, js_name = isNaN)]
2685    pub fn is_nan(value: &JsValue) -> bool;
2686
2687    /// The `Number.isSafeInteger()` method determines whether the provided value is a number
2688    /// that is a safe integer.
2689    ///
2690    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger)
2691    #[wasm_bindgen(static_method_of = Number, js_name = isSafeInteger)]
2692    pub fn is_safe_integer(value: &JsValue) -> bool;
2693
2694    /// The `Number` JavaScript object is a wrapper object allowing
2695    /// you to work with numerical values. A `Number` object is
2696    /// created using the `Number()` constructor.
2697    ///
2698    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)
2699    #[wasm_bindgen(constructor)]
2700    #[deprecated(note = "recommended to use `Number::from` instead")]
2701    #[allow(deprecated)]
2702    pub fn new(value: &JsValue) -> Number;
2703
2704    #[wasm_bindgen(constructor)]
2705    fn new_from_str(value: &str) -> Number;
2706
2707    /// The `Number.parseInt()` method parses a string argument and returns an
2708    /// integer of the specified radix or base.
2709    ///
2710    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/parseInt)
2711    #[wasm_bindgen(static_method_of = Number, js_name = parseInt)]
2712    pub fn parse_int(text: &str, radix: u8) -> f64;
2713
2714    /// The `Number.parseFloat()` method parses a string argument and returns a
2715    /// floating point number.
2716    ///
2717    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/parseFloat)
2718    #[wasm_bindgen(static_method_of = Number, js_name = parseFloat)]
2719    pub fn parse_float(text: &str) -> f64;
2720
2721    /// The `toLocaleString()` method returns a string with a language sensitive
2722    /// representation of this number.
2723    ///
2724    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString)
2725    #[wasm_bindgen(method, js_name = toLocaleString)]
2726    pub fn to_locale_string(this: &Number, locale: &str) -> JsString;
2727
2728    /// The `toPrecision()` method returns a string representing the Number
2729    /// object to the specified precision.
2730    ///
2731    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toPrecision)
2732    #[wasm_bindgen(catch, method, js_name = toPrecision)]
2733    pub fn to_precision(this: &Number, precision: u8) -> Result<JsString, JsValue>;
2734
2735    /// The `toFixed()` method returns a string representing the Number
2736    /// object using fixed-point notation.
2737    ///
2738    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed)
2739    #[wasm_bindgen(catch, method, js_name = toFixed)]
2740    pub fn to_fixed(this: &Number, digits: u8) -> Result<JsString, JsValue>;
2741
2742    /// The `toExponential()` method returns a string representing the Number
2743    /// object in exponential notation.
2744    ///
2745    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toExponential)
2746    #[wasm_bindgen(catch, method, js_name = toExponential)]
2747    pub fn to_exponential(this: &Number, fraction_digits: u8) -> Result<JsString, JsValue>;
2748
2749    /// The `toString()` method returns a string representing the
2750    /// specified Number object.
2751    ///
2752    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString)
2753    #[wasm_bindgen(catch, method, js_name = toString)]
2754    pub fn to_string(this: &Number, radix: u8) -> Result<JsString, JsValue>;
2755
2756    /// The `valueOf()` method returns the wrapped primitive value of
2757    /// a Number object.
2758    ///
2759    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/valueOf)
2760    #[wasm_bindgen(method, js_name = valueOf)]
2761    pub fn value_of(this: &Number) -> f64;
2762}
2763
2764impl Number {
2765    /// The smallest interval between two representable numbers.
2766    ///
2767    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/EPSILON)
2768    pub const EPSILON: f64 = f64::EPSILON;
2769    /// The maximum safe integer in JavaScript (2^53 - 1).
2770    ///
2771    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER)
2772    pub const MAX_SAFE_INTEGER: f64 = 9007199254740991.0;
2773    /// The largest positive representable number.
2774    ///
2775    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_VALUE)
2776    pub const MAX_VALUE: f64 = f64::MAX;
2777    /// The minimum safe integer in JavaScript (-(2^53 - 1)).
2778    ///
2779    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MIN_SAFE_INTEGER)
2780    pub const MIN_SAFE_INTEGER: f64 = -9007199254740991.0;
2781    /// The smallest positive representable number—that is, the positive number closest to zero
2782    /// (without actually being zero).
2783    ///
2784    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MIN_VALUE)
2785    // Cannot use f64::MIN_POSITIVE since that is the smallest **normal** positive number.
2786    pub const MIN_VALUE: f64 = 5E-324;
2787    /// Special "Not a Number" value.
2788    ///
2789    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/NaN)
2790    pub const NAN: f64 = f64::NAN;
2791    /// Special value representing negative infinity. Returned on overflow.
2792    ///
2793    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/NEGATIVE_INFINITY)
2794    pub const NEGATIVE_INFINITY: f64 = f64::NEG_INFINITY;
2795    /// Special value representing infinity. Returned on overflow.
2796    ///
2797    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/POSITIVE_INFINITY)
2798    pub const POSITIVE_INFINITY: f64 = f64::INFINITY;
2799
2800    /// Applies the binary `**` JS operator on the two `Number`s.
2801    ///
2802    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Exponentiation)
2803    #[inline]
2804    pub fn pow(&self, rhs: &Self) -> Self {
2805        JsValue::as_ref(self)
2806            .pow(JsValue::as_ref(rhs))
2807            .unchecked_into()
2808    }
2809
2810    /// Applies the binary `>>>` JS operator on the two `Number`s.
2811    ///
2812    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Unsigned_right_shift)
2813    #[inline]
2814    pub fn unsigned_shr(&self, rhs: &Self) -> Self {
2815        Number::from(JsValue::as_ref(self).unsigned_shr(JsValue::as_ref(rhs)))
2816    }
2817}
2818
2819macro_rules! number_from {
2820    ($($x:ident)*) => ($(
2821        impl From<$x> for Number {
2822            #[inline]
2823            fn from(x: $x) -> Number {
2824                Number::unchecked_from_js(JsValue::from(x))
2825            }
2826        }
2827
2828        impl PartialEq<$x> for Number {
2829            #[inline]
2830            fn eq(&self, other: &$x) -> bool {
2831                self.value_of() == f64::from(*other)
2832            }
2833        }
2834    )*)
2835}
2836number_from!(i8 u8 i16 u16 i32 u32 f32 f64);
2837
2838/// The error type returned when a checked integral type conversion fails.
2839#[derive(Debug, Copy, Clone, PartialEq, Eq)]
2840pub struct TryFromIntError(());
2841
2842impl fmt::Display for TryFromIntError {
2843    fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
2844        fmt.write_str("out of range integral type conversion attempted")
2845    }
2846}
2847
2848#[cfg(feature = "std")]
2849impl std::error::Error for TryFromIntError {}
2850
2851macro_rules! number_try_from {
2852    ($($x:ident)*) => ($(
2853        impl TryFrom<$x> for Number {
2854            type Error = TryFromIntError;
2855
2856            #[inline]
2857            fn try_from(x: $x) -> Result<Number, Self::Error> {
2858                let x_f64 = x as f64;
2859                if (Number::MIN_SAFE_INTEGER..=Number::MAX_SAFE_INTEGER).contains(&x_f64) {
2860                    Ok(Number::from(x_f64))
2861                } else {
2862                    Err(TryFromIntError(()))
2863                }
2864            }
2865        }
2866    )*)
2867}
2868number_try_from!(i64 u64 i128 u128);
2869
2870// TODO: add this on the next major version, when blanket impl is removed
2871/*
2872impl convert::TryFrom<JsValue> for Number {
2873    type Error = Error;
2874
2875    fn try_from(value: JsValue) -> Result<Self, Self::Error> {
2876        return match f64::try_from(value) {
2877            Ok(num) => Ok(Number::from(num)),
2878            Err(jsval) => Err(jsval.unchecked_into())
2879        }
2880    }
2881}
2882*/
2883
2884impl From<&Number> for f64 {
2885    #[inline]
2886    fn from(n: &Number) -> f64 {
2887        n.value_of()
2888    }
2889}
2890
2891impl From<Number> for f64 {
2892    #[inline]
2893    fn from(n: Number) -> f64 {
2894        <f64 as From<&'_ Number>>::from(&n)
2895    }
2896}
2897
2898impl fmt::Debug for Number {
2899    #[inline]
2900    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2901        fmt::Debug::fmt(&self.value_of(), f)
2902    }
2903}
2904
2905impl fmt::Display for Number {
2906    #[inline]
2907    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2908        fmt::Display::fmt(&self.value_of(), f)
2909    }
2910}
2911
2912impl Default for Number {
2913    fn default() -> Self {
2914        Self::from(f64::default())
2915    }
2916}
2917
2918impl PartialEq<BigInt> for Number {
2919    #[inline]
2920    fn eq(&self, other: &BigInt) -> bool {
2921        JsValue::as_ref(self).loose_eq(JsValue::as_ref(other))
2922    }
2923}
2924
2925impl Not for &Number {
2926    type Output = BigInt;
2927
2928    #[inline]
2929    fn not(self) -> Self::Output {
2930        JsValue::as_ref(self).bit_not().unchecked_into()
2931    }
2932}
2933
2934forward_deref_unop!(impl Not, not for Number);
2935forward_js_unop!(impl Neg, neg for Number);
2936forward_js_binop!(impl BitAnd, bitand for Number);
2937forward_js_binop!(impl BitOr, bitor for Number);
2938forward_js_binop!(impl BitXor, bitxor for Number);
2939forward_js_binop!(impl Shl, shl for Number);
2940forward_js_binop!(impl Shr, shr for Number);
2941forward_js_binop!(impl Add, add for Number);
2942forward_js_binop!(impl Sub, sub for Number);
2943forward_js_binop!(impl Div, div for Number);
2944forward_js_binop!(impl Mul, mul for Number);
2945forward_js_binop!(impl Rem, rem for Number);
2946
2947sum_product!(Number);
2948
2949impl PartialOrd for Number {
2950    #[inline]
2951    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
2952        if Number::is_nan(self) || Number::is_nan(other) {
2953            None
2954        } else if self == other {
2955            Some(Ordering::Equal)
2956        } else if self.lt(other) {
2957            Some(Ordering::Less)
2958        } else {
2959            Some(Ordering::Greater)
2960        }
2961    }
2962
2963    #[inline]
2964    fn lt(&self, other: &Self) -> bool {
2965        JsValue::as_ref(self).lt(JsValue::as_ref(other))
2966    }
2967
2968    #[inline]
2969    fn le(&self, other: &Self) -> bool {
2970        JsValue::as_ref(self).le(JsValue::as_ref(other))
2971    }
2972
2973    #[inline]
2974    fn ge(&self, other: &Self) -> bool {
2975        JsValue::as_ref(self).ge(JsValue::as_ref(other))
2976    }
2977
2978    #[inline]
2979    fn gt(&self, other: &Self) -> bool {
2980        JsValue::as_ref(self).gt(JsValue::as_ref(other))
2981    }
2982}
2983
2984impl FromStr for Number {
2985    type Err = Infallible;
2986
2987    #[allow(deprecated)]
2988    #[inline]
2989    fn from_str(s: &str) -> Result<Self, Self::Err> {
2990        Ok(Number::new_from_str(s))
2991    }
2992}
2993
2994// Date.
2995#[wasm_bindgen]
2996extern "C" {
2997    #[wasm_bindgen(extends = Object, typescript_type = "Date")]
2998    #[derive(Clone, Debug, PartialEq, Eq)]
2999    pub type Date;
3000
3001    /// The `getDate()` method returns the day of the month for the
3002    /// specified date according to local time.
3003    ///
3004    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getDate)
3005    #[wasm_bindgen(method, js_name = getDate)]
3006    pub fn get_date(this: &Date) -> u32;
3007
3008    /// The `getDay()` method returns the day of the week for the specified date according to local time,
3009    /// where 0 represents Sunday. For the day of the month see getDate().
3010    ///
3011    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getDay)
3012    #[wasm_bindgen(method, js_name = getDay)]
3013    pub fn get_day(this: &Date) -> u32;
3014
3015    /// The `getFullYear()` method returns the year of the specified date according to local time.
3016    ///
3017    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getFullYear)
3018    #[wasm_bindgen(method, js_name = getFullYear)]
3019    pub fn get_full_year(this: &Date) -> u32;
3020
3021    /// The `getHours()` method returns the hour for the specified date, according to local time.
3022    ///
3023    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getHours)
3024    #[wasm_bindgen(method, js_name = getHours)]
3025    pub fn get_hours(this: &Date) -> u32;
3026
3027    /// The `getMilliseconds()` method returns the milliseconds in the specified date according to local time.
3028    ///
3029    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMilliseconds)
3030    #[wasm_bindgen(method, js_name = getMilliseconds)]
3031    pub fn get_milliseconds(this: &Date) -> u32;
3032
3033    /// The `getMinutes()` method returns the minutes in the specified date according to local time.
3034    ///
3035    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMinutes)
3036    #[wasm_bindgen(method, js_name = getMinutes)]
3037    pub fn get_minutes(this: &Date) -> u32;
3038
3039    /// The `getMonth()` method returns the month in the specified date according to local time,
3040    /// as a zero-based value (where zero indicates the first month of the year).
3041    ///
3042    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMonth)
3043    #[wasm_bindgen(method, js_name = getMonth)]
3044    pub fn get_month(this: &Date) -> u32;
3045
3046    /// The `getSeconds()` method returns the seconds in the specified date according to local time.
3047    ///
3048    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getSeconds)
3049    #[wasm_bindgen(method, js_name = getSeconds)]
3050    pub fn get_seconds(this: &Date) -> u32;
3051
3052    /// The `getTime()` method returns the numeric value corresponding to the time for the specified date
3053    /// according to universal time.
3054    ///
3055    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTime)
3056    #[wasm_bindgen(method, js_name = getTime)]
3057    pub fn get_time(this: &Date) -> f64;
3058
3059    /// The `getTimezoneOffset()` method returns the time zone difference, in minutes,
3060    /// from current locale (host system settings) to UTC.
3061    ///
3062    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset)
3063    #[wasm_bindgen(method, js_name = getTimezoneOffset)]
3064    pub fn get_timezone_offset(this: &Date) -> f64;
3065
3066    /// The `getUTCDate()` method returns the day (date) of the month in the specified date
3067    /// according to universal time.
3068    ///
3069    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCDate)
3070    #[wasm_bindgen(method, js_name = getUTCDate)]
3071    pub fn get_utc_date(this: &Date) -> u32;
3072
3073    /// The `getUTCDay()` method returns the day of the week in the specified date according to universal time,
3074    /// where 0 represents Sunday.
3075    ///
3076    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCDay)
3077    #[wasm_bindgen(method, js_name = getUTCDay)]
3078    pub fn get_utc_day(this: &Date) -> u32;
3079
3080    /// The `getUTCFullYear()` method returns the year in the specified date according to universal time.
3081    ///
3082    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCFullYear)
3083    #[wasm_bindgen(method, js_name = getUTCFullYear)]
3084    pub fn get_utc_full_year(this: &Date) -> u32;
3085
3086    /// The `getUTCHours()` method returns the hours in the specified date according to universal time.
3087    ///
3088    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCHours)
3089    #[wasm_bindgen(method, js_name = getUTCHours)]
3090    pub fn get_utc_hours(this: &Date) -> u32;
3091
3092    /// The `getUTCMilliseconds()` method returns the milliseconds in the specified date
3093    /// according to universal time.
3094    ///
3095    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMilliseconds)
3096    #[wasm_bindgen(method, js_name = getUTCMilliseconds)]
3097    pub fn get_utc_milliseconds(this: &Date) -> u32;
3098
3099    /// The `getUTCMinutes()` method returns the minutes in the specified date according to universal time.
3100    ///
3101    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMinutes)
3102    #[wasm_bindgen(method, js_name = getUTCMinutes)]
3103    pub fn get_utc_minutes(this: &Date) -> u32;
3104
3105    /// The `getUTCMonth()` returns the month of the specified date according to universal time,
3106    /// as a zero-based value (where zero indicates the first month of the year).
3107    ///
3108    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMonth)
3109    #[wasm_bindgen(method, js_name = getUTCMonth)]
3110    pub fn get_utc_month(this: &Date) -> u32;
3111
3112    /// The `getUTCSeconds()` method returns the seconds in the specified date according to universal time.
3113    ///
3114    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCSeconds)
3115    #[wasm_bindgen(method, js_name = getUTCSeconds)]
3116    pub fn get_utc_seconds(this: &Date) -> u32;
3117
3118    /// Creates a JavaScript `Date` instance that represents
3119    /// a single moment in time. `Date` objects are based on a time value that is
3120    /// the number of milliseconds since 1 January 1970 UTC.
3121    ///
3122    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
3123    #[wasm_bindgen(constructor)]
3124    pub fn new(init: &JsValue) -> Date;
3125
3126    /// Creates a JavaScript `Date` instance that represents the current moment in
3127    /// time.
3128    ///
3129    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
3130    #[wasm_bindgen(constructor)]
3131    pub fn new_0() -> Date;
3132
3133    /// Creates a JavaScript `Date` instance that represents
3134    /// a single moment in time. `Date` objects are based on a time value that is
3135    /// the number of milliseconds since 1 January 1970 UTC.
3136    ///
3137    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
3138    #[wasm_bindgen(constructor)]
3139    pub fn new_with_year_month(year: u32, month: i32) -> Date;
3140
3141    /// Creates a JavaScript `Date` instance that represents
3142    /// a single moment in time. `Date` objects are based on a time value that is
3143    /// the number of milliseconds since 1 January 1970 UTC.
3144    ///
3145    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
3146    #[wasm_bindgen(constructor)]
3147    pub fn new_with_year_month_day(year: u32, month: i32, day: i32) -> Date;
3148
3149    /// Creates a JavaScript `Date` instance that represents
3150    /// a single moment in time. `Date` objects are based on a time value that is
3151    /// the number of milliseconds since 1 January 1970 UTC.
3152    ///
3153    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
3154    #[wasm_bindgen(constructor)]
3155    pub fn new_with_year_month_day_hr(year: u32, month: i32, day: i32, hr: i32) -> Date;
3156
3157    /// Creates a JavaScript `Date` instance that represents
3158    /// a single moment in time. `Date` objects are based on a time value that is
3159    /// the number of milliseconds since 1 January 1970 UTC.
3160    ///
3161    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
3162    #[wasm_bindgen(constructor)]
3163    pub fn new_with_year_month_day_hr_min(
3164        year: u32,
3165        month: i32,
3166        day: i32,
3167        hr: i32,
3168        min: i32,
3169    ) -> Date;
3170
3171    /// Creates a JavaScript `Date` instance that represents
3172    /// a single moment in time. `Date` objects are based on a time value that is
3173    /// the number of milliseconds since 1 January 1970 UTC.
3174    ///
3175    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
3176    #[wasm_bindgen(constructor)]
3177    pub fn new_with_year_month_day_hr_min_sec(
3178        year: u32,
3179        month: i32,
3180        day: i32,
3181        hr: i32,
3182        min: i32,
3183        sec: i32,
3184    ) -> Date;
3185
3186    /// Creates a JavaScript `Date` instance that represents
3187    /// a single moment in time. `Date` objects are based on a time value that is
3188    /// the number of milliseconds since 1 January 1970 UTC.
3189    ///
3190    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
3191    #[wasm_bindgen(constructor)]
3192    pub fn new_with_year_month_day_hr_min_sec_milli(
3193        year: u32,
3194        month: i32,
3195        day: i32,
3196        hr: i32,
3197        min: i32,
3198        sec: i32,
3199        milli: i32,
3200    ) -> Date;
3201
3202    /// The `Date.now()` method returns the number of milliseconds
3203    /// elapsed since January 1, 1970 00:00:00 UTC.
3204    ///
3205    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now)
3206    #[wasm_bindgen(static_method_of = Date)]
3207    pub fn now() -> f64;
3208
3209    /// The `Date.parse()` method parses a string representation of a date, and returns the number of milliseconds
3210    /// since January 1, 1970, 00:00:00 UTC or `NaN` if the string is unrecognized or, in some cases,
3211    /// contains illegal date values (e.g. 2015-02-31).
3212    ///
3213    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse)
3214    #[wasm_bindgen(static_method_of = Date)]
3215    pub fn parse(date: &str) -> f64;
3216
3217    /// The `setDate()` method sets the day of the Date object relative to the beginning of the currently set month.
3218    ///
3219    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setDate)
3220    #[wasm_bindgen(method, js_name = setDate)]
3221    pub fn set_date(this: &Date, day: u32) -> f64;
3222
3223    /// The `setFullYear()` method sets the full year for a specified date according to local time.
3224    /// Returns new timestamp.
3225    ///
3226    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setFullYear)
3227    #[wasm_bindgen(method, js_name = setFullYear)]
3228    pub fn set_full_year(this: &Date, year: u32) -> f64;
3229
3230    /// The `setFullYear()` method sets the full year for a specified date according to local time.
3231    /// Returns new timestamp.
3232    ///
3233    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setFullYear)
3234    #[wasm_bindgen(method, js_name = setFullYear)]
3235    pub fn set_full_year_with_month(this: &Date, year: u32, month: i32) -> f64;
3236
3237    /// The `setFullYear()` method sets the full year for a specified date according to local time.
3238    /// Returns new timestamp.
3239    ///
3240    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setFullYear)
3241    #[wasm_bindgen(method, js_name = setFullYear)]
3242    pub fn set_full_year_with_month_date(this: &Date, year: u32, month: i32, date: i32) -> f64;
3243
3244    /// The `setHours()` method sets the hours for a specified date according to local time,
3245    /// and returns the number of milliseconds since January 1, 1970 00:00:00 UTC until the time represented
3246    /// by the updated Date instance.
3247    ///
3248    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setHours)
3249    #[wasm_bindgen(method, js_name = setHours)]
3250    pub fn set_hours(this: &Date, hours: u32) -> f64;
3251
3252    /// The `setMilliseconds()` method sets the milliseconds for a specified date according to local time.
3253    ///
3254    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setMilliseconds)
3255    #[wasm_bindgen(method, js_name = setMilliseconds)]
3256    pub fn set_milliseconds(this: &Date, milliseconds: u32) -> f64;
3257
3258    /// The `setMinutes()` method sets the minutes for a specified date according to local time.
3259    ///
3260    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setMinutes)
3261    #[wasm_bindgen(method, js_name = setMinutes)]
3262    pub fn set_minutes(this: &Date, minutes: u32) -> f64;
3263
3264    /// The `setMonth()` method sets the month for a specified date according to the currently set year.
3265    ///
3266    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setMonth)
3267    #[wasm_bindgen(method, js_name = setMonth)]
3268    pub fn set_month(this: &Date, month: u32) -> f64;
3269
3270    /// The `setSeconds()` method sets the seconds for a specified date according to local time.
3271    ///
3272    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setSeconds)
3273    #[wasm_bindgen(method, js_name = setSeconds)]
3274    pub fn set_seconds(this: &Date, seconds: u32) -> f64;
3275
3276    /// The `setTime()` method sets the Date object to the time represented by a number of milliseconds
3277    /// since January 1, 1970, 00:00:00 UTC.
3278    ///
3279    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setTime)
3280    #[wasm_bindgen(method, js_name = setTime)]
3281    pub fn set_time(this: &Date, time: f64) -> f64;
3282
3283    /// The `setUTCDate()` method sets the day of the month for a specified date
3284    /// according to universal time.
3285    ///
3286    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCDate)
3287    #[wasm_bindgen(method, js_name = setUTCDate)]
3288    pub fn set_utc_date(this: &Date, day: u32) -> f64;
3289
3290    /// The `setUTCFullYear()` method sets the full year for a specified date according to universal time.
3291    ///
3292    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCFullYear)
3293    #[wasm_bindgen(method, js_name = setUTCFullYear)]
3294    pub fn set_utc_full_year(this: &Date, year: u32) -> f64;
3295
3296    /// The `setUTCFullYear()` method sets the full year for a specified date according to universal time.
3297    ///
3298    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCFullYear)
3299    #[wasm_bindgen(method, js_name = setUTCFullYear)]
3300    pub fn set_utc_full_year_with_month(this: &Date, year: u32, month: i32) -> f64;
3301
3302    /// The `setUTCFullYear()` method sets the full year for a specified date according to universal time.
3303    ///
3304    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCFullYear)
3305    #[wasm_bindgen(method, js_name = setUTCFullYear)]
3306    pub fn set_utc_full_year_with_month_date(this: &Date, year: u32, month: i32, date: i32) -> f64;
3307
3308    /// The `setUTCHours()` method sets the hour for a specified date according to universal time,
3309    /// and returns the number of milliseconds since  January 1, 1970 00:00:00 UTC until the time
3310    /// represented by the updated Date instance.
3311    ///
3312    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCHours)
3313    #[wasm_bindgen(method, js_name = setUTCHours)]
3314    pub fn set_utc_hours(this: &Date, hours: u32) -> f64;
3315
3316    /// The `setUTCMilliseconds()` method sets the milliseconds for a specified date
3317    /// according to universal time.
3318    ///
3319    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCMilliseconds)
3320    #[wasm_bindgen(method, js_name = setUTCMilliseconds)]
3321    pub fn set_utc_milliseconds(this: &Date, milliseconds: u32) -> f64;
3322
3323    /// The `setUTCMinutes()` method sets the minutes for a specified date according to universal time.
3324    ///
3325    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCMinutes)
3326    #[wasm_bindgen(method, js_name = setUTCMinutes)]
3327    pub fn set_utc_minutes(this: &Date, minutes: u32) -> f64;
3328
3329    /// The `setUTCMonth()` method sets the month for a specified date according to universal time.
3330    ///
3331    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCMonth)
3332    #[wasm_bindgen(method, js_name = setUTCMonth)]
3333    pub fn set_utc_month(this: &Date, month: u32) -> f64;
3334
3335    /// The `setUTCSeconds()` method sets the seconds for a specified date according to universal time.
3336    ///
3337    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCSeconds)
3338    #[wasm_bindgen(method, js_name = setUTCSeconds)]
3339    pub fn set_utc_seconds(this: &Date, seconds: u32) -> f64;
3340
3341    /// The `toDateString()` method returns the date portion of a Date object
3342    /// in human readable form in American English.
3343    ///
3344    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toDateString)
3345    #[wasm_bindgen(method, js_name = toDateString)]
3346    pub fn to_date_string(this: &Date) -> JsString;
3347
3348    /// The `toISOString()` method returns a string in simplified extended ISO format (ISO
3349    /// 8601), which is always 24 or 27 characters long (YYYY-MM-DDTHH:mm:ss.sssZ or
3350    /// ±YYYYYY-MM-DDTHH:mm:ss.sssZ, respectively). The timezone is always zero UTC offset,
3351    /// as denoted by the suffix "Z"
3352    ///
3353    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
3354    #[wasm_bindgen(method, js_name = toISOString)]
3355    pub fn to_iso_string(this: &Date) -> JsString;
3356
3357    /// The `toJSON()` method returns a string representation of the Date object.
3358    ///
3359    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toJSON)
3360    #[wasm_bindgen(method, js_name = toJSON)]
3361    pub fn to_json(this: &Date) -> JsString;
3362
3363    /// The `toLocaleDateString()` method returns a string with a language sensitive
3364    /// representation of the date portion of this date. The new locales and options
3365    /// arguments let applications specify the language whose formatting conventions
3366    /// should be used and allow to customize the behavior of the function.
3367    /// In older implementations, which ignore the locales and options arguments,
3368    /// the locale used and the form of the string
3369    /// returned are entirely implementation dependent.
3370    ///
3371    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString)
3372    #[wasm_bindgen(method, js_name = toLocaleDateString)]
3373    pub fn to_locale_date_string(this: &Date, locale: &str, options: &JsValue) -> JsString;
3374
3375    /// The `toLocaleString()` method returns a string with a language sensitive
3376    /// representation of this date. The new locales and options arguments
3377    /// let applications specify the language whose formatting conventions
3378    /// should be used and customize the behavior of the function.
3379    /// In older implementations, which ignore the locales
3380    /// and options arguments, the locale used and the form of the string
3381    /// returned are entirely implementation dependent.
3382    ///
3383    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString)
3384    #[wasm_bindgen(method, js_name = toLocaleString)]
3385    pub fn to_locale_string(this: &Date, locale: &str, options: &JsValue) -> JsString;
3386
3387    /// The `toLocaleTimeString()` method returns a string with a language sensitive
3388    /// representation of the time portion of this date. The new locales and options
3389    /// arguments let applications specify the language whose formatting conventions should be
3390    /// used and customize the behavior of the function. In older implementations, which ignore
3391    /// the locales and options arguments, the locale used and the form of the string
3392    /// returned are entirely implementation dependent.
3393    ///
3394    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleTimeString)
3395    #[wasm_bindgen(method, js_name = toLocaleTimeString)]
3396    pub fn to_locale_time_string(this: &Date, locale: &str) -> JsString;
3397
3398    /// The `toString()` method returns a string representing
3399    /// the specified Date object.
3400    ///
3401    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toString)
3402    #[wasm_bindgen(method, js_name = toString)]
3403    pub fn to_string(this: &Date) -> JsString;
3404
3405    /// The `toTimeString()` method returns the time portion of a Date object in human
3406    /// readable form in American English.
3407    ///
3408    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toTimeString)
3409    #[wasm_bindgen(method, js_name = toTimeString)]
3410    pub fn to_time_string(this: &Date) -> JsString;
3411
3412    /// The `toUTCString()` method converts a date to a string,
3413    /// using the UTC time zone.
3414    ///
3415    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toUTCString)
3416    #[wasm_bindgen(method, js_name = toUTCString)]
3417    pub fn to_utc_string(this: &Date) -> JsString;
3418
3419    /// The `Date.UTC()` method accepts the same parameters as the
3420    /// longest form of the constructor, and returns the number of
3421    /// milliseconds in a `Date` object since January 1, 1970,
3422    /// 00:00:00, universal time.
3423    ///
3424    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/UTC)
3425    #[wasm_bindgen(static_method_of = Date, js_name = UTC)]
3426    pub fn utc(year: f64, month: f64) -> f64;
3427
3428    /// The `valueOf()` method  returns the primitive value of
3429    /// a Date object.
3430    ///
3431    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/valueOf)
3432    #[wasm_bindgen(method, js_name = valueOf)]
3433    pub fn value_of(this: &Date) -> f64;
3434}
3435
3436// Object.
3437#[wasm_bindgen]
3438extern "C" {
3439    #[wasm_bindgen(typescript_type = "object")]
3440    #[derive(Clone, Debug)]
3441    pub type Object;
3442
3443    /// The `Object.assign()` method is used to copy the values of all enumerable
3444    /// own properties from one or more source objects to a target object. It
3445    /// will return the target object.
3446    ///
3447    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign)
3448    #[wasm_bindgen(static_method_of = Object)]
3449    pub fn assign(target: &Object, source: &Object) -> Object;
3450
3451    /// The `Object.assign()` method is used to copy the values of all enumerable
3452    /// own properties from one or more source objects to a target object. It
3453    /// will return the target object.
3454    ///
3455    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign)
3456    #[wasm_bindgen(static_method_of = Object, js_name = assign)]
3457    pub fn assign2(target: &Object, source1: &Object, source2: &Object) -> Object;
3458
3459    /// The `Object.assign()` method is used to copy the values of all enumerable
3460    /// own properties from one or more source objects to a target object. It
3461    /// will return the target object.
3462    ///
3463    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign)
3464    #[wasm_bindgen(static_method_of = Object, js_name = assign)]
3465    pub fn assign3(target: &Object, source1: &Object, source2: &Object, source3: &Object)
3466        -> Object;
3467
3468    /// The constructor property returns a reference to the `Object` constructor
3469    /// function that created the instance object.
3470    ///
3471    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/constructor)
3472    #[wasm_bindgen(method, getter)]
3473    pub fn constructor(this: &Object) -> Function;
3474
3475    /// The `Object.create()` method creates a new object, using an existing
3476    /// object to provide the newly created object's prototype.
3477    ///
3478    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create)
3479    #[wasm_bindgen(static_method_of = Object)]
3480    pub fn create(prototype: &Object) -> Object;
3481
3482    /// The static method `Object.defineProperty()` defines a new
3483    /// property directly on an object, or modifies an existing
3484    /// property on an object, and returns the object.
3485    ///
3486    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty)
3487    #[wasm_bindgen(static_method_of = Object, js_name = defineProperty)]
3488    pub fn define_property(obj: &Object, prop: &JsValue, descriptor: &Object) -> Object;
3489
3490    /// The `Object.defineProperties()` method defines new or modifies
3491    /// existing properties directly on an object, returning the
3492    /// object.
3493    ///
3494    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperties)
3495    #[wasm_bindgen(static_method_of = Object, js_name = defineProperties)]
3496    pub fn define_properties(obj: &Object, props: &Object) -> Object;
3497
3498    /// The `Object.entries()` method returns an array of a given
3499    /// object's own enumerable property [key, value] pairs, in the
3500    /// same order as that provided by a for...in loop (the difference
3501    /// being that a for-in loop enumerates properties in the
3502    /// prototype chain as well).
3503    ///
3504    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries)
3505    #[wasm_bindgen(static_method_of = Object)]
3506    pub fn entries(object: &Object) -> Array;
3507
3508    /// The `Object.freeze()` method freezes an object: that is, prevents new
3509    /// properties from being added to it; prevents existing properties from
3510    /// being removed; and prevents existing properties, or their enumerability,
3511    /// configurability, or writability, from being changed, it also prevents
3512    /// the prototype from being changed. The method returns the passed object.
3513    ///
3514    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze)
3515    #[wasm_bindgen(static_method_of = Object)]
3516    pub fn freeze(value: &Object) -> Object;
3517
3518    /// The `Object.fromEntries()` method transforms a list of key-value pairs
3519    /// into an object.
3520    ///
3521    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/fromEntries)
3522    #[wasm_bindgen(static_method_of = Object, catch, js_name = fromEntries)]
3523    pub fn from_entries(iterable: &JsValue) -> Result<Object, JsValue>;
3524
3525    /// The `Object.getOwnPropertyDescriptor()` method returns a
3526    /// property descriptor for an own property (that is, one directly
3527    /// present on an object and not in the object's prototype chain)
3528    /// of a given object.
3529    ///
3530    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor)
3531    #[wasm_bindgen(static_method_of = Object, js_name = getOwnPropertyDescriptor)]
3532    pub fn get_own_property_descriptor(obj: &Object, prop: &JsValue) -> JsValue;
3533
3534    /// The `Object.getOwnPropertyDescriptors()` method returns all own
3535    /// property descriptors of a given object.
3536    ///
3537    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptors)
3538    #[wasm_bindgen(static_method_of = Object, js_name = getOwnPropertyDescriptors)]
3539    pub fn get_own_property_descriptors(obj: &Object) -> JsValue;
3540
3541    /// The `Object.getOwnPropertyNames()` method returns an array of
3542    /// all properties (including non-enumerable properties except for
3543    /// those which use Symbol) found directly upon a given object.
3544    ///
3545    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames)
3546    #[wasm_bindgen(static_method_of = Object, js_name = getOwnPropertyNames)]
3547    pub fn get_own_property_names(obj: &Object) -> Array;
3548
3549    /// The `Object.getOwnPropertySymbols()` method returns an array of
3550    /// all symbol properties found directly upon a given object.
3551    ///
3552    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertySymbols)
3553    #[wasm_bindgen(static_method_of = Object, js_name = getOwnPropertySymbols)]
3554    pub fn get_own_property_symbols(obj: &Object) -> Array;
3555
3556    /// The `Object.getPrototypeOf()` method returns the prototype
3557    /// (i.e. the value of the internal [[Prototype]] property) of the
3558    /// specified object.
3559    ///
3560    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getPrototypeOf)
3561    #[wasm_bindgen(static_method_of = Object, js_name = getPrototypeOf)]
3562    pub fn get_prototype_of(obj: &JsValue) -> Object;
3563
3564    /// The `hasOwnProperty()` method returns a boolean indicating whether the
3565    /// object has the specified property as its own property (as opposed to
3566    /// inheriting it).
3567    ///
3568    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty)
3569    #[wasm_bindgen(method, js_name = hasOwnProperty)]
3570    pub fn has_own_property(this: &Object, property: &JsValue) -> bool;
3571
3572    /// The `Object.hasOwn()` method returns a boolean indicating whether the
3573    /// object passed in has the specified property as its own property (as
3574    /// opposed to inheriting it).
3575    ///
3576    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwn)
3577    #[wasm_bindgen(static_method_of = Object, js_name = hasOwn)]
3578    pub fn has_own(instance: &Object, property: &JsValue) -> bool;
3579
3580    /// The `Object.is()` method determines whether two values are the same value.
3581    ///
3582    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is)
3583    #[wasm_bindgen(static_method_of = Object)]
3584    pub fn is(value_1: &JsValue, value_2: &JsValue) -> bool;
3585
3586    /// The `Object.isExtensible()` method determines if an object is extensible
3587    /// (whether it can have new properties added to it).
3588    ///
3589    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isExtensible)
3590    #[wasm_bindgen(static_method_of = Object, js_name = isExtensible)]
3591    pub fn is_extensible(object: &Object) -> bool;
3592
3593    /// The `Object.isFrozen()` determines if an object is frozen.
3594    ///
3595    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isFrozen)
3596    #[wasm_bindgen(static_method_of = Object, js_name = isFrozen)]
3597    pub fn is_frozen(object: &Object) -> bool;
3598
3599    /// The `Object.isSealed()` method determines if an object is sealed.
3600    ///
3601    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isSealed)
3602    #[wasm_bindgen(static_method_of = Object, js_name = isSealed)]
3603    pub fn is_sealed(object: &Object) -> bool;
3604
3605    /// The `isPrototypeOf()` method checks if an object exists in another
3606    /// object's prototype chain.
3607    ///
3608    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isPrototypeOf)
3609    #[wasm_bindgen(method, js_name = isPrototypeOf)]
3610    pub fn is_prototype_of(this: &Object, value: &JsValue) -> bool;
3611
3612    /// The `Object.keys()` method returns an array of a given object's property
3613    /// names, in the same order as we get with a normal loop.
3614    ///
3615    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys)
3616    #[wasm_bindgen(static_method_of = Object)]
3617    pub fn keys(object: &Object) -> Array;
3618
3619    /// The [`Object`] constructor creates an object wrapper.
3620    ///
3621    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)
3622    #[wasm_bindgen(constructor)]
3623    pub fn new() -> Object;
3624
3625    /// The `Object.preventExtensions()` method prevents new properties from
3626    /// ever being added to an object (i.e. prevents future extensions to the
3627    /// object).
3628    ///
3629    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/preventExtensions)
3630    #[wasm_bindgen(static_method_of = Object, js_name = preventExtensions)]
3631    pub fn prevent_extensions(object: &Object);
3632
3633    /// The `propertyIsEnumerable()` method returns a Boolean indicating
3634    /// whether the specified property is enumerable.
3635    ///
3636    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/propertyIsEnumerable)
3637    #[wasm_bindgen(method, js_name = propertyIsEnumerable)]
3638    pub fn property_is_enumerable(this: &Object, property: &JsValue) -> bool;
3639
3640    /// The `Object.seal()` method seals an object, preventing new properties
3641    /// from being added to it and marking all existing properties as
3642    /// non-configurable.  Values of present properties can still be changed as
3643    /// long as they are writable.
3644    ///
3645    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/seal)
3646    #[wasm_bindgen(static_method_of = Object)]
3647    pub fn seal(value: &Object) -> Object;
3648
3649    /// The `Object.setPrototypeOf()` method sets the prototype (i.e., the
3650    /// internal `[[Prototype]]` property) of a specified object to another
3651    /// object or `null`.
3652    ///
3653    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/setPrototypeOf)
3654    #[wasm_bindgen(static_method_of = Object, js_name = setPrototypeOf)]
3655    pub fn set_prototype_of(object: &Object, prototype: &Object) -> Object;
3656
3657    /// The `toLocaleString()` method returns a string representing the object.
3658    /// This method is meant to be overridden by derived objects for
3659    /// locale-specific purposes.
3660    ///
3661    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toLocaleString)
3662    #[wasm_bindgen(method, js_name = toLocaleString)]
3663    pub fn to_locale_string(this: &Object) -> JsString;
3664
3665    /// The `toString()` method returns a string representing the object.
3666    ///
3667    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString)
3668    #[wasm_bindgen(method, js_name = toString)]
3669    pub fn to_string(this: &Object) -> JsString;
3670
3671    /// The `valueOf()` method returns the primitive value of the
3672    /// specified object.
3673    ///
3674    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/valueOf)
3675    #[wasm_bindgen(method, js_name = valueOf)]
3676    pub fn value_of(this: &Object) -> Object;
3677
3678    /// The `Object.values()` method returns an array of a given object's own
3679    /// enumerable property values, in the same order as that provided by a
3680    /// `for...in` loop (the difference being that a for-in loop enumerates
3681    /// properties in the prototype chain as well).
3682    ///
3683    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/values)
3684    #[wasm_bindgen(static_method_of = Object)]
3685    pub fn values(object: &Object) -> Array;
3686}
3687
3688impl Object {
3689    /// Returns the `Object` value of this JS value if it's an instance of an
3690    /// object.
3691    ///
3692    /// If this JS value is not an instance of an object then this returns
3693    /// `None`.
3694    pub fn try_from(val: &JsValue) -> Option<&Object> {
3695        if val.is_object() {
3696            Some(val.unchecked_ref())
3697        } else {
3698            None
3699        }
3700    }
3701}
3702
3703impl PartialEq for Object {
3704    #[inline]
3705    fn eq(&self, other: &Object) -> bool {
3706        Object::is(self.as_ref(), other.as_ref())
3707    }
3708}
3709
3710impl Eq for Object {}
3711
3712impl Default for Object {
3713    fn default() -> Self {
3714        Self::new()
3715    }
3716}
3717
3718// Proxy
3719#[wasm_bindgen]
3720extern "C" {
3721    #[wasm_bindgen(typescript_type = "ProxyConstructor")]
3722    #[derive(Clone, Debug)]
3723    pub type Proxy;
3724
3725    /// The [`Proxy`] object is used to define custom behavior for fundamental
3726    /// operations (e.g. property lookup, assignment, enumeration, function
3727    /// invocation, etc).
3728    ///
3729    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy)
3730    #[wasm_bindgen(constructor)]
3731    pub fn new(target: &JsValue, handler: &Object) -> Proxy;
3732
3733    /// The `Proxy.revocable()` method is used to create a revocable [`Proxy`]
3734    /// object.
3735    ///
3736    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/revocable)
3737    #[wasm_bindgen(static_method_of = Proxy)]
3738    pub fn revocable(target: &JsValue, handler: &Object) -> Object;
3739}
3740
3741// RangeError
3742#[wasm_bindgen]
3743extern "C" {
3744    /// The `RangeError` object indicates an error when a value is not in the set
3745    /// or range of allowed values.
3746    ///
3747    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError)
3748    #[wasm_bindgen(extends = Error, extends = Object, typescript_type = "RangeError")]
3749    #[derive(Clone, Debug, PartialEq, Eq)]
3750    pub type RangeError;
3751
3752    /// The `RangeError` object indicates an error when a value is not in the set
3753    /// or range of allowed values.
3754    ///
3755    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError)
3756    #[wasm_bindgen(constructor)]
3757    pub fn new(message: &str) -> RangeError;
3758}
3759
3760// ReferenceError
3761#[wasm_bindgen]
3762extern "C" {
3763    /// The `ReferenceError` object represents an error when a non-existent
3764    /// variable is referenced.
3765    ///
3766    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError)
3767    #[wasm_bindgen(extends = Error, extends = Object, typescript_type = "ReferenceError")]
3768    #[derive(Clone, Debug, PartialEq, Eq)]
3769    pub type ReferenceError;
3770
3771    /// The `ReferenceError` object represents an error when a non-existent
3772    /// variable is referenced.
3773    ///
3774    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError)
3775    #[wasm_bindgen(constructor)]
3776    pub fn new(message: &str) -> ReferenceError;
3777}
3778
3779#[allow(non_snake_case)]
3780pub mod Reflect {
3781    use super::*;
3782
3783    // Reflect
3784    #[wasm_bindgen]
3785    extern "C" {
3786        /// The static `Reflect.apply()` method calls a target function with
3787        /// arguments as specified.
3788        ///
3789        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/apply)
3790        #[wasm_bindgen(js_namespace = Reflect, catch)]
3791        pub fn apply(
3792            target: &Function,
3793            this_argument: &JsValue,
3794            arguments_list: &Array,
3795        ) -> Result<JsValue, JsValue>;
3796
3797        /// The static `Reflect.construct()` method acts like the new operator, but
3798        /// as a function.  It is equivalent to calling `new target(...args)`. It
3799        /// gives also the added option to specify a different prototype.
3800        ///
3801        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/construct)
3802        #[wasm_bindgen(js_namespace = Reflect, catch)]
3803        pub fn construct(target: &Function, arguments_list: &Array) -> Result<JsValue, JsValue>;
3804
3805        /// The static `Reflect.construct()` method acts like the new operator, but
3806        /// as a function.  It is equivalent to calling `new target(...args)`. It
3807        /// gives also the added option to specify a different prototype.
3808        ///
3809        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/construct)
3810        #[wasm_bindgen(js_namespace = Reflect, js_name = construct, catch)]
3811        pub fn construct_with_new_target(
3812            target: &Function,
3813            arguments_list: &Array,
3814            new_target: &Function,
3815        ) -> Result<JsValue, JsValue>;
3816
3817        /// The static `Reflect.defineProperty()` method is like
3818        /// `Object.defineProperty()` but returns a `Boolean`.
3819        ///
3820        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/defineProperty)
3821        #[wasm_bindgen(js_namespace = Reflect, js_name = defineProperty, catch)]
3822        pub fn define_property(
3823            target: &Object,
3824            property_key: &JsValue,
3825            attributes: &Object,
3826        ) -> Result<bool, JsValue>;
3827
3828        /// The static `Reflect.deleteProperty()` method allows to delete
3829        /// properties.  It is like the `delete` operator as a function.
3830        ///
3831        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/deleteProperty)
3832        #[wasm_bindgen(js_namespace = Reflect, js_name = deleteProperty, catch)]
3833        pub fn delete_property(target: &Object, key: &JsValue) -> Result<bool, JsValue>;
3834
3835        /// The static `Reflect.get()` method works like getting a property from
3836        /// an object (`target[propertyKey]`) as a function.
3837        ///
3838        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/get)
3839        #[wasm_bindgen(js_namespace = Reflect, catch)]
3840        pub fn get(target: &JsValue, key: &JsValue) -> Result<JsValue, JsValue>;
3841
3842        /// The same as [`get`](fn.get.html)
3843        /// except the key is an `f64`, which is slightly faster.
3844        #[wasm_bindgen(js_namespace = Reflect, js_name = "get", catch)]
3845        pub fn get_f64(target: &JsValue, key: f64) -> Result<JsValue, JsValue>;
3846
3847        /// The same as [`get`](fn.get.html)
3848        /// except the key is a `u32`, which is slightly faster.
3849        #[wasm_bindgen(js_namespace = Reflect, js_name = "get", catch)]
3850        pub fn get_u32(target: &JsValue, key: u32) -> Result<JsValue, JsValue>;
3851
3852        /// The static `Reflect.getOwnPropertyDescriptor()` method is similar to
3853        /// `Object.getOwnPropertyDescriptor()`. It returns a property descriptor
3854        /// of the given property if it exists on the object, `undefined` otherwise.
3855        ///
3856        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/getOwnPropertyDescriptor)
3857        #[wasm_bindgen(js_namespace = Reflect, js_name = getOwnPropertyDescriptor, catch)]
3858        pub fn get_own_property_descriptor(
3859            target: &Object,
3860            property_key: &JsValue,
3861        ) -> Result<JsValue, JsValue>;
3862
3863        /// The static `Reflect.getPrototypeOf()` method is almost the same
3864        /// method as `Object.getPrototypeOf()`. It returns the prototype
3865        /// (i.e. the value of the internal `[[Prototype]]` property) of
3866        /// the specified object.
3867        ///
3868        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/getPrototypeOf)
3869        #[wasm_bindgen(js_namespace = Reflect, js_name = getPrototypeOf, catch)]
3870        pub fn get_prototype_of(target: &JsValue) -> Result<Object, JsValue>;
3871
3872        /// The static `Reflect.has()` method works like the in operator as a
3873        /// function.
3874        ///
3875        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/has)
3876        #[wasm_bindgen(js_namespace = Reflect, catch)]
3877        pub fn has(target: &JsValue, property_key: &JsValue) -> Result<bool, JsValue>;
3878
3879        /// The static `Reflect.isExtensible()` method determines if an object is
3880        /// extensible (whether it can have new properties added to it). It is
3881        /// similar to `Object.isExtensible()`, but with some differences.
3882        ///
3883        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/isExtensible)
3884        #[wasm_bindgen(js_namespace = Reflect, js_name = isExtensible, catch)]
3885        pub fn is_extensible(target: &Object) -> Result<bool, JsValue>;
3886
3887        /// The static `Reflect.ownKeys()` method returns an array of the
3888        /// target object's own property keys.
3889        ///
3890        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/ownKeys)
3891        #[wasm_bindgen(js_namespace = Reflect, js_name = ownKeys, catch)]
3892        pub fn own_keys(target: &JsValue) -> Result<Array, JsValue>;
3893
3894        /// The static `Reflect.preventExtensions()` method prevents new
3895        /// properties from ever being added to an object (i.e. prevents
3896        /// future extensions to the object). It is similar to
3897        /// `Object.preventExtensions()`, but with some differences.
3898        ///
3899        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/preventExtensions)
3900        #[wasm_bindgen(js_namespace = Reflect, js_name = preventExtensions, catch)]
3901        pub fn prevent_extensions(target: &Object) -> Result<bool, JsValue>;
3902
3903        /// The static `Reflect.set()` method works like setting a
3904        /// property on an object.
3905        ///
3906        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/set)
3907        #[wasm_bindgen(js_namespace = Reflect, catch)]
3908        pub fn set(
3909            target: &JsValue,
3910            property_key: &JsValue,
3911            value: &JsValue,
3912        ) -> Result<bool, JsValue>;
3913
3914        /// The same as [`set`](fn.set.html)
3915        /// except the key is an `f64`, which is slightly faster.
3916        #[wasm_bindgen(js_namespace = Reflect, js_name = "set", catch)]
3917        pub fn set_f64(
3918            target: &JsValue,
3919            property_key: f64,
3920            value: &JsValue,
3921        ) -> Result<bool, JsValue>;
3922
3923        /// The same as [`set`](fn.set.html)
3924        /// except the key is a `u32`, which is slightly faster.
3925        #[wasm_bindgen(js_namespace = Reflect, js_name = "set", catch)]
3926        pub fn set_u32(
3927            target: &JsValue,
3928            property_key: u32,
3929            value: &JsValue,
3930        ) -> Result<bool, JsValue>;
3931
3932        /// The static `Reflect.set()` method works like setting a
3933        /// property on an object.
3934        ///
3935        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/set)
3936        #[wasm_bindgen(js_namespace = Reflect, js_name = set, catch)]
3937        pub fn set_with_receiver(
3938            target: &JsValue,
3939            property_key: &JsValue,
3940            value: &JsValue,
3941            receiver: &JsValue,
3942        ) -> Result<bool, JsValue>;
3943
3944        /// The static `Reflect.setPrototypeOf()` method is the same
3945        /// method as `Object.setPrototypeOf()`. It sets the prototype
3946        /// (i.e., the internal `[[Prototype]]` property) of a specified
3947        /// object to another object or to null.
3948        ///
3949        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/setPrototypeOf)
3950        #[wasm_bindgen(js_namespace = Reflect, js_name = setPrototypeOf, catch)]
3951        pub fn set_prototype_of(target: &Object, prototype: &JsValue) -> Result<bool, JsValue>;
3952    }
3953}
3954
3955// RegExp
3956#[wasm_bindgen]
3957extern "C" {
3958    #[wasm_bindgen(extends = Object, typescript_type = "RegExp")]
3959    #[derive(Clone, Debug, PartialEq, Eq)]
3960    pub type RegExp;
3961
3962    /// The `exec()` method executes a search for a match in a specified
3963    /// string. Returns a result array, or null.
3964    ///
3965    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec)
3966    #[wasm_bindgen(method)]
3967    pub fn exec(this: &RegExp, text: &str) -> Option<Array>;
3968
3969    /// The flags property returns a string consisting of the flags of
3970    /// the current regular expression object.
3971    ///
3972    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/flags)
3973    #[wasm_bindgen(method, getter)]
3974    pub fn flags(this: &RegExp) -> JsString;
3975
3976    /// The global property indicates whether or not the "g" flag is
3977    /// used with the regular expression. global is a read-only
3978    /// property of an individual regular expression instance.
3979    ///
3980    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/global)
3981    #[wasm_bindgen(method, getter)]
3982    pub fn global(this: &RegExp) -> bool;
3983
3984    /// The ignoreCase property indicates whether or not the "i" flag
3985    /// is used with the regular expression. ignoreCase is a read-only
3986    /// property of an individual regular expression instance.
3987    ///
3988    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/ignoreCase)
3989    #[wasm_bindgen(method, getter, js_name = ignoreCase)]
3990    pub fn ignore_case(this: &RegExp) -> bool;
3991
3992    /// The non-standard input property is a static property of
3993    /// regular expressions that contains the string against which a
3994    /// regular expression is matched. RegExp.$_ is an alias for this
3995    /// property.
3996    ///
3997    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/input)
3998    #[wasm_bindgen(static_method_of = RegExp, getter)]
3999    pub fn input() -> JsString;
4000
4001    /// The lastIndex is a read/write integer property of regular expression
4002    /// instances that specifies the index at which to start the next match.
4003    ///
4004    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastIndex)
4005    #[wasm_bindgen(structural, getter = lastIndex, method)]
4006    pub fn last_index(this: &RegExp) -> u32;
4007
4008    /// The lastIndex is a read/write integer property of regular expression
4009    /// instances that specifies the index at which to start the next match.
4010    ///
4011    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastIndex)
4012    #[wasm_bindgen(structural, setter = lastIndex, method)]
4013    pub fn set_last_index(this: &RegExp, index: u32);
4014
4015    /// The non-standard lastMatch property is a static and read-only
4016    /// property of regular expressions that contains the last matched
4017    /// characters. `RegExp.$&` is an alias for this property.
4018    ///
4019    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastMatch)
4020    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = lastMatch)]
4021    pub fn last_match() -> JsString;
4022
4023    /// The non-standard lastParen property is a static and read-only
4024    /// property of regular expressions that contains the last
4025    /// parenthesized substring match, if any. `RegExp.$+` is an alias
4026    /// for this property.
4027    ///
4028    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastParen)
4029    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = lastParen)]
4030    pub fn last_paren() -> JsString;
4031
4032    /// The non-standard leftContext property is a static and
4033    /// read-only property of regular expressions that contains the
4034    /// substring preceding the most recent match. `RegExp.$`` is an
4035    /// alias for this property.
4036    ///
4037    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/leftContext)
4038    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = leftContext)]
4039    pub fn left_context() -> JsString;
4040
4041    /// The multiline property indicates whether or not the "m" flag
4042    /// is used with the regular expression. multiline is a read-only
4043    /// property of an individual regular expression instance.
4044    ///
4045    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/multiline)
4046    #[wasm_bindgen(method, getter)]
4047    pub fn multiline(this: &RegExp) -> bool;
4048
4049    /// The non-standard $1, $2, $3, $4, $5, $6, $7, $8, $9 properties
4050    /// are static and read-only properties of regular expressions
4051    /// that contain parenthesized substring matches.
4052    ///
4053    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/n)
4054    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$1")]
4055    pub fn n1() -> JsString;
4056    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$2")]
4057    pub fn n2() -> JsString;
4058    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$3")]
4059    pub fn n3() -> JsString;
4060    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$4")]
4061    pub fn n4() -> JsString;
4062    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$5")]
4063    pub fn n5() -> JsString;
4064    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$6")]
4065    pub fn n6() -> JsString;
4066    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$7")]
4067    pub fn n7() -> JsString;
4068    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$8")]
4069    pub fn n8() -> JsString;
4070    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$9")]
4071    pub fn n9() -> JsString;
4072
4073    /// The `RegExp` constructor creates a regular expression object for matching text with a pattern.
4074    ///
4075    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp)
4076    #[wasm_bindgen(constructor)]
4077    pub fn new(pattern: &str, flags: &str) -> RegExp;
4078    #[wasm_bindgen(constructor)]
4079    pub fn new_regexp(pattern: &RegExp, flags: &str) -> RegExp;
4080
4081    /// The non-standard rightContext property is a static and
4082    /// read-only property of regular expressions that contains the
4083    /// substring following the most recent match. `RegExp.$'` is an
4084    /// alias for this property.
4085    ///
4086    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/rightContext)
4087    #[wasm_bindgen(static_method_of = RegExp, getter, js_name = rightContext)]
4088    pub fn right_context() -> JsString;
4089
4090    /// The source property returns a String containing the source
4091    /// text of the regexp object, and it doesn't contain the two
4092    /// forward slashes on both sides and any flags.
4093    ///
4094    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/source)
4095    #[wasm_bindgen(method, getter)]
4096    pub fn source(this: &RegExp) -> JsString;
4097
4098    /// The sticky property reflects whether or not the search is
4099    /// sticky (searches in strings only from the index indicated by
4100    /// the lastIndex property of this regular expression). sticky is
4101    /// a read-only property of an individual regular expression
4102    /// object.
4103    ///
4104    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/sticky)
4105    #[wasm_bindgen(method, getter)]
4106    pub fn sticky(this: &RegExp) -> bool;
4107
4108    /// The `test()` method executes a search for a match between a
4109    /// regular expression and a specified string. Returns true or
4110    /// false.
4111    ///
4112    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test)
4113    #[wasm_bindgen(method)]
4114    pub fn test(this: &RegExp, text: &str) -> bool;
4115
4116    /// The `toString()` method returns a string representing the
4117    /// regular expression.
4118    ///
4119    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/toString)
4120    #[wasm_bindgen(method, js_name = toString)]
4121    pub fn to_string(this: &RegExp) -> JsString;
4122
4123    /// The unicode property indicates whether or not the "u" flag is
4124    /// used with a regular expression. unicode is a read-only
4125    /// property of an individual regular expression instance.
4126    ///
4127    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/unicode)
4128    #[wasm_bindgen(method, getter)]
4129    pub fn unicode(this: &RegExp) -> bool;
4130}
4131
4132// Set
4133#[wasm_bindgen]
4134extern "C" {
4135    #[wasm_bindgen(extends = Object, typescript_type = "Set<any>")]
4136    #[derive(Clone, Debug, PartialEq, Eq)]
4137    pub type Set;
4138
4139    /// The `add()` method appends a new element with a specified value to the
4140    /// end of a [`Set`] object.
4141    ///
4142    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/add)
4143    #[wasm_bindgen(method)]
4144    pub fn add(this: &Set, value: &JsValue) -> Set;
4145
4146    /// The `clear()` method removes all elements from a [`Set`] object.
4147    ///
4148    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/clear)
4149    #[wasm_bindgen(method)]
4150    pub fn clear(this: &Set);
4151
4152    /// The `delete()` method removes the specified element from a [`Set`]
4153    /// object.
4154    ///
4155    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/delete)
4156    #[wasm_bindgen(method)]
4157    pub fn delete(this: &Set, value: &JsValue) -> bool;
4158
4159    /// The `forEach()` method executes a provided function once for each value
4160    /// in the Set object, in insertion order.
4161    ///
4162    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/forEach)
4163    #[wasm_bindgen(method, js_name = forEach)]
4164    pub fn for_each(this: &Set, callback: &mut dyn FnMut(JsValue, JsValue, Set));
4165
4166    /// The `has()` method returns a boolean indicating whether an element with
4167    /// the specified value exists in a [`Set`] object or not.
4168    ///
4169    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/has)
4170    #[wasm_bindgen(method)]
4171    pub fn has(this: &Set, value: &JsValue) -> bool;
4172
4173    /// The [`Set`] object lets you store unique values of any type, whether
4174    /// primitive values or object references.
4175    ///
4176    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set)
4177    #[wasm_bindgen(constructor)]
4178    pub fn new(init: &JsValue) -> Set;
4179
4180    /// The size accessor property returns the number of elements in a [`Set`]
4181    /// object.
4182    ///
4183    /// [MDN documentation](https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Set/size)
4184    #[wasm_bindgen(method, getter, structural)]
4185    pub fn size(this: &Set) -> u32;
4186}
4187
4188impl Default for Set {
4189    fn default() -> Self {
4190        Self::new(&JsValue::UNDEFINED)
4191    }
4192}
4193
4194// SetIterator
4195#[wasm_bindgen]
4196extern "C" {
4197    /// The `entries()` method returns a new Iterator object that contains an
4198    /// array of [value, value] for each element in the Set object, in insertion
4199    /// order. For Set objects there is no key like in Map objects. However, to
4200    /// keep the API similar to the Map object, each entry has the same value
4201    /// for its key and value here, so that an array [value, value] is returned.
4202    ///
4203    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/entries)
4204    #[wasm_bindgen(method)]
4205    pub fn entries(set: &Set) -> Iterator;
4206
4207    /// The `keys()` method is an alias for this method (for similarity with
4208    /// Map objects); it behaves exactly the same and returns values
4209    /// of Set elements.
4210    ///
4211    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/values)
4212    #[wasm_bindgen(method)]
4213    pub fn keys(set: &Set) -> Iterator;
4214
4215    /// The `values()` method returns a new Iterator object that contains the
4216    /// values for each element in the Set object in insertion order.
4217    ///
4218    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/values)
4219    #[wasm_bindgen(method)]
4220    pub fn values(set: &Set) -> Iterator;
4221}
4222
4223// SyntaxError
4224#[wasm_bindgen]
4225extern "C" {
4226    /// A `SyntaxError` is thrown when the JavaScript engine encounters tokens or
4227    /// token order that does not conform to the syntax of the language when
4228    /// parsing code.
4229    ///
4230    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError)
4231    #[wasm_bindgen(extends = Error, extends = Object, typescript_type = "SyntaxError")]
4232    #[derive(Clone, Debug, PartialEq, Eq)]
4233    pub type SyntaxError;
4234
4235    /// A `SyntaxError` is thrown when the JavaScript engine encounters tokens or
4236    /// token order that does not conform to the syntax of the language when
4237    /// parsing code.
4238    ///
4239    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError)
4240    #[wasm_bindgen(constructor)]
4241    pub fn new(message: &str) -> SyntaxError;
4242}
4243
4244// TypeError
4245#[wasm_bindgen]
4246extern "C" {
4247    /// The `TypeError` object represents an error when a value is not of the
4248    /// expected type.
4249    ///
4250    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError)
4251    #[wasm_bindgen(extends = Error, extends = Object, typescript_type = "TypeError")]
4252    #[derive(Clone, Debug, PartialEq, Eq)]
4253    pub type TypeError;
4254
4255    /// The `TypeError` object represents an error when a value is not of the
4256    /// expected type.
4257    ///
4258    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError)
4259    #[wasm_bindgen(constructor)]
4260    pub fn new(message: &str) -> TypeError;
4261}
4262
4263// URIError
4264#[wasm_bindgen]
4265extern "C" {
4266    /// The `URIError` object represents an error when a global URI handling
4267    /// function was used in a wrong way.
4268    ///
4269    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError)
4270    #[wasm_bindgen(extends = Error, extends = Object, js_name = URIError, typescript_type = "URIError")]
4271    #[derive(Clone, Debug, PartialEq, Eq)]
4272    pub type UriError;
4273
4274    /// The `URIError` object represents an error when a global URI handling
4275    /// function was used in a wrong way.
4276    ///
4277    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError)
4278    #[wasm_bindgen(constructor, js_class = "URIError")]
4279    pub fn new(message: &str) -> UriError;
4280}
4281
4282// WeakMap
4283#[wasm_bindgen]
4284extern "C" {
4285    #[wasm_bindgen(extends = Object, typescript_type = "WeakMap<object, any>")]
4286    #[derive(Clone, Debug, PartialEq, Eq)]
4287    pub type WeakMap;
4288
4289    /// The [`WeakMap`] object is a collection of key/value pairs in which the
4290    /// keys are weakly referenced.  The keys must be objects and the values can
4291    /// be arbitrary values.
4292    ///
4293    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap)
4294    #[wasm_bindgen(constructor)]
4295    pub fn new() -> WeakMap;
4296
4297    /// The `set()` method sets the value for the key in the [`WeakMap`] object.
4298    /// Returns the [`WeakMap`] object.
4299    ///
4300    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/set)
4301    #[wasm_bindgen(method, js_class = "WeakMap")]
4302    pub fn set(this: &WeakMap, key: &Object, value: &JsValue) -> WeakMap;
4303
4304    /// The `get()` method returns a specified by key element
4305    /// from a [`WeakMap`] object.
4306    ///
4307    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/get)
4308    #[wasm_bindgen(method)]
4309    pub fn get(this: &WeakMap, key: &Object) -> JsValue;
4310
4311    /// The `has()` method returns a boolean indicating whether an element with
4312    /// the specified key exists in the [`WeakMap`] object or not.
4313    ///
4314    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/has)
4315    #[wasm_bindgen(method)]
4316    pub fn has(this: &WeakMap, key: &Object) -> bool;
4317
4318    /// The `delete()` method removes the specified element from a [`WeakMap`]
4319    /// object.
4320    ///
4321    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/delete)
4322    #[wasm_bindgen(method)]
4323    pub fn delete(this: &WeakMap, key: &Object) -> bool;
4324}
4325
4326impl Default for WeakMap {
4327    fn default() -> Self {
4328        Self::new()
4329    }
4330}
4331
4332// WeakSet
4333#[wasm_bindgen]
4334extern "C" {
4335    #[wasm_bindgen(extends = Object, typescript_type = "WeakSet<object>")]
4336    #[derive(Clone, Debug, PartialEq, Eq)]
4337    pub type WeakSet;
4338
4339    /// The `WeakSet` object lets you store weakly held objects in a collection.
4340    ///
4341    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet)
4342    #[wasm_bindgen(constructor)]
4343    pub fn new() -> WeakSet;
4344
4345    /// The `has()` method returns a boolean indicating whether an object exists
4346    /// in a WeakSet or not.
4347    ///
4348    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet/has)
4349    #[wasm_bindgen(method)]
4350    pub fn has(this: &WeakSet, value: &Object) -> bool;
4351
4352    /// The `add()` method appends a new object to the end of a WeakSet object.
4353    ///
4354    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet/add)
4355    #[wasm_bindgen(method)]
4356    pub fn add(this: &WeakSet, value: &Object) -> WeakSet;
4357
4358    /// The `delete()` method removes the specified element from a WeakSet
4359    /// object.
4360    ///
4361    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet/delete)
4362    #[wasm_bindgen(method)]
4363    pub fn delete(this: &WeakSet, value: &Object) -> bool;
4364}
4365
4366impl Default for WeakSet {
4367    fn default() -> Self {
4368        Self::new()
4369    }
4370}
4371
4372#[cfg(js_sys_unstable_apis)]
4373#[allow(non_snake_case)]
4374pub mod Temporal;
4375
4376#[allow(non_snake_case)]
4377pub mod WebAssembly {
4378    use super::*;
4379
4380    // WebAssembly
4381    #[wasm_bindgen]
4382    extern "C" {
4383        /// The `WebAssembly.compile()` function compiles a `WebAssembly.Module`
4384        /// from WebAssembly binary code.  This function is useful if it is
4385        /// necessary to a compile a module before it can be instantiated
4386        /// (otherwise, the `WebAssembly.instantiate()` function should be used).
4387        ///
4388        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/compile)
4389        #[wasm_bindgen(js_namespace = WebAssembly)]
4390        pub fn compile(buffer_source: &JsValue) -> Promise;
4391
4392        /// The `WebAssembly.compileStreaming()` function compiles a
4393        /// `WebAssembly.Module` module directly from a streamed underlying
4394        /// source. This function is useful if it is necessary to a compile a
4395        /// module before it can be instantiated (otherwise, the
4396        /// `WebAssembly.instantiateStreaming()` function should be used).
4397        ///
4398        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/compileStreaming)
4399        #[wasm_bindgen(js_namespace = WebAssembly, js_name = compileStreaming)]
4400        pub fn compile_streaming(response: &Promise) -> Promise;
4401
4402        /// The `WebAssembly.instantiate()` function allows you to compile and
4403        /// instantiate WebAssembly code.
4404        ///
4405        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiate)
4406        #[wasm_bindgen(js_namespace = WebAssembly, js_name = instantiate)]
4407        pub fn instantiate_buffer(buffer: &[u8], imports: &Object) -> Promise;
4408
4409        /// The `WebAssembly.instantiate()` function allows you to compile and
4410        /// instantiate WebAssembly code.
4411        ///
4412        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiate)
4413        #[wasm_bindgen(js_namespace = WebAssembly, js_name = instantiate)]
4414        pub fn instantiate_module(module: &Module, imports: &Object) -> Promise;
4415
4416        /// The `WebAssembly.instantiateStreaming()` function compiles and
4417        /// instantiates a WebAssembly module directly from a streamed
4418        /// underlying source. This is the most efficient, optimized way to load
4419        /// Wasm code.
4420        ///
4421        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiateStreaming)
4422        #[wasm_bindgen(js_namespace = WebAssembly, js_name = instantiateStreaming)]
4423        pub fn instantiate_streaming(response: &Promise, imports: &Object) -> Promise;
4424
4425        /// The `WebAssembly.validate()` function validates a given typed
4426        /// array of WebAssembly binary code, returning whether the bytes
4427        /// form a valid Wasm module (`true`) or not (`false`).
4428        ///
4429        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/validate)
4430        #[wasm_bindgen(js_namespace = WebAssembly, catch)]
4431        pub fn validate(buffer_source: &JsValue) -> Result<bool, JsValue>;
4432    }
4433
4434    // WebAssembly.CompileError
4435    #[wasm_bindgen]
4436    extern "C" {
4437        /// The `WebAssembly.CompileError()` constructor creates a new
4438        /// WebAssembly `CompileError` object, which indicates an error during
4439        /// WebAssembly decoding or validation.
4440        ///
4441        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/CompileError)
4442        #[wasm_bindgen(extends = Error, js_namespace = WebAssembly, typescript_type = "WebAssembly.CompileError")]
4443        #[derive(Clone, Debug, PartialEq, Eq)]
4444        pub type CompileError;
4445
4446        /// The `WebAssembly.CompileError()` constructor creates a new
4447        /// WebAssembly `CompileError` object, which indicates an error during
4448        /// WebAssembly decoding or validation.
4449        ///
4450        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/CompileError)
4451        #[wasm_bindgen(constructor, js_namespace = WebAssembly)]
4452        pub fn new(message: &str) -> CompileError;
4453    }
4454
4455    // WebAssembly.Instance
4456    #[wasm_bindgen]
4457    extern "C" {
4458        /// A `WebAssembly.Instance` object is a stateful, executable instance
4459        /// of a `WebAssembly.Module`. Instance objects contain all the exported
4460        /// WebAssembly functions that allow calling into WebAssembly code from
4461        /// JavaScript.
4462        ///
4463        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance)
4464        #[wasm_bindgen(extends = Object, js_namespace = WebAssembly, typescript_type = "WebAssembly.Instance")]
4465        #[derive(Clone, Debug, PartialEq, Eq)]
4466        pub type Instance;
4467
4468        /// The `WebAssembly.Instance()` constructor function can be called to
4469        /// synchronously instantiate a given `WebAssembly.Module`
4470        /// object. However, the primary way to get an `Instance` is through the
4471        /// asynchronous `WebAssembly.instantiateStreaming()` function.
4472        ///
4473        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance)
4474        #[wasm_bindgen(catch, constructor, js_namespace = WebAssembly)]
4475        pub fn new(module: &Module, imports: &Object) -> Result<Instance, JsValue>;
4476
4477        /// The `exports` readonly property of the `WebAssembly.Instance` object
4478        /// prototype returns an object containing as its members all the
4479        /// functions exported from the WebAssembly module instance, to allow
4480        /// them to be accessed and used by JavaScript.
4481        ///
4482        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance/exports)
4483        #[wasm_bindgen(getter, method, js_namespace = WebAssembly)]
4484        pub fn exports(this: &Instance) -> Object;
4485    }
4486
4487    // WebAssembly.LinkError
4488    #[wasm_bindgen]
4489    extern "C" {
4490        /// The `WebAssembly.LinkError()` constructor creates a new WebAssembly
4491        /// LinkError object, which indicates an error during module
4492        /// instantiation (besides traps from the start function).
4493        ///
4494        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/LinkError)
4495        #[wasm_bindgen(extends = Error, js_namespace = WebAssembly, typescript_type = "WebAssembly.LinkError")]
4496        #[derive(Clone, Debug, PartialEq, Eq)]
4497        pub type LinkError;
4498
4499        /// The `WebAssembly.LinkError()` constructor creates a new WebAssembly
4500        /// LinkError object, which indicates an error during module
4501        /// instantiation (besides traps from the start function).
4502        ///
4503        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/LinkError)
4504        #[wasm_bindgen(constructor, js_namespace = WebAssembly)]
4505        pub fn new(message: &str) -> LinkError;
4506    }
4507
4508    // WebAssembly.RuntimeError
4509    #[wasm_bindgen]
4510    extern "C" {
4511        /// The `WebAssembly.RuntimeError()` constructor creates a new WebAssembly
4512        /// `RuntimeError` object — the type that is thrown whenever WebAssembly
4513        /// specifies a trap.
4514        ///
4515        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/RuntimeError)
4516        #[wasm_bindgen(extends = Error, js_namespace = WebAssembly, typescript_type = "WebAssembly.RuntimeError")]
4517        #[derive(Clone, Debug, PartialEq, Eq)]
4518        pub type RuntimeError;
4519
4520        /// The `WebAssembly.RuntimeError()` constructor creates a new WebAssembly
4521        /// `RuntimeError` object — the type that is thrown whenever WebAssembly
4522        /// specifies a trap.
4523        ///
4524        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/RuntimeError)
4525        #[wasm_bindgen(constructor, js_namespace = WebAssembly)]
4526        pub fn new(message: &str) -> RuntimeError;
4527    }
4528
4529    // WebAssembly.Module
4530    #[wasm_bindgen]
4531    extern "C" {
4532        /// A `WebAssembly.Module` object contains stateless WebAssembly code
4533        /// that has already been compiled by the browser and can be
4534        /// efficiently shared with Workers, and instantiated multiple times.
4535        ///
4536        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module)
4537        #[wasm_bindgen(js_namespace = WebAssembly, extends = Object, typescript_type = "WebAssembly.Module")]
4538        #[derive(Clone, Debug, PartialEq, Eq)]
4539        pub type Module;
4540
4541        /// A `WebAssembly.Module` object contains stateless WebAssembly code
4542        /// that has already been compiled by the browser and can be
4543        /// efficiently shared with Workers, and instantiated multiple times.
4544        ///
4545        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module)
4546        #[wasm_bindgen(constructor, js_namespace = WebAssembly, catch)]
4547        pub fn new(buffer_source: &JsValue) -> Result<Module, JsValue>;
4548
4549        /// The `WebAssembly.customSections()` function returns a copy of the
4550        /// contents of all custom sections in the given module with the given
4551        /// string name.
4552        ///
4553        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module/customSections)
4554        #[wasm_bindgen(static_method_of = Module, js_namespace = WebAssembly, js_name = customSections)]
4555        pub fn custom_sections(module: &Module, sectionName: &str) -> Array;
4556
4557        /// The `WebAssembly.exports()` function returns an array containing
4558        /// descriptions of all the declared exports of the given `Module`.
4559        ///
4560        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module/exports)
4561        #[wasm_bindgen(static_method_of = Module, js_namespace = WebAssembly)]
4562        pub fn exports(module: &Module) -> Array;
4563
4564        /// The `WebAssembly.imports()` function returns an array containing
4565        /// descriptions of all the declared imports of the given `Module`.
4566        ///
4567        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module/imports)
4568        #[wasm_bindgen(static_method_of = Module, js_namespace = WebAssembly)]
4569        pub fn imports(module: &Module) -> Array;
4570    }
4571
4572    // WebAssembly.Table
4573    #[wasm_bindgen]
4574    extern "C" {
4575        /// The `WebAssembly.Table()` constructor creates a new `Table` object
4576        /// of the given size and element type.
4577        ///
4578        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table)
4579        #[wasm_bindgen(js_namespace = WebAssembly, extends = Object, typescript_type = "WebAssembly.Table")]
4580        #[derive(Clone, Debug, PartialEq, Eq)]
4581        pub type Table;
4582
4583        /// The `WebAssembly.Table()` constructor creates a new `Table` object
4584        /// of the given size and element type.
4585        ///
4586        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table)
4587        #[wasm_bindgen(constructor, js_namespace = WebAssembly, catch)]
4588        pub fn new(table_descriptor: &Object) -> Result<Table, JsValue>;
4589
4590        /// The length prototype property of the `WebAssembly.Table` object
4591        /// returns the length of the table, i.e. the number of elements in the
4592        /// table.
4593        ///
4594        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/length)
4595        #[wasm_bindgen(method, getter, js_namespace = WebAssembly)]
4596        pub fn length(this: &Table) -> u32;
4597
4598        /// The `get()` prototype method of the `WebAssembly.Table()` object
4599        /// retrieves a function reference stored at a given index.
4600        ///
4601        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/get)
4602        #[wasm_bindgen(method, catch, js_namespace = WebAssembly)]
4603        pub fn get(this: &Table, index: u32) -> Result<Function, JsValue>;
4604
4605        /// The `grow()` prototype method of the `WebAssembly.Table` object
4606        /// increases the size of the `Table` instance by a specified number of
4607        /// elements.
4608        ///
4609        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/grow)
4610        #[wasm_bindgen(method, catch, js_namespace = WebAssembly)]
4611        pub fn grow(this: &Table, additional_capacity: u32) -> Result<u32, JsValue>;
4612
4613        /// The `set()` prototype method of the `WebAssembly.Table` object mutates a
4614        /// reference stored at a given index to a different value.
4615        ///
4616        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/set)
4617        #[wasm_bindgen(method, catch, js_namespace = WebAssembly)]
4618        pub fn set(this: &Table, index: u32, function: &Function) -> Result<(), JsValue>;
4619    }
4620
4621    // WebAssembly.Tag
4622    #[wasm_bindgen]
4623    extern "C" {
4624        /// The `WebAssembly.Tag()` constructor creates a new `Tag` object
4625        ///
4626        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Tag)
4627        #[wasm_bindgen(js_namespace = WebAssembly, extends = Object, typescript_type = "WebAssembly.Tag")]
4628        #[derive(Clone, Debug, PartialEq, Eq)]
4629        pub type Tag;
4630
4631        /// The `WebAssembly.Tag()` constructor creates a new `Tag` object
4632        ///
4633        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Tag)
4634        #[wasm_bindgen(constructor, js_namespace = WebAssembly, catch)]
4635        pub fn new(tag_descriptor: &Object) -> Result<Tag, JsValue>;
4636    }
4637
4638    // WebAssembly.Exception
4639    #[wasm_bindgen]
4640    extern "C" {
4641        /// The `WebAssembly.Exception()` constructor creates a new `Exception` object
4642        ///
4643        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Exception)
4644        #[wasm_bindgen(js_namespace = WebAssembly, extends = Object, typescript_type = "WebAssembly.Exception")]
4645        #[derive(Clone, Debug, PartialEq, Eq)]
4646        pub type Exception;
4647
4648        /// The `WebAssembly.Exception()` constructor creates a new `Exception` object
4649        ///
4650        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Exception)
4651        #[wasm_bindgen(constructor, js_namespace = WebAssembly, catch)]
4652        pub fn new(tag: &Tag, payload: &Array) -> Result<Exception, JsValue>;
4653
4654        /// The `WebAssembly.Exception()` constructor creates a new `Exception` object
4655        ///
4656        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Exception)
4657        #[wasm_bindgen(constructor, js_namespace = WebAssembly, catch)]
4658        pub fn new_with_options(
4659            tag: &Tag,
4660            payload: &Array,
4661            options: &Object,
4662        ) -> Result<Exception, JsValue>;
4663
4664        /// The `is()` prototype method of the `WebAssembly.Exception` can be used to
4665        /// test if the Exception matches a given tag.
4666        ///
4667        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Exception/is)
4668        #[wasm_bindgen(method, js_namespace = WebAssembly)]
4669        pub fn is(this: &Exception, tag: &Tag) -> bool;
4670
4671        /// The `getArg()` prototype method of the `WebAssembly.Exception` can be used
4672        /// to get the value of a specified item in the exception's data arguments
4673        ///
4674        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Exception/getArg)
4675        #[wasm_bindgen(method, js_namespace = WebAssembly, js_name = getArg, catch)]
4676        pub fn get_arg(this: &Exception, tag: &Tag, index: u32) -> Result<JsValue, JsValue>;
4677    }
4678
4679    // WebAssembly.Global
4680    #[wasm_bindgen]
4681    extern "C" {
4682        /// The `WebAssembly.Global()` constructor creates a new `Global` object
4683        /// of the given type and value.
4684        ///
4685        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Global)
4686        #[wasm_bindgen(js_namespace = WebAssembly, extends = Object, typescript_type = "WebAssembly.Global")]
4687        #[derive(Clone, Debug, PartialEq, Eq)]
4688        pub type Global;
4689
4690        /// The `WebAssembly.Global()` constructor creates a new `Global` object
4691        /// of the given type and value.
4692        ///
4693        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Global)
4694        #[wasm_bindgen(constructor, js_namespace = WebAssembly, catch)]
4695        pub fn new(global_descriptor: &Object, value: &JsValue) -> Result<Global, JsValue>;
4696
4697        /// The value prototype property of the `WebAssembly.Global` object
4698        /// returns the value of the global.
4699        ///
4700        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Global)
4701        #[wasm_bindgen(method, getter, structural, js_namespace = WebAssembly)]
4702        pub fn value(this: &Global) -> JsValue;
4703        #[wasm_bindgen(method, setter = value, structural, js_namespace = WebAssembly)]
4704        pub fn set_value(this: &Global, value: &JsValue);
4705    }
4706
4707    // WebAssembly.Memory
4708    #[wasm_bindgen]
4709    extern "C" {
4710        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory)
4711        #[wasm_bindgen(js_namespace = WebAssembly, extends = Object, typescript_type = "WebAssembly.Memory")]
4712        #[derive(Clone, Debug, PartialEq, Eq)]
4713        pub type Memory;
4714
4715        /// The `WebAssembly.Memory()` constructor creates a new `Memory` object
4716        /// which is a resizable `ArrayBuffer` that holds the raw bytes of
4717        /// memory accessed by a WebAssembly `Instance`.
4718        ///
4719        /// A memory created by JavaScript or in WebAssembly code will be
4720        /// accessible and mutable from both JavaScript and WebAssembly.
4721        ///
4722        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory)
4723        #[wasm_bindgen(constructor, js_namespace = WebAssembly, catch)]
4724        pub fn new(descriptor: &Object) -> Result<Memory, JsValue>;
4725
4726        /// An accessor property that returns the buffer contained in the
4727        /// memory.
4728        ///
4729        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory/buffer)
4730        #[wasm_bindgen(method, getter, js_namespace = WebAssembly)]
4731        pub fn buffer(this: &Memory) -> JsValue;
4732
4733        /// The `grow()` prototype method of the `Memory` object increases the
4734        /// size of the memory instance by a specified number of WebAssembly
4735        /// pages.
4736        ///
4737        /// Takes the number of pages to grow (64KiB in size) and returns the
4738        /// previous size of memory, in pages.
4739        ///
4740        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory/grow)
4741        #[wasm_bindgen(method, js_namespace = WebAssembly)]
4742        pub fn grow(this: &Memory, pages: u32) -> u32;
4743    }
4744}
4745
4746/// The `JSON` object contains methods for parsing [JavaScript Object
4747/// Notation (JSON)](https://json.org/) and converting values to JSON. It
4748/// can't be called or constructed, and aside from its two method
4749/// properties, it has no interesting functionality of its own.
4750#[allow(non_snake_case)]
4751pub mod JSON {
4752    use super::*;
4753
4754    // JSON
4755    #[wasm_bindgen]
4756    extern "C" {
4757        /// The `JSON.parse()` method parses a JSON string, constructing the
4758        /// JavaScript value or object described by the string.
4759        ///
4760        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse)
4761        #[wasm_bindgen(catch, js_namespace = JSON)]
4762        pub fn parse(text: &str) -> Result<JsValue, JsValue>;
4763
4764        /// The `JSON.stringify()` method converts a JavaScript value to a JSON string.
4765        ///
4766        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)
4767        #[wasm_bindgen(catch, js_namespace = JSON)]
4768        pub fn stringify(obj: &JsValue) -> Result<JsString, JsValue>;
4769
4770        /// The `JSON.stringify()` method converts a JavaScript value to a JSON string.
4771        ///
4772        /// The `replacer` argument is a function that alters the behavior of the stringification
4773        /// process, or an array of String and Number objects that serve as a whitelist
4774        /// for selecting/filtering the properties of the value object to be included
4775        /// in the JSON string. If this value is null or not provided, all properties
4776        /// of the object are included in the resulting JSON string.
4777        ///
4778        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)
4779        #[wasm_bindgen(catch, js_namespace = JSON, js_name = stringify)]
4780        pub fn stringify_with_replacer(
4781            obj: &JsValue,
4782            replacer: &JsValue,
4783        ) -> Result<JsString, JsValue>;
4784
4785        /// The `JSON.stringify()` method converts a JavaScript value to a JSON string.
4786        ///
4787        /// The `replacer` argument is a function that alters the behavior of the stringification
4788        /// process, or an array of String and Number objects that serve as a whitelist
4789        /// for selecting/filtering the properties of the value object to be included
4790        /// in the JSON string. If this value is null or not provided, all properties
4791        /// of the object are included in the resulting JSON string.
4792        ///
4793        /// The `space` argument is a String or Number object that's used to insert white space into
4794        /// the output JSON string for readability purposes. If this is a Number, it
4795        /// indicates the number of space characters to use as white space; this number
4796        /// is capped at 10 (if it is greater, the value is just 10). Values less than
4797        /// 1 indicate that no space should be used. If this is a String, the string
4798        /// (or the first 10 characters of the string, if it's longer than that) is
4799        /// used as white space. If this parameter is not provided (or is null), no
4800        /// white space is used.
4801        ///
4802        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)
4803        #[wasm_bindgen(catch, js_namespace = JSON, js_name = stringify)]
4804        pub fn stringify_with_replacer_and_space(
4805            obj: &JsValue,
4806            replacer: &JsValue,
4807            space: &JsValue,
4808        ) -> Result<JsString, JsValue>;
4809
4810    }
4811}
4812
4813// JsString
4814#[wasm_bindgen]
4815extern "C" {
4816    #[wasm_bindgen(js_name = String, extends = Object, is_type_of = JsValue::is_string, typescript_type = "string")]
4817    #[derive(Clone, PartialEq, Eq)]
4818    pub type JsString;
4819
4820    /// The length property of a String object indicates the length of a string,
4821    /// in UTF-16 code units.
4822    ///
4823    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length)
4824    #[wasm_bindgen(method, getter, structural)]
4825    pub fn length(this: &JsString) -> u32;
4826
4827    /// The 'at()' method returns a new string consisting of the single UTF-16
4828    /// code unit located at the specified offset into the string, counting from
4829    /// the end if it's negative.
4830    ///
4831    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/at)
4832    #[wasm_bindgen(method, js_class = "String")]
4833    pub fn at(this: &JsString, index: i32) -> Option<JsString>;
4834
4835    /// The String object's `charAt()` method returns a new string consisting of
4836    /// the single UTF-16 code unit located at the specified offset into the
4837    /// string.
4838    ///
4839    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charAt)
4840    #[wasm_bindgen(method, js_class = "String", js_name = charAt)]
4841    pub fn char_at(this: &JsString, index: u32) -> JsString;
4842
4843    /// The `charCodeAt()` method returns an integer between 0 and 65535
4844    /// representing the UTF-16 code unit at the given index (the UTF-16 code
4845    /// unit matches the Unicode code point for code points representable in a
4846    /// single UTF-16 code unit, but might also be the first code unit of a
4847    /// surrogate pair for code points not representable in a single UTF-16 code
4848    /// unit, e.g. Unicode code points > 0x10000).  If you want the entire code
4849    /// point value, use `codePointAt()`.
4850    ///
4851    /// Returns `NaN` if index is out of range.
4852    ///
4853    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charCodeAt)
4854    #[wasm_bindgen(method, js_class = "String", js_name = charCodeAt)]
4855    pub fn char_code_at(this: &JsString, index: u32) -> f64;
4856
4857    /// The `codePointAt()` method returns a non-negative integer that is the
4858    /// Unicode code point value.
4859    ///
4860    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt)
4861    #[wasm_bindgen(method, js_class = "String", js_name = codePointAt)]
4862    pub fn code_point_at(this: &JsString, pos: u32) -> JsValue;
4863
4864    /// The `concat()` method concatenates the string arguments to the calling
4865    /// string and returns a new string.
4866    ///
4867    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/concat)
4868    #[wasm_bindgen(method, js_class = "String")]
4869    pub fn concat(this: &JsString, string_2: &JsValue) -> JsString;
4870
4871    /// The `endsWith()` method determines whether a string ends with the characters of a
4872    /// specified string, returning true or false as appropriate.
4873    ///
4874    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith)
4875    #[wasm_bindgen(method, js_class = "String", js_name = endsWith)]
4876    pub fn ends_with(this: &JsString, search_string: &str, length: i32) -> bool;
4877
4878    /// The static `String.fromCharCode()` method returns a string created from
4879    /// the specified sequence of UTF-16 code units.
4880    ///
4881    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
4882    ///
4883    /// # Notes
4884    ///
4885    /// There are a few bindings to `from_char_code` in `js-sys`: `from_char_code1`, `from_char_code2`, etc...
4886    /// with different arities.
4887    ///
4888    /// Additionally, this function accepts `u16` for character codes, but
4889    /// fixing others requires a breaking change release
4890    /// (see https://github.com/rustwasm/wasm-bindgen/issues/1460 for details).
4891    #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode, variadic)]
4892    pub fn from_char_code(char_codes: &[u16]) -> JsString;
4893
4894    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
4895    #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)]
4896    pub fn from_char_code1(a: u32) -> JsString;
4897
4898    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
4899    #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)]
4900    pub fn from_char_code2(a: u32, b: u32) -> JsString;
4901
4902    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
4903    #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)]
4904    pub fn from_char_code3(a: u32, b: u32, c: u32) -> JsString;
4905
4906    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
4907    #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)]
4908    pub fn from_char_code4(a: u32, b: u32, c: u32, d: u32) -> JsString;
4909
4910    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
4911    #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)]
4912    pub fn from_char_code5(a: u32, b: u32, c: u32, d: u32, e: u32) -> JsString;
4913
4914    /// The static `String.fromCodePoint()` method returns a string created by
4915    /// using the specified sequence of code points.
4916    ///
4917    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)
4918    ///
4919    /// # Exceptions
4920    ///
4921    /// A RangeError is thrown if an invalid Unicode code point is given
4922    ///
4923    /// # Notes
4924    ///
4925    /// There are a few bindings to `from_code_point` in `js-sys`: `from_code_point1`, `from_code_point2`, etc...
4926    /// with different arities.
4927    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = fromCodePoint, variadic)]
4928    pub fn from_code_point(code_points: &[u32]) -> Result<JsString, JsValue>;
4929
4930    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)
4931    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = fromCodePoint)]
4932    pub fn from_code_point1(a: u32) -> Result<JsString, JsValue>;
4933
4934    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)
4935    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = fromCodePoint)]
4936    pub fn from_code_point2(a: u32, b: u32) -> Result<JsString, JsValue>;
4937
4938    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)
4939    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = fromCodePoint)]
4940    pub fn from_code_point3(a: u32, b: u32, c: u32) -> Result<JsString, JsValue>;
4941
4942    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)
4943    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = fromCodePoint)]
4944    pub fn from_code_point4(a: u32, b: u32, c: u32, d: u32) -> Result<JsString, JsValue>;
4945
4946    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)
4947    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = fromCodePoint)]
4948    pub fn from_code_point5(a: u32, b: u32, c: u32, d: u32, e: u32) -> Result<JsString, JsValue>;
4949
4950    /// The `includes()` method determines whether one string may be found
4951    /// within another string, returning true or false as appropriate.
4952    ///
4953    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes)
4954    #[wasm_bindgen(method, js_class = "String")]
4955    pub fn includes(this: &JsString, search_string: &str, position: i32) -> bool;
4956
4957    /// The `indexOf()` method returns the index within the calling String
4958    /// object of the first occurrence of the specified value, starting the
4959    /// search at fromIndex.  Returns -1 if the value is not found.
4960    ///
4961    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf)
4962    #[wasm_bindgen(method, js_class = "String", js_name = indexOf)]
4963    pub fn index_of(this: &JsString, search_value: &str, from_index: i32) -> i32;
4964
4965    /// The `lastIndexOf()` method returns the index within the calling String
4966    /// object of the last occurrence of the specified value, searching
4967    /// backwards from fromIndex.  Returns -1 if the value is not found.
4968    ///
4969    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/lastIndexOf)
4970    #[wasm_bindgen(method, js_class = "String", js_name = lastIndexOf)]
4971    pub fn last_index_of(this: &JsString, search_value: &str, from_index: i32) -> i32;
4972
4973    /// The `localeCompare()` method returns a number indicating whether
4974    /// a reference string comes before or after or is the same as
4975    /// the given string in sort order.
4976    ///
4977    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare)
4978    #[wasm_bindgen(method, js_class = "String", js_name = localeCompare)]
4979    pub fn locale_compare(
4980        this: &JsString,
4981        compare_string: &str,
4982        locales: &Array,
4983        options: &Object,
4984    ) -> i32;
4985
4986    /// The `match()` method retrieves the matches when matching a string against a regular expression.
4987    ///
4988    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match)
4989    #[wasm_bindgen(method, js_class = "String", js_name = match)]
4990    pub fn match_(this: &JsString, pattern: &RegExp) -> Option<Object>;
4991
4992    /// The `match_all()` method is similar to `match()`, but gives an iterator of `exec()` arrays, which preserve capture groups.
4993    ///
4994    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/matchAll)
4995    #[wasm_bindgen(method, js_class = "String", js_name = matchAll)]
4996    pub fn match_all(this: &JsString, pattern: &RegExp) -> Iterator;
4997
4998    /// The `normalize()` method returns the Unicode Normalization Form
4999    /// of a given string (if the value isn't a string, it will be converted to one first).
5000    ///
5001    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize)
5002    #[wasm_bindgen(method, js_class = "String")]
5003    pub fn normalize(this: &JsString, form: &str) -> JsString;
5004
5005    /// The `padEnd()` method pads the current string with a given string
5006    /// (repeated, if needed) so that the resulting string reaches a given
5007    /// length. The padding is applied from the end (right) of the current
5008    /// string.
5009    ///
5010    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padEnd)
5011    #[wasm_bindgen(method, js_class = "String", js_name = padEnd)]
5012    pub fn pad_end(this: &JsString, target_length: u32, pad_string: &str) -> JsString;
5013
5014    /// The `padStart()` method pads the current string with another string
5015    /// (repeated, if needed) so that the resulting string reaches the given
5016    /// length. The padding is applied from the start (left) of the current
5017    /// string.
5018    ///
5019    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padStart)
5020    #[wasm_bindgen(method, js_class = "String", js_name = padStart)]
5021    pub fn pad_start(this: &JsString, target_length: u32, pad_string: &str) -> JsString;
5022
5023    /// The `repeat()` method constructs and returns a new string which contains the specified
5024    /// number of copies of the string on which it was called, concatenated together.
5025    ///
5026    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat)
5027    #[wasm_bindgen(method, js_class = "String")]
5028    pub fn repeat(this: &JsString, count: i32) -> JsString;
5029
5030    /// The `replace()` method returns a new string with some or all matches of a pattern
5031    /// replaced by a replacement. The pattern can be a string or a RegExp, and
5032    /// the replacement can be a string or a function to be called for each match.
5033    ///
5034    /// Note: The original string will remain unchanged.
5035    ///
5036    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace)
5037    #[wasm_bindgen(method, js_class = "String")]
5038    pub fn replace(this: &JsString, pattern: &str, replacement: &str) -> JsString;
5039
5040    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace)
5041    #[wasm_bindgen(method, js_class = "String", js_name = replace)]
5042    pub fn replace_with_function(
5043        this: &JsString,
5044        pattern: &str,
5045        replacement: &Function,
5046    ) -> JsString;
5047
5048    #[wasm_bindgen(method, js_class = "String", js_name = replace)]
5049    pub fn replace_by_pattern(this: &JsString, pattern: &RegExp, replacement: &str) -> JsString;
5050
5051    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace)
5052    #[wasm_bindgen(method, js_class = "String", js_name = replace)]
5053    pub fn replace_by_pattern_with_function(
5054        this: &JsString,
5055        pattern: &RegExp,
5056        replacement: &Function,
5057    ) -> JsString;
5058
5059    /// The `replace_all()` method returns a new string with all matches of a pattern
5060    /// replaced by a replacement. The pattern can be a string or a global RegExp, and
5061    /// the replacement can be a string or a function to be called for each match.
5062    ///
5063    /// Note: The original string will remain unchanged.
5064    ///
5065    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replaceAll)
5066    #[wasm_bindgen(method, js_class = "String", js_name = replaceAll)]
5067    pub fn replace_all(this: &JsString, pattern: &str, replacement: &str) -> JsString;
5068
5069    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replaceAll)
5070    #[wasm_bindgen(method, js_class = "String", js_name = replaceAll)]
5071    pub fn replace_all_with_function(
5072        this: &JsString,
5073        pattern: &str,
5074        replacement: &Function,
5075    ) -> JsString;
5076
5077    #[wasm_bindgen(method, js_class = "String", js_name = replaceAll)]
5078    pub fn replace_all_by_pattern(this: &JsString, pattern: &RegExp, replacement: &str)
5079        -> JsString;
5080
5081    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replaceAll)
5082    #[wasm_bindgen(method, js_class = "String", js_name = replaceAll)]
5083    pub fn replace_all_by_pattern_with_function(
5084        this: &JsString,
5085        pattern: &RegExp,
5086        replacement: &Function,
5087    ) -> JsString;
5088
5089    /// The `search()` method executes a search for a match between
5090    /// a regular expression and this String object.
5091    ///
5092    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/search)
5093    #[wasm_bindgen(method, js_class = "String")]
5094    pub fn search(this: &JsString, pattern: &RegExp) -> i32;
5095
5096    /// The `slice()` method extracts a section of a string and returns it as a
5097    /// new string, without modifying the original string.
5098    ///
5099    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice)
5100    #[wasm_bindgen(method, js_class = "String")]
5101    pub fn slice(this: &JsString, start: u32, end: u32) -> JsString;
5102
5103    /// The `split()` method splits a String object into an array of strings by separating the string
5104    /// into substrings, using a specified separator string to determine where to make each split.
5105    ///
5106    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split)
5107    #[wasm_bindgen(method, js_class = "String")]
5108    pub fn split(this: &JsString, separator: &str) -> Array;
5109
5110    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split)
5111    #[wasm_bindgen(method, js_class = "String", js_name = split)]
5112    pub fn split_limit(this: &JsString, separator: &str, limit: u32) -> Array;
5113
5114    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split)
5115    #[wasm_bindgen(method, js_class = "String", js_name = split)]
5116    pub fn split_by_pattern(this: &JsString, pattern: &RegExp) -> Array;
5117
5118    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split)
5119    #[wasm_bindgen(method, js_class = "String", js_name = split)]
5120    pub fn split_by_pattern_limit(this: &JsString, pattern: &RegExp, limit: u32) -> Array;
5121
5122    /// The `startsWith()` method determines whether a string begins with the
5123    /// characters of a specified string, returning true or false as
5124    /// appropriate.
5125    ///
5126    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith)
5127    #[wasm_bindgen(method, js_class = "String", js_name = startsWith)]
5128    pub fn starts_with(this: &JsString, search_string: &str, position: u32) -> bool;
5129
5130    /// The `substring()` method returns the part of the string between the
5131    /// start and end indexes, or to the end of the string.
5132    ///
5133    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring)
5134    #[wasm_bindgen(method, js_class = "String")]
5135    pub fn substring(this: &JsString, index_start: u32, index_end: u32) -> JsString;
5136
5137    /// The `substr()` method returns the part of a string between
5138    /// the start index and a number of characters after it.
5139    ///
5140    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr)
5141    #[wasm_bindgen(method, js_class = "String")]
5142    pub fn substr(this: &JsString, start: i32, length: i32) -> JsString;
5143
5144    /// The `toLocaleLowerCase()` method returns the calling string value converted to lower case,
5145    /// according to any locale-specific case mappings.
5146    ///
5147    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase)
5148    #[wasm_bindgen(method, js_class = "String", js_name = toLocaleLowerCase)]
5149    pub fn to_locale_lower_case(this: &JsString, locale: Option<&str>) -> JsString;
5150
5151    /// The `toLocaleUpperCase()` method returns the calling string value converted to upper case,
5152    /// according to any locale-specific case mappings.
5153    ///
5154    /// [MDN documentation](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleUpperCase)
5155    #[wasm_bindgen(method, js_class = "String", js_name = toLocaleUpperCase)]
5156    pub fn to_locale_upper_case(this: &JsString, locale: Option<&str>) -> JsString;
5157
5158    /// The `toLowerCase()` method returns the calling string value
5159    /// converted to lower case.
5160    ///
5161    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLowerCase)
5162    #[wasm_bindgen(method, js_class = "String", js_name = toLowerCase)]
5163    pub fn to_lower_case(this: &JsString) -> JsString;
5164
5165    /// The `toString()` method returns a string representing the specified
5166    /// object.
5167    ///
5168    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toString)
5169    #[wasm_bindgen(method, js_class = "String", js_name = toString)]
5170    pub fn to_string(this: &JsString) -> JsString;
5171
5172    /// The `toUpperCase()` method returns the calling string value converted to
5173    /// uppercase (the value will be converted to a string if it isn't one).
5174    ///
5175    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase)
5176    #[wasm_bindgen(method, js_class = "String", js_name = toUpperCase)]
5177    pub fn to_upper_case(this: &JsString) -> JsString;
5178
5179    /// The `trim()` method removes whitespace from both ends of a string.
5180    /// Whitespace in this context is all the whitespace characters (space, tab,
5181    /// no-break space, etc.) and all the line terminator characters (LF, CR,
5182    /// etc.).
5183    ///
5184    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trim)
5185    #[wasm_bindgen(method, js_class = "String")]
5186    pub fn trim(this: &JsString) -> JsString;
5187
5188    /// The `trimEnd()` method removes whitespace from the end of a string.
5189    /// `trimRight()` is an alias of this method.
5190    ///
5191    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimEnd)
5192    #[wasm_bindgen(method, js_class = "String", js_name = trimEnd)]
5193    pub fn trim_end(this: &JsString) -> JsString;
5194
5195    /// The `trimEnd()` method removes whitespace from the end of a string.
5196    /// `trimRight()` is an alias of this method.
5197    ///
5198    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimEnd)
5199    #[wasm_bindgen(method, js_class = "String", js_name = trimRight)]
5200    pub fn trim_right(this: &JsString) -> JsString;
5201
5202    /// The `trimStart()` method removes whitespace from the beginning of a
5203    /// string. `trimLeft()` is an alias of this method.
5204    ///
5205    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimStart)
5206    #[wasm_bindgen(method, js_class = "String", js_name = trimStart)]
5207    pub fn trim_start(this: &JsString) -> JsString;
5208
5209    /// The `trimStart()` method removes whitespace from the beginning of a
5210    /// string. `trimLeft()` is an alias of this method.
5211    ///
5212    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimStart)
5213    #[wasm_bindgen(method, js_class = "String", js_name = trimLeft)]
5214    pub fn trim_left(this: &JsString) -> JsString;
5215
5216    /// The `valueOf()` method returns the primitive value of a `String` object.
5217    ///
5218    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/valueOf)
5219    #[wasm_bindgen(method, js_class = "String", js_name = valueOf)]
5220    pub fn value_of(this: &JsString) -> JsString;
5221
5222    /// The static `raw()` method is a tag function of template literals,
5223    /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
5224    ///
5225    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
5226    #[wasm_bindgen(catch, variadic, static_method_of = JsString, js_class = "String")]
5227    pub fn raw(call_site: &Object, substitutions: &Array) -> Result<JsString, JsValue>;
5228
5229    /// The static `raw()` method is a tag function of template literals,
5230    /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
5231    ///
5232    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
5233    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = raw)]
5234    pub fn raw_0(call_site: &Object) -> Result<JsString, JsValue>;
5235
5236    /// The static `raw()` method is a tag function of template literals,
5237    /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
5238    ///
5239    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
5240    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = raw)]
5241    pub fn raw_1(call_site: &Object, substitutions_1: &str) -> Result<JsString, JsValue>;
5242
5243    /// The static `raw()` method is a tag function of template literals,
5244    /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
5245    ///
5246    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
5247    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = raw)]
5248    pub fn raw_2(
5249        call_site: &Object,
5250        substitutions_1: &str,
5251        substitutions_2: &str,
5252    ) -> Result<JsString, JsValue>;
5253
5254    /// The static `raw()` method is a tag function of template literals,
5255    /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
5256    ///
5257    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
5258    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = raw)]
5259    pub fn raw_3(
5260        call_site: &Object,
5261        substitutions_1: &str,
5262        substitutions_2: &str,
5263        substitutions_3: &str,
5264    ) -> Result<JsString, JsValue>;
5265
5266    /// The static `raw()` method is a tag function of template literals,
5267    /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
5268    ///
5269    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
5270    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = raw)]
5271    pub fn raw_4(
5272        call_site: &Object,
5273        substitutions_1: &str,
5274        substitutions_2: &str,
5275        substitutions_3: &str,
5276        substitutions_4: &str,
5277    ) -> Result<JsString, JsValue>;
5278
5279    /// The static `raw()` method is a tag function of template literals,
5280    /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
5281    ///
5282    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
5283    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = raw)]
5284    pub fn raw_5(
5285        call_site: &Object,
5286        substitutions_1: &str,
5287        substitutions_2: &str,
5288        substitutions_3: &str,
5289        substitutions_4: &str,
5290        substitutions_5: &str,
5291    ) -> Result<JsString, JsValue>;
5292
5293    /// The static `raw()` method is a tag function of template literals,
5294    /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
5295    ///
5296    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
5297    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = raw)]
5298    pub fn raw_6(
5299        call_site: &Object,
5300        substitutions_1: &str,
5301        substitutions_2: &str,
5302        substitutions_3: &str,
5303        substitutions_4: &str,
5304        substitutions_5: &str,
5305        substitutions_6: &str,
5306    ) -> Result<JsString, JsValue>;
5307
5308    /// The static `raw()` method is a tag function of template literals,
5309    /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
5310    ///
5311    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
5312    #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = raw)]
5313    pub fn raw_7(
5314        call_site: &Object,
5315        substitutions_1: &str,
5316        substitutions_2: &str,
5317        substitutions_3: &str,
5318        substitutions_4: &str,
5319        substitutions_5: &str,
5320        substitutions_6: &str,
5321        substitutions_7: &str,
5322    ) -> Result<JsString, JsValue>;
5323}
5324
5325impl JsString {
5326    /// Returns the `JsString` value of this JS value if it's an instance of a
5327    /// string.
5328    ///
5329    /// If this JS value is not an instance of a string then this returns
5330    /// `None`.
5331    #[deprecated(note = "recommended to use dyn_ref instead which is now equivalent")]
5332    pub fn try_from(val: &JsValue) -> Option<&JsString> {
5333        val.dyn_ref()
5334    }
5335
5336    /// Returns whether this string is a valid UTF-16 string.
5337    ///
5338    /// This is useful for learning whether `String::from(..)` will return a
5339    /// lossless representation of the JS string. If this string contains
5340    /// unpaired surrogates then `String::from` will succeed but it will be a
5341    /// lossy representation of the JS string because unpaired surrogates will
5342    /// become replacement characters.
5343    ///
5344    /// If this function returns `false` then to get a lossless representation
5345    /// of the string you'll need to manually use the `iter` method (or the
5346    /// `char_code_at` accessor) to view the raw character codes.
5347    ///
5348    /// For more information, see the documentation on [JS strings vs Rust
5349    /// strings][docs]
5350    ///
5351    /// [docs]: https://rustwasm.github.io/docs/wasm-bindgen/reference/types/str.html
5352    pub fn is_valid_utf16(&self) -> bool {
5353        core::char::decode_utf16(self.iter()).all(|i| i.is_ok())
5354    }
5355
5356    /// Returns an iterator over the `u16` character codes that make up this JS
5357    /// string.
5358    ///
5359    /// This method will call `char_code_at` for each code in this JS string,
5360    /// returning an iterator of the codes in sequence.
5361    pub fn iter(
5362        &self,
5363    ) -> impl ExactSizeIterator<Item = u16> + DoubleEndedIterator<Item = u16> + '_ {
5364        (0..self.length()).map(move |i| self.char_code_at(i) as u16)
5365    }
5366
5367    /// If this string consists of a single Unicode code point, then this method
5368    /// converts it into a Rust `char` without doing any allocations.
5369    ///
5370    /// If this JS value is not a valid UTF-8 or consists of more than a single
5371    /// codepoint, then this returns `None`.
5372    ///
5373    /// Note that a single Unicode code point might be represented as more than
5374    /// one code unit on the JavaScript side. For example, a JavaScript string
5375    /// `"\uD801\uDC37"` is actually a single Unicode code point U+10437 which
5376    /// corresponds to a character '𐐷'.
5377    pub fn as_char(&self) -> Option<char> {
5378        let len = self.length();
5379
5380        if len == 0 || len > 2 {
5381            return None;
5382        }
5383
5384        // This will be simplified when definitions are fixed:
5385        // https://github.com/rustwasm/wasm-bindgen/issues/1362
5386        let cp = self.code_point_at(0).as_f64().unwrap_throw() as u32;
5387
5388        let c = core::char::from_u32(cp)?;
5389
5390        if c.len_utf16() as u32 == len {
5391            Some(c)
5392        } else {
5393            None
5394        }
5395    }
5396}
5397
5398impl PartialEq<str> for JsString {
5399    #[allow(clippy::cmp_owned)] // prevent infinite recursion
5400    fn eq(&self, other: &str) -> bool {
5401        String::from(self) == other
5402    }
5403}
5404
5405impl<'a> PartialEq<&'a str> for JsString {
5406    fn eq(&self, other: &&'a str) -> bool {
5407        <JsString as PartialEq<str>>::eq(self, other)
5408    }
5409}
5410
5411impl PartialEq<String> for JsString {
5412    fn eq(&self, other: &String) -> bool {
5413        <JsString as PartialEq<str>>::eq(self, other)
5414    }
5415}
5416
5417impl<'a> PartialEq<&'a String> for JsString {
5418    fn eq(&self, other: &&'a String) -> bool {
5419        <JsString as PartialEq<str>>::eq(self, other)
5420    }
5421}
5422
5423impl<'a> From<&'a str> for JsString {
5424    fn from(s: &'a str) -> Self {
5425        JsString::unchecked_from_js(JsValue::from_str(s))
5426    }
5427}
5428
5429impl From<String> for JsString {
5430    fn from(s: String) -> Self {
5431        From::from(&*s)
5432    }
5433}
5434
5435impl From<char> for JsString {
5436    #[inline]
5437    fn from(c: char) -> Self {
5438        JsString::from_code_point1(c as u32).unwrap_throw()
5439    }
5440}
5441
5442impl<'a> From<&'a JsString> for String {
5443    fn from(s: &'a JsString) -> Self {
5444        s.obj.as_string().unwrap_throw()
5445    }
5446}
5447
5448impl From<JsString> for String {
5449    fn from(s: JsString) -> Self {
5450        From::from(&s)
5451    }
5452}
5453
5454impl fmt::Debug for JsString {
5455    #[inline]
5456    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
5457        fmt::Debug::fmt(&String::from(self), f)
5458    }
5459}
5460
5461impl fmt::Display for JsString {
5462    #[inline]
5463    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
5464        fmt::Display::fmt(&String::from(self), f)
5465    }
5466}
5467
5468impl str::FromStr for JsString {
5469    type Err = convert::Infallible;
5470    fn from_str(s: &str) -> Result<Self, Self::Err> {
5471        Ok(JsString::from(s))
5472    }
5473}
5474
5475// Symbol
5476#[wasm_bindgen]
5477extern "C" {
5478    #[wasm_bindgen(is_type_of = JsValue::is_symbol, typescript_type = "Symbol")]
5479    #[derive(Clone, Debug)]
5480    pub type Symbol;
5481
5482    /// The `Symbol.hasInstance` well-known symbol is used to determine
5483    /// if a constructor object recognizes an object as its instance.
5484    /// The `instanceof` operator's behavior can be customized by this symbol.
5485    ///
5486    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/hasInstance)
5487    #[wasm_bindgen(static_method_of = Symbol, getter, structural, js_name = hasInstance)]
5488    pub fn has_instance() -> Symbol;
5489
5490    /// The `Symbol.isConcatSpreadable` well-known symbol is used to configure
5491    /// if an object should be flattened to its array elements when using the
5492    /// `Array.prototype.concat()` method.
5493    ///
5494    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/isConcatSpreadable)
5495    #[wasm_bindgen(static_method_of = Symbol, getter, structural, js_name = isConcatSpreadable)]
5496    pub fn is_concat_spreadable() -> Symbol;
5497
5498    /// The `Symbol.asyncIterator` well-known symbol specifies the default AsyncIterator for an object.
5499    /// If this property is set on an object, it is an async iterable and can be used in a `for await...of` loop.
5500    ///
5501    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/asyncIterator)
5502    #[wasm_bindgen(static_method_of = Symbol, getter, structural, js_name = asyncIterator)]
5503    pub fn async_iterator() -> Symbol;
5504
5505    /// The `Symbol.iterator` well-known symbol specifies the default iterator
5506    /// for an object.  Used by `for...of`.
5507    ///
5508    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/iterator)
5509    #[wasm_bindgen(static_method_of = Symbol, getter, structural)]
5510    pub fn iterator() -> Symbol;
5511
5512    /// The `Symbol.match` well-known symbol specifies the matching of a regular
5513    /// expression against a string. This function is called by the
5514    /// `String.prototype.match()` method.
5515    ///
5516    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/match)
5517    #[wasm_bindgen(static_method_of = Symbol, getter, structural, js_name = match)]
5518    pub fn match_() -> Symbol;
5519
5520    /// The `Symbol.replace` well-known symbol specifies the method that
5521    /// replaces matched substrings of a string.  This function is called by the
5522    /// `String.prototype.replace()` method.
5523    ///
5524    /// For more information, see `RegExp.prototype[@@replace]()` and
5525    /// `String.prototype.replace()`.
5526    ///
5527    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/replace)
5528    #[wasm_bindgen(static_method_of = Symbol, getter, structural)]
5529    pub fn replace() -> Symbol;
5530
5531    /// The `Symbol.search` well-known symbol specifies the method that returns
5532    /// the index within a string that matches the regular expression.  This
5533    /// function is called by the `String.prototype.search()` method.
5534    ///
5535    /// For more information, see `RegExp.prototype[@@search]()` and
5536    /// `String.prototype.search()`.
5537    ///
5538    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/search)
5539    #[wasm_bindgen(static_method_of = Symbol, getter, structural)]
5540    pub fn search() -> Symbol;
5541
5542    /// The well-known symbol `Symbol.species` specifies a function-valued
5543    /// property that the constructor function uses to create derived objects.
5544    ///
5545    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/species)
5546    #[wasm_bindgen(static_method_of = Symbol, getter, structural)]
5547    pub fn species() -> Symbol;
5548
5549    /// The `Symbol.split` well-known symbol specifies the method that splits a
5550    /// string at the indices that match a regular expression.  This function is
5551    /// called by the `String.prototype.split()` method.
5552    ///
5553    /// For more information, see `RegExp.prototype[@@split]()` and
5554    /// `String.prototype.split()`.
5555    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/split)
5556    #[wasm_bindgen(static_method_of = Symbol, getter, structural)]
5557    pub fn split() -> Symbol;
5558
5559    /// The `Symbol.toPrimitive` is a symbol that specifies a function valued
5560    /// property that is called to convert an object to a corresponding
5561    /// primitive value.
5562    ///
5563    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toPrimitive)
5564    #[wasm_bindgen(static_method_of = Symbol, getter, structural, js_name = toPrimitive)]
5565    pub fn to_primitive() -> Symbol;
5566
5567    /// The `Symbol.toStringTag` well-known symbol is a string valued property
5568    /// that is used in the creation of the default string description of an
5569    /// object.  It is accessed internally by the `Object.prototype.toString()`
5570    /// method.
5571    ///
5572    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toString)
5573    #[wasm_bindgen(static_method_of = Symbol, getter, structural, js_name = toStringTag)]
5574    pub fn to_string_tag() -> Symbol;
5575
5576    /// The `Symbol.for(key)` method searches for existing symbols in a runtime-wide symbol registry with
5577    /// the given key and returns it if found.
5578    /// Otherwise a new symbol gets created in the global symbol registry with this key.
5579    ///
5580    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/for)
5581    #[wasm_bindgen(static_method_of = Symbol, js_name = for)]
5582    pub fn for_(key: &str) -> Symbol;
5583
5584    /// The `Symbol.keyFor(sym)` method retrieves a shared symbol key from the global symbol registry for the given symbol.
5585    ///
5586    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/keyFor)
5587    #[wasm_bindgen(static_method_of = Symbol, js_name = keyFor)]
5588    pub fn key_for(sym: &Symbol) -> JsValue;
5589
5590    /// The `toString()` method returns a string representing the specified Symbol object.
5591    ///
5592    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toString)
5593    #[wasm_bindgen(method, js_name = toString)]
5594    pub fn to_string(this: &Symbol) -> JsString;
5595
5596    /// The `Symbol.unscopables` well-known symbol is used to specify an object
5597    /// value of whose own and inherited property names are excluded from the
5598    /// with environment bindings of the associated object.
5599    ///
5600    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/unscopables)
5601    #[wasm_bindgen(static_method_of = Symbol, getter, structural)]
5602    pub fn unscopables() -> Symbol;
5603
5604    /// The `valueOf()` method returns the primitive value of a Symbol object.
5605    ///
5606    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/valueOf)
5607    #[wasm_bindgen(method, js_name = valueOf)]
5608    pub fn value_of(this: &Symbol) -> Symbol;
5609}
5610
5611#[allow(non_snake_case)]
5612pub mod Intl {
5613    use super::*;
5614
5615    // Intl
5616    #[wasm_bindgen]
5617    extern "C" {
5618        /// The `Intl.getCanonicalLocales()` method returns an array containing
5619        /// the canonical locale names. Duplicates will be omitted and elements
5620        /// will be validated as structurally valid language tags.
5621        ///
5622        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/getCanonicalLocales)
5623        #[wasm_bindgen(js_name = getCanonicalLocales, js_namespace = Intl)]
5624        pub fn get_canonical_locales(s: &JsValue) -> Array;
5625    }
5626
5627    // Intl.Collator
5628    #[wasm_bindgen]
5629    extern "C" {
5630        /// The `Intl.Collator` object is a constructor for collators, objects
5631        /// that enable language sensitive string comparison.
5632        ///
5633        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator)
5634        #[wasm_bindgen(extends = Object, js_namespace = Intl, typescript_type = "Intl.Collator")]
5635        #[derive(Clone, Debug)]
5636        pub type Collator;
5637
5638        /// The `Intl.Collator` object is a constructor for collators, objects
5639        /// that enable language sensitive string comparison.
5640        ///
5641        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator)
5642        #[wasm_bindgen(constructor, js_namespace = Intl)]
5643        pub fn new(locales: &Array, options: &Object) -> Collator;
5644
5645        /// The Intl.Collator.prototype.compare property returns a function that
5646        /// compares two strings according to the sort order of this Collator
5647        /// object.
5648        ///
5649        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator/compare)
5650        #[wasm_bindgen(method, getter, js_class = "Intl.Collator")]
5651        pub fn compare(this: &Collator) -> Function;
5652
5653        /// The `Intl.Collator.prototype.resolvedOptions()` method returns a new
5654        /// object with properties reflecting the locale and collation options
5655        /// computed during initialization of this Collator object.
5656        ///
5657        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator/resolvedOptions)
5658        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
5659        pub fn resolved_options(this: &Collator) -> Object;
5660
5661        /// The `Intl.Collator.supportedLocalesOf()` method returns an array
5662        /// containing those of the provided locales that are supported in
5663        /// collation without having to fall back to the runtime's default
5664        /// locale.
5665        ///
5666        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator/supportedLocalesOf)
5667        #[wasm_bindgen(static_method_of = Collator, js_namespace = Intl, js_name = supportedLocalesOf)]
5668        pub fn supported_locales_of(locales: &Array, options: &Object) -> Array;
5669    }
5670
5671    impl Default for Collator {
5672        fn default() -> Self {
5673            Self::new(
5674                &JsValue::UNDEFINED.unchecked_into(),
5675                &JsValue::UNDEFINED.unchecked_into(),
5676            )
5677        }
5678    }
5679
5680    // Intl.DateTimeFormat
5681    #[wasm_bindgen]
5682    extern "C" {
5683        /// The `Intl.DateTimeFormat` object is a constructor for objects
5684        /// that enable language-sensitive date and time formatting.
5685        ///
5686        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat)
5687        #[wasm_bindgen(extends = Object, js_namespace = Intl, typescript_type = "Intl.DateTimeFormat")]
5688        #[derive(Clone, Debug)]
5689        pub type DateTimeFormat;
5690
5691        /// The `Intl.DateTimeFormat` object is a constructor for objects
5692        /// that enable language-sensitive date and time formatting.
5693        ///
5694        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat)
5695        #[wasm_bindgen(constructor, js_namespace = Intl)]
5696        pub fn new(locales: &Array, options: &Object) -> DateTimeFormat;
5697
5698        /// The Intl.DateTimeFormat.prototype.format property returns a getter function that
5699        /// formats a date according to the locale and formatting options of this
5700        /// Intl.DateTimeFormat object.
5701        ///
5702        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/format)
5703        #[wasm_bindgen(method, getter, js_class = "Intl.DateTimeFormat")]
5704        pub fn format(this: &DateTimeFormat) -> Function;
5705
5706        /// The `Intl.DateTimeFormat.prototype.formatToParts()` method allows locale-aware
5707        /// formatting of strings produced by DateTimeFormat formatters.
5708        ///
5709        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/formatToParts)
5710        #[wasm_bindgen(method, js_class = "Intl.DateTimeFormat", js_name = formatToParts)]
5711        pub fn format_to_parts(this: &DateTimeFormat, date: &Date) -> Array;
5712
5713        /// The `Intl.DateTimeFormat.prototype.resolvedOptions()` method returns a new
5714        /// object with properties reflecting the locale and date and time formatting
5715        /// options computed during initialization of this DateTimeFormat object.
5716        ///
5717        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/resolvedOptions)
5718        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
5719        pub fn resolved_options(this: &DateTimeFormat) -> Object;
5720
5721        /// The `Intl.DateTimeFormat.supportedLocalesOf()` method returns an array
5722        /// containing those of the provided locales that are supported in date
5723        /// and time formatting without having to fall back to the runtime's default
5724        /// locale.
5725        ///
5726        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/supportedLocalesOf)
5727        #[wasm_bindgen(static_method_of = DateTimeFormat, js_namespace = Intl, js_name = supportedLocalesOf)]
5728        pub fn supported_locales_of(locales: &Array, options: &Object) -> Array;
5729    }
5730
5731    impl Default for DateTimeFormat {
5732        fn default() -> Self {
5733            Self::new(
5734                &JsValue::UNDEFINED.unchecked_into(),
5735                &JsValue::UNDEFINED.unchecked_into(),
5736            )
5737        }
5738    }
5739
5740    // Intl.NumberFormat
5741    #[wasm_bindgen]
5742    extern "C" {
5743        /// The `Intl.NumberFormat` object is a constructor for objects
5744        /// that enable language sensitive number formatting.
5745        ///
5746        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat)
5747        #[wasm_bindgen(extends = Object, js_namespace = Intl, typescript_type = "Intl.NumberFormat")]
5748        #[derive(Clone, Debug)]
5749        pub type NumberFormat;
5750
5751        /// The `Intl.NumberFormat` object is a constructor for objects
5752        /// that enable language sensitive number formatting.
5753        ///
5754        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat)
5755        #[wasm_bindgen(constructor, js_namespace = Intl)]
5756        pub fn new(locales: &Array, options: &Object) -> NumberFormat;
5757
5758        /// The Intl.NumberFormat.prototype.format property returns a getter function that
5759        /// formats a number according to the locale and formatting options of this
5760        /// NumberFormat object.
5761        ///
5762        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/format)
5763        #[wasm_bindgen(method, getter, js_class = "Intl.NumberFormat")]
5764        pub fn format(this: &NumberFormat) -> Function;
5765
5766        /// The `Intl.Numberformat.prototype.formatToParts()` method allows locale-aware
5767        /// formatting of strings produced by NumberTimeFormat formatters.
5768        ///
5769        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/formatToParts)
5770        #[wasm_bindgen(method, js_class = "Intl.NumberFormat", js_name = formatToParts)]
5771        pub fn format_to_parts(this: &NumberFormat, number: f64) -> Array;
5772
5773        /// The `Intl.NumberFormat.prototype.resolvedOptions()` method returns a new
5774        /// object with properties reflecting the locale and number formatting
5775        /// options computed during initialization of this NumberFormat object.
5776        ///
5777        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/resolvedOptions)
5778        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
5779        pub fn resolved_options(this: &NumberFormat) -> Object;
5780
5781        /// The `Intl.NumberFormat.supportedLocalesOf()` method returns an array
5782        /// containing those of the provided locales that are supported in number
5783        /// formatting without having to fall back to the runtime's default locale.
5784        ///
5785        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/supportedLocalesOf)
5786        #[wasm_bindgen(static_method_of = NumberFormat, js_namespace = Intl, js_name = supportedLocalesOf)]
5787        pub fn supported_locales_of(locales: &Array, options: &Object) -> Array;
5788    }
5789
5790    impl Default for NumberFormat {
5791        fn default() -> Self {
5792            Self::new(
5793                &JsValue::UNDEFINED.unchecked_into(),
5794                &JsValue::UNDEFINED.unchecked_into(),
5795            )
5796        }
5797    }
5798
5799    // Intl.PluralRules
5800    #[wasm_bindgen]
5801    extern "C" {
5802        /// The `Intl.PluralRules` object is a constructor for objects
5803        /// that enable plural sensitive formatting and plural language rules.
5804        ///
5805        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules)
5806        #[wasm_bindgen(extends = Object, js_namespace = Intl, typescript_type = "Intl.PluralRules")]
5807        #[derive(Clone, Debug)]
5808        pub type PluralRules;
5809
5810        /// The `Intl.PluralRules` object is a constructor for objects
5811        /// that enable plural sensitive formatting and plural language rules.
5812        ///
5813        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules)
5814        #[wasm_bindgen(constructor, js_namespace = Intl)]
5815        pub fn new(locales: &Array, options: &Object) -> PluralRules;
5816
5817        /// The `Intl.PluralRules.prototype.resolvedOptions()` method returns a new
5818        /// object with properties reflecting the locale and plural formatting
5819        /// options computed during initialization of this PluralRules object.
5820        ///
5821        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules/resolvedOptions)
5822        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
5823        pub fn resolved_options(this: &PluralRules) -> Object;
5824
5825        /// The `Intl.PluralRules.prototype.select()` method returns a String indicating
5826        /// which plural rule to use for locale-aware formatting.
5827        ///
5828        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules/select)
5829        #[wasm_bindgen(method, js_namespace = Intl)]
5830        pub fn select(this: &PluralRules, number: f64) -> JsString;
5831
5832        /// The `Intl.PluralRules.supportedLocalesOf()` method returns an array
5833        /// containing those of the provided locales that are supported in plural
5834        /// formatting without having to fall back to the runtime's default locale.
5835        ///
5836        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules/supportedLocalesOf)
5837        #[wasm_bindgen(static_method_of = PluralRules, js_namespace = Intl, js_name = supportedLocalesOf)]
5838        pub fn supported_locales_of(locales: &Array, options: &Object) -> Array;
5839    }
5840
5841    impl Default for PluralRules {
5842        fn default() -> Self {
5843            Self::new(
5844                &JsValue::UNDEFINED.unchecked_into(),
5845                &JsValue::UNDEFINED.unchecked_into(),
5846            )
5847        }
5848    }
5849
5850    // Intl.RelativeTimeFormat
5851    #[wasm_bindgen]
5852    extern "C" {
5853        /// The `Intl.RelativeTimeFormat` object is a constructor for objects
5854        /// that enable language-sensitive relative time formatting.
5855        ///
5856        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat)
5857        #[wasm_bindgen(extends = Object, js_namespace = Intl, typescript_type = "Intl.RelativeTimeFormat")]
5858        #[derive(Clone, Debug)]
5859        pub type RelativeTimeFormat;
5860
5861        /// The `Intl.RelativeTimeFormat` object is a constructor for objects
5862        /// that enable language-sensitive relative time formatting.
5863        ///
5864        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat)
5865        #[wasm_bindgen(constructor, js_namespace = Intl)]
5866        pub fn new(locales: &Array, options: &Object) -> RelativeTimeFormat;
5867
5868        /// The `Intl.RelativeTimeFormat.prototype.format` method formats a `value` and `unit`
5869        /// according to the locale and formatting options of this Intl.RelativeTimeFormat object.
5870        ///
5871        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/format)
5872        #[wasm_bindgen(method, js_class = "Intl.RelativeTimeFormat")]
5873        pub fn format(this: &RelativeTimeFormat, value: f64, unit: &str) -> JsString;
5874
5875        /// The `Intl.RelativeTimeFormat.prototype.formatToParts()` method returns an array of
5876        /// objects representing the relative time format in parts that can be used for custom locale-aware formatting.
5877        ///
5878        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/formatToParts)
5879        #[wasm_bindgen(method, js_class = "Intl.RelativeTimeFormat", js_name = formatToParts)]
5880        pub fn format_to_parts(this: &RelativeTimeFormat, value: f64, unit: &str) -> Array;
5881
5882        /// The `Intl.RelativeTimeFormat.prototype.resolvedOptions()` method returns a new
5883        /// object with properties reflecting the locale and relative time formatting
5884        /// options computed during initialization of this RelativeTimeFormat object.
5885        ///
5886        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/resolvedOptions)
5887        #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
5888        pub fn resolved_options(this: &RelativeTimeFormat) -> Object;
5889
5890        /// The `Intl.RelativeTimeFormat.supportedLocalesOf()` method returns an array
5891        /// containing those of the provided locales that are supported in date and time
5892        /// formatting without having to fall back to the runtime's default locale.
5893        ///
5894        /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RelativeTimeFormat/supportedLocalesOf)
5895        #[wasm_bindgen(static_method_of = RelativeTimeFormat, js_namespace = Intl, js_name = supportedLocalesOf)]
5896        pub fn supported_locales_of(locales: &Array, options: &Object) -> Array;
5897    }
5898
5899    impl Default for RelativeTimeFormat {
5900        fn default() -> Self {
5901            Self::new(
5902                &JsValue::UNDEFINED.unchecked_into(),
5903                &JsValue::UNDEFINED.unchecked_into(),
5904            )
5905        }
5906    }
5907}
5908
5909// Promise
5910#[wasm_bindgen]
5911extern "C" {
5912    /// The `Promise` object represents the eventual completion (or failure) of
5913    /// an asynchronous operation, and its resulting value.
5914    ///
5915    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
5916    #[must_use]
5917    #[wasm_bindgen(extends = Object, typescript_type = "Promise<any>")]
5918    #[derive(Clone, Debug)]
5919    pub type Promise;
5920
5921    /// Creates a new `Promise` with the provided executor `cb`
5922    ///
5923    /// The `cb` is a function that is passed with the arguments `resolve` and
5924    /// `reject`. The `cb` function is executed immediately by the `Promise`
5925    /// implementation, passing `resolve` and `reject` functions (the executor
5926    /// is called before the `Promise` constructor even returns the created
5927    /// object). The `resolve` and `reject` functions, when called, resolve or
5928    /// reject the promise, respectively. The executor normally initiates
5929    /// some asynchronous work, and then, once that completes, either calls
5930    /// the `resolve` function to resolve the promise or else rejects it if an
5931    /// error occurred.
5932    ///
5933    /// If an error is thrown in the executor function, the promise is rejected.
5934    /// The return value of the executor is ignored.
5935    ///
5936    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
5937    #[wasm_bindgen(constructor)]
5938    pub fn new(cb: &mut dyn FnMut(Function, Function)) -> Promise;
5939
5940    /// The `Promise.all(iterable)` method returns a single `Promise` that
5941    /// resolves when all of the promises in the iterable argument have resolved
5942    /// or when the iterable argument contains no promises. It rejects with the
5943    /// reason of the first promise that rejects.
5944    ///
5945    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all)
5946    #[wasm_bindgen(static_method_of = Promise)]
5947    pub fn all(obj: &JsValue) -> Promise;
5948
5949    /// The `Promise.allSettled(iterable)` method returns a single `Promise` that
5950    /// resolves when all of the promises in the iterable argument have either
5951    /// fulfilled or rejected or when the iterable argument contains no promises.
5952    ///
5953    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/allSettled)
5954    #[wasm_bindgen(static_method_of = Promise, js_name = allSettled)]
5955    pub fn all_settled(obj: &JsValue) -> Promise;
5956
5957    /// The `Promise.any(iterable)` method returns a single `Promise` that
5958    /// resolves when any of the promises in the iterable argument have resolved
5959    /// or when the iterable argument contains no promises. It rejects with an
5960    /// `AggregateError` if all promises in the iterable rejected.
5961    ///
5962    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/any)
5963    #[wasm_bindgen(static_method_of = Promise)]
5964    pub fn any(obj: &JsValue) -> Promise;
5965
5966    /// The `Promise.race(iterable)` method returns a promise that resolves or
5967    /// rejects as soon as one of the promises in the iterable resolves or
5968    /// rejects, with the value or reason from that promise.
5969    ///
5970    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/race)
5971    #[wasm_bindgen(static_method_of = Promise)]
5972    pub fn race(obj: &JsValue) -> Promise;
5973
5974    /// The `Promise.reject(reason)` method returns a `Promise` object that is
5975    /// rejected with the given reason.
5976    ///
5977    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/reject)
5978    #[wasm_bindgen(static_method_of = Promise)]
5979    pub fn reject(obj: &JsValue) -> Promise;
5980
5981    /// The `Promise.resolve(value)` method returns a `Promise` object that is
5982    /// resolved with the given value. If the value is a promise, that promise
5983    /// is returned; if the value is a thenable (i.e. has a "then" method), the
5984    /// returned promise will "follow" that thenable, adopting its eventual
5985    /// state; otherwise the returned promise will be fulfilled with the value.
5986    ///
5987    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/resolve)
5988    #[wasm_bindgen(static_method_of = Promise)]
5989    pub fn resolve(obj: &JsValue) -> Promise;
5990
5991    /// The `catch()` method returns a `Promise` and deals with rejected cases
5992    /// only.  It behaves the same as calling `Promise.prototype.then(undefined,
5993    /// onRejected)` (in fact, calling `obj.catch(onRejected)` internally calls
5994    /// `obj.then(undefined, onRejected)`).
5995    ///
5996    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/catch)
5997    #[wasm_bindgen(method)]
5998    pub fn catch(this: &Promise, cb: &Closure<dyn FnMut(JsValue)>) -> Promise;
5999
6000    /// The `then()` method returns a `Promise`. It takes up to two arguments:
6001    /// callback functions for the success and failure cases of the `Promise`.
6002    ///
6003    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then)
6004    #[wasm_bindgen(method)]
6005    pub fn then(this: &Promise, cb: &Closure<dyn FnMut(JsValue)>) -> Promise;
6006
6007    /// Same as `then`, only with both arguments provided.
6008    #[wasm_bindgen(method, js_name = then)]
6009    pub fn then2(
6010        this: &Promise,
6011        resolve: &Closure<dyn FnMut(JsValue)>,
6012        reject: &Closure<dyn FnMut(JsValue)>,
6013    ) -> Promise;
6014
6015    /// The `finally()` method returns a `Promise`. When the promise is settled,
6016    /// whether fulfilled or rejected, the specified callback function is
6017    /// executed. This provides a way for code that must be executed once the
6018    /// `Promise` has been dealt with to be run whether the promise was
6019    /// fulfilled successfully or rejected.
6020    ///
6021    /// This lets you avoid duplicating code in both the promise's `then()` and
6022    /// `catch()` handlers.
6023    ///
6024    /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/finally)
6025    #[wasm_bindgen(method)]
6026    pub fn finally(this: &Promise, cb: &Closure<dyn FnMut()>) -> Promise;
6027}
6028
6029/// Returns a handle to the global scope object.
6030///
6031/// This allows access to the global properties and global names by accessing
6032/// the `Object` returned.
6033pub fn global() -> Object {
6034    #[cfg(feature = "std")]
6035    {
6036        thread_local!(static GLOBAL: Object = get_global_object());
6037        return GLOBAL.with(|g| g.clone());
6038    }
6039    #[cfg(not(feature = "std"))]
6040    {
6041        use once_cell::unsync::Lazy;
6042
6043        struct Wrapper<T>(Lazy<T>);
6044
6045        #[cfg(not(target_feature = "atomics"))]
6046        unsafe impl<T> Sync for Wrapper<T> {}
6047
6048        #[cfg(not(target_feature = "atomics"))]
6049        unsafe impl<T> Send for Wrapper<T> {}
6050
6051        #[cfg_attr(target_feature = "atomics", thread_local)]
6052        static GLOBAL: Wrapper<Object> = Wrapper(Lazy::new(get_global_object));
6053
6054        return GLOBAL.0.clone();
6055    }
6056
6057    fn get_global_object() -> Object {
6058        // Accessing the global object is not an easy thing to do, and what we
6059        // basically want is `globalThis` but we can't rely on that existing
6060        // everywhere. In the meantime we've got the fallbacks mentioned in:
6061        //
6062        // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis
6063        //
6064        // Note that this is pretty heavy code-size wise but it at least gets
6065        // the job largely done for now and avoids the `Function` constructor at
6066        // the end which triggers CSP errors.
6067        #[wasm_bindgen]
6068        extern "C" {
6069            type Global;
6070
6071            #[wasm_bindgen(thread_local_v2, js_name = globalThis)]
6072            static GLOBAL_THIS: Option<Object>;
6073
6074            #[wasm_bindgen(thread_local_v2, js_name = self)]
6075            static SELF: Option<Object>;
6076
6077            #[wasm_bindgen(thread_local_v2, js_name = window)]
6078            static WINDOW: Option<Object>;
6079
6080            #[wasm_bindgen(thread_local_v2, js_name = global)]
6081            static GLOBAL: Option<Object>;
6082        }
6083
6084        // The order is important: in Firefox Extension Content Scripts `globalThis`
6085        // is a Sandbox (not Window), so `globalThis` must be checked after `window`.
6086        let static_object = SELF
6087            .with(Option::clone)
6088            .or_else(|| WINDOW.with(Option::clone))
6089            .or_else(|| GLOBAL_THIS.with(Option::clone))
6090            .or_else(|| GLOBAL.with(Option::clone));
6091        if let Some(obj) = static_object {
6092            if !obj.is_undefined() {
6093                return obj;
6094            }
6095        }
6096
6097        // According to StackOverflow you can access the global object via:
6098        //
6099        //      const global = Function('return this')();
6100        //
6101        // I think that's because the manufactured function isn't in "strict" mode.
6102        // It also turns out that non-strict functions will ignore `undefined`
6103        // values for `this` when using the `apply` function.
6104        //
6105        // As a result we use the equivalent of this snippet to get a handle to the
6106        // global object in a sort of roundabout way that should hopefully work in
6107        // all contexts like ESM, node, browsers, etc.
6108        let this = Function::new_no_args("return this")
6109            .call0(&JsValue::undefined())
6110            .ok();
6111
6112        // Note that we avoid `unwrap()` on `call0` to avoid code size bloat, we
6113        // just handle the `Err` case as returning a different object.
6114        debug_assert!(this.is_some());
6115        match this {
6116            Some(this) => this.unchecked_into(),
6117            None => JsValue::undefined().unchecked_into(),
6118        }
6119    }
6120}
6121
6122macro_rules! arrays {
6123    ($(#[doc = $ctor:literal] #[doc = $mdn:literal] $name:ident: $ty:ident,)*) => ($(
6124        #[wasm_bindgen]
6125        extern "C" {
6126            #[wasm_bindgen(extends = Object, typescript_type = $name)]
6127            #[derive(Clone, Debug)]
6128            pub type $name;
6129
6130            /// The
6131            #[doc = $ctor]
6132            /// constructor creates a new array.
6133            ///
6134            /// [MDN documentation](
6135            #[doc = $mdn]
6136            /// )
6137            #[wasm_bindgen(constructor)]
6138            pub fn new(constructor_arg: &JsValue) -> $name;
6139
6140            /// An
6141            #[doc = $ctor]
6142            /// which creates an array with an internal buffer large
6143            /// enough for `length` elements.
6144            ///
6145            /// [MDN documentation](
6146            #[doc = $mdn]
6147            /// )
6148            #[wasm_bindgen(constructor)]
6149            pub fn new_with_length(length: u32) -> $name;
6150
6151            /// An
6152            #[doc = $ctor]
6153            /// which creates an array with the given buffer but is a
6154            /// view starting at `byte_offset`.
6155            ///
6156            /// [MDN documentation](
6157            #[doc = $mdn]
6158            /// )
6159            #[wasm_bindgen(constructor)]
6160            pub fn new_with_byte_offset(buffer: &JsValue, byte_offset: u32) -> $name;
6161
6162            /// An
6163            #[doc = $ctor]
6164            /// which creates an array with the given buffer but is a
6165            /// view starting at `byte_offset` for `length` elements.
6166            ///
6167            /// [MDN documentation](
6168            #[doc = $mdn]
6169            /// )
6170            #[wasm_bindgen(constructor)]
6171            pub fn new_with_byte_offset_and_length(
6172                buffer: &JsValue,
6173                byte_offset: u32,
6174                length: u32,
6175            ) -> $name;
6176
6177            /// The `fill()` method fills all the elements of an array from a start index
6178            /// to an end index with a static value. The end index is not included.
6179            ///
6180            /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/fill)
6181            #[wasm_bindgen(method)]
6182            pub fn fill(this: &$name, value: $ty, start: u32, end: u32) -> $name;
6183
6184            /// The buffer accessor property represents the `ArrayBuffer` referenced
6185            /// by a `TypedArray` at construction time.
6186            #[wasm_bindgen(getter, method)]
6187            pub fn buffer(this: &$name) -> ArrayBuffer;
6188
6189            /// The `subarray()` method returns a new `TypedArray` on the same
6190            /// `ArrayBuffer` store and with the same element types as for this
6191            /// `TypedArray` object.
6192            #[wasm_bindgen(method)]
6193            pub fn subarray(this: &$name, begin: u32, end: u32) -> $name;
6194
6195            /// The `slice()` method returns a shallow copy of a portion of a typed
6196            /// array into a new typed array object. This method has the same algorithm
6197            /// as `Array.prototype.slice()`.
6198            #[wasm_bindgen(method)]
6199            pub fn slice(this: &$name, begin: u32, end: u32) -> $name;
6200
6201            /// The `forEach()` method executes a provided function once per array
6202            /// element. This method has the same algorithm as
6203            /// `Array.prototype.forEach()`. `TypedArray` is one of the typed array
6204            /// types here.
6205            #[wasm_bindgen(method, js_name = forEach)]
6206            pub fn for_each(this: &$name, callback: &mut dyn FnMut($ty, u32, $name));
6207
6208            /// The length accessor property represents the length (in elements) of a
6209            /// typed array.
6210            #[wasm_bindgen(method, getter)]
6211            pub fn length(this: &$name) -> u32;
6212
6213            /// The byteLength accessor property represents the length (in bytes) of a
6214            /// typed array.
6215            #[wasm_bindgen(method, getter, js_name = byteLength)]
6216            pub fn byte_length(this: &$name) -> u32;
6217
6218            /// The byteOffset accessor property represents the offset (in bytes) of a
6219            /// typed array from the start of its `ArrayBuffer`.
6220            #[wasm_bindgen(method, getter, js_name = byteOffset)]
6221            pub fn byte_offset(this: &$name) -> u32;
6222
6223            /// The `set()` method stores multiple values in the typed array, reading
6224            /// input values from a specified array.
6225            #[wasm_bindgen(method)]
6226            pub fn set(this: &$name, src: &JsValue, offset: u32);
6227
6228            /// Gets the value at `idx`, counting from the end if negative.
6229            #[wasm_bindgen(method)]
6230            pub fn at(this: &$name, idx: i32) -> Option<$ty>;
6231
6232            /// The `copyWithin()` method shallow copies part of a typed array to another
6233            /// location in the same typed array and returns it, without modifying its size.
6234            ///
6235            /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/copyWithin)
6236            #[wasm_bindgen(method, js_name = copyWithin)]
6237            pub fn copy_within(this: &$name, target: i32, start: i32, end: i32) -> $name;
6238
6239            /// Gets the value at `idx`, equivalent to the javascript `my_var = arr[idx]`.
6240            #[wasm_bindgen(method, structural, indexing_getter)]
6241            pub fn get_index(this: &$name, idx: u32) -> $ty;
6242
6243            /// Sets the value at `idx`, equivalent to the javascript `arr[idx] = value`.
6244            #[wasm_bindgen(method, structural, indexing_setter)]
6245            pub fn set_index(this: &$name, idx: u32, value: $ty);
6246        }
6247
6248        impl $name {
6249            /// Creates a JS typed array which is a view into wasm's linear
6250            /// memory at the slice specified.
6251            ///
6252            /// This function returns a new typed array which is a view into
6253            /// wasm's memory. This view does not copy the underlying data.
6254            ///
6255            /// # Safety
6256            ///
6257            /// Views into WebAssembly memory are only valid so long as the
6258            /// backing buffer isn't resized in JS. Once this function is called
6259            /// any future calls to `Box::new` (or malloc of any form) may cause
6260            /// the returned value here to be invalidated. Use with caution!
6261            ///
6262            /// Additionally the returned object can be safely mutated but the
6263            /// input slice isn't guaranteed to be mutable.
6264            ///
6265            /// Finally, the returned object is disconnected from the input
6266            /// slice's lifetime, so there's no guarantee that the data is read
6267            /// at the right time.
6268            pub unsafe fn view(rust: &[$ty]) -> $name {
6269                let buf = wasm_bindgen::memory();
6270                let mem = buf.unchecked_ref::<WebAssembly::Memory>();
6271                $name::new_with_byte_offset_and_length(
6272                    &mem.buffer(),
6273                    rust.as_ptr() as u32,
6274                    rust.len() as u32,
6275                )
6276            }
6277
6278            /// Creates a JS typed array which is a view into wasm's linear
6279            /// memory at the specified pointer with specified length.
6280            ///
6281            /// This function returns a new typed array which is a view into
6282            /// wasm's memory. This view does not copy the underlying data.
6283            ///
6284            /// # Safety
6285            ///
6286            /// Views into WebAssembly memory are only valid so long as the
6287            /// backing buffer isn't resized in JS. Once this function is called
6288            /// any future calls to `Box::new` (or malloc of any form) may cause
6289            /// the returned value here to be invalidated. Use with caution!
6290            ///
6291            /// Additionally the returned object can be safely mutated,
6292            /// the changes are guaranteed to be reflected in the input array.
6293            pub unsafe fn view_mut_raw(ptr: *mut $ty, length: usize) -> $name {
6294                let buf = wasm_bindgen::memory();
6295                let mem = buf.unchecked_ref::<WebAssembly::Memory>();
6296                $name::new_with_byte_offset_and_length(
6297                    &mem.buffer(),
6298                    ptr as u32,
6299                    length as u32
6300                )
6301            }
6302
6303
6304            /// Copy the contents of this JS typed array into the destination
6305            /// Rust pointer.
6306            ///
6307            /// This function will efficiently copy the memory from a typed
6308            /// array into this Wasm module's own linear memory, initializing
6309            /// the memory destination provided.
6310            ///
6311            /// # Safety
6312            ///
6313            /// This function requires `dst` to point to a buffer
6314            /// large enough to fit this array's contents.
6315            pub unsafe fn raw_copy_to_ptr(&self, dst: *mut $ty) {
6316                let buf = wasm_bindgen::memory();
6317                let mem = buf.unchecked_ref::<WebAssembly::Memory>();
6318                let all_wasm_memory = $name::new(&mem.buffer());
6319                let offset = dst as usize / mem::size_of::<$ty>();
6320                all_wasm_memory.set(self, offset as u32);
6321            }
6322
6323            /// Copy the contents of this JS typed array into the destination
6324            /// Rust slice.
6325            ///
6326            /// This function will efficiently copy the memory from a typed
6327            /// array into this Wasm module's own linear memory, initializing
6328            /// the memory destination provided.
6329            ///
6330            /// # Panics
6331            ///
6332            /// This function will panic if this typed array's length is
6333            /// different than the length of the provided `dst` array.
6334            pub fn copy_to(&self, dst: &mut [$ty]) {
6335                core::assert_eq!(self.length() as usize, dst.len());
6336                unsafe { self.raw_copy_to_ptr(dst.as_mut_ptr()); }
6337            }
6338
6339            /// Copy the contents of the source Rust slice into this
6340            /// JS typed array.
6341            ///
6342            /// This function will efficiently copy the memory from within
6343            /// the Wasm module's own linear memory to this typed array.
6344            ///
6345            /// # Panics
6346            ///
6347            /// This function will panic if this typed array's length is
6348            /// different than the length of the provided `src` array.
6349            pub fn copy_from(&self, src: &[$ty]) {
6350                core::assert_eq!(self.length() as usize, src.len());
6351                // This is safe because the `set` function copies from its TypedArray argument
6352                unsafe { self.set(&$name::view(src), 0) }
6353            }
6354
6355            /// Efficiently copies the contents of this JS typed array into a new Vec.
6356            pub fn to_vec(&self) -> Vec<$ty> {
6357                let mut output = Vec::with_capacity(self.length() as usize);
6358                unsafe {
6359                    self.raw_copy_to_ptr(output.as_mut_ptr());
6360                    output.set_len(self.length() as usize);
6361                }
6362                output
6363            }
6364        }
6365
6366        impl<'a> From<&'a [$ty]> for $name {
6367            #[inline]
6368            fn from(slice: &'a [$ty]) -> $name {
6369                // This is safe because the `new` function makes a copy if its argument is a TypedArray
6370                unsafe { $name::new(&$name::view(slice)) }
6371            }
6372        }
6373
6374        impl Default for $name {
6375            fn default() -> Self {
6376                Self::new(&JsValue::UNDEFINED.unchecked_into())
6377            }
6378        }
6379    )*);
6380}
6381
6382arrays! {
6383    /// `Int8Array()`
6384    /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int8Array
6385    Int8Array: i8,
6386
6387    /// `Int16Array()`
6388    /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int16Array
6389    Int16Array: i16,
6390
6391    /// `Int32Array()`
6392    /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int32Array
6393    Int32Array: i32,
6394
6395    /// `Uint8Array()`
6396    /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array
6397    Uint8Array: u8,
6398
6399    /// `Uint8ClampedArray()`
6400    /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8ClampedArray
6401    Uint8ClampedArray: u8,
6402
6403    /// `Uint16Array()`
6404    /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint16Array
6405    Uint16Array: u16,
6406
6407    /// `Uint32Array()`
6408    /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint32Array
6409    Uint32Array: u32,
6410
6411    /// `Float32Array()`
6412    /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float32Array
6413    Float32Array: f32,
6414
6415    /// `Float64Array()`
6416    /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float64Array
6417    Float64Array: f64,
6418
6419    /// `BigInt64Array()`
6420    /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt64Array
6421    BigInt64Array: i64,
6422
6423    /// `BigUint64Array()`
6424    /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigUint64Array
6425    BigUint64Array: u64,
6426}