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