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 std::f64;
22 use std::fmt;
23 use std::mem;
24 
25 use wasm_bindgen::prelude::*;
26 use wasm_bindgen::JsCast;
27 
28 // When adding new imports:
29 //
30 // * Keep imports in alphabetical order.
31 //
32 // * Rename imports with `js_name = ...` according to the note about `camelCase`
33 //   and `snake_case` in the module's documentation above.
34 //
35 // * Include the one sentence summary of the import from the MDN link in the
36 //   module's documentation above, and the MDN link itself.
37 //
38 // * If a function or method can throw an exception, make it catchable by adding
39 //   `#[wasm_bindgen(catch)]`.
40 //
41 // * Add a new `#[test]` into the appropriate file in the
42 //   `crates/js-sys/tests/wasm/` directory. If the imported function or method
43 //   can throw an exception, make sure to also add test coverage for that case.
44 //
45 // * Arguments that are `JsValue`s or imported JavaScript types should be taken
46 //   by reference.
47 
48 #[wasm_bindgen]
49 extern "C" {
50     /// The `decodeURI()` function decodes a Uniform Resource Identifier (URI)
51     /// previously created by `encodeURI` or by a similar routine.
52     ///
53     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURI)
54     #[wasm_bindgen(catch, js_name = decodeURI)]
decode_uri(encoded: &str) -> Result<JsString, JsValue>55     pub fn decode_uri(encoded: &str) -> Result<JsString, JsValue>;
56 
57     /// The `decodeURIComponent()` function decodes a Uniform Resource Identifier (URI) component
58     /// previously created by `encodeURIComponent` or by a similar routine.
59     ///
60     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent)
61     #[wasm_bindgen(catch, js_name = decodeURIComponent)]
decode_uri_component(encoded: &str) -> Result<JsString, JsValue>62     pub fn decode_uri_component(encoded: &str) -> Result<JsString, JsValue>;
63 
64     /// The `encodeURI()` function encodes a Uniform Resource Identifier (URI)
65     /// by replacing each instance of certain characters by one, two, three, or
66     /// four escape sequences representing the UTF-8 encoding of the character
67     /// (will only be four escape sequences for characters composed of two
68     /// "surrogate" characters).
69     ///
70     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI)
71     #[wasm_bindgen(js_name = encodeURI)]
encode_uri(decoded: &str) -> JsString72     pub fn encode_uri(decoded: &str) -> JsString;
73 
74     /// The `encodeURIComponent()` function encodes a Uniform Resource Identifier (URI) component
75     /// by replacing each instance of certain characters by one, two, three, or four escape sequences
76     /// representing the UTF-8 encoding of the character
77     /// (will only be four escape sequences for characters composed of two "surrogate" characters).
78     ///
79     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent)
80     #[wasm_bindgen(js_name = encodeURIComponent)]
encode_uri_component(decoded: &str) -> JsString81     pub fn encode_uri_component(decoded: &str) -> JsString;
82 
83     /// The `eval()` function evaluates JavaScript code represented as a string.
84     ///
85     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval)
86     #[wasm_bindgen(catch)]
eval(js_source_text: &str) -> Result<JsValue, JsValue>87     pub fn eval(js_source_text: &str) -> Result<JsValue, JsValue>;
88 
89     /// The global `isFinite()` function determines whether the passed value is a finite number.
90     /// If needed, the parameter is first converted to a number.
91     ///
92     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/isFinite)
93     #[wasm_bindgen(js_name = isFinite)]
is_finite(value: &JsValue) -> bool94     pub fn is_finite(value: &JsValue) -> bool;
95 
96     /// The `parseInt()` function parses a string argument and returns an integer
97     /// of the specified radix (the base in mathematical numeral systems), or NaN on error.
98     ///
99     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt)
100     #[wasm_bindgen(js_name = parseInt)]
parse_int(text: &str, radix: u8) -> f64101     pub fn parse_int(text: &str, radix: u8) -> f64;
102 
103     /// The `parseFloat()` function parses an argument and returns a floating point number,
104     /// or NaN on error.
105     ///
106     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseFloat)
107     #[wasm_bindgen(js_name = parseFloat)]
parse_float(text: &str) -> f64108     pub fn parse_float(text: &str) -> f64;
109 
110     /// The `escape()` function computes a new string in which certain characters have been
111     /// replaced by a hexadecimal escape sequence.
112     ///
113     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/escape)
114     #[wasm_bindgen]
escape(string: &str) -> JsString115     pub fn escape(string: &str) -> JsString;
116 
117     /// The `unescape()` function computes a new string in which hexadecimal escape
118     /// sequences are replaced with the character that it represents. The escape sequences might
119     /// be introduced by a function like `escape`. Usually, `decodeURI` or `decodeURIComponent`
120     /// are preferred over `unescape`.
121     ///
122     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/unescape)
123     #[wasm_bindgen]
unescape(string: &str) -> JsString124     pub fn unescape(string: &str) -> JsString;
125 }
126 
127 // Array
128 #[wasm_bindgen]
129 extern "C" {
130     #[wasm_bindgen(extends = Object, is_type_of = Array::is_array, typescript_type = "Array<any>")]
131     #[derive(Clone, Debug, PartialEq, Eq)]
132     pub type Array;
133 
134     /// Creates a new empty array.
135     #[wasm_bindgen(constructor)]
new() -> Array136     pub fn new() -> Array;
137 
138     /// Creates a new array with the specified length (elements are initialized to `undefined`).
139     #[wasm_bindgen(constructor)]
new_with_length(len: u32) -> Array140     pub fn new_with_length(len: u32) -> Array;
141 
142     /// Retrieves the element at the index (returns `undefined` if the index is out of range).
143     #[wasm_bindgen(method, structural, indexing_getter)]
get(this: &Array, index: u32) -> JsValue144     pub fn get(this: &Array, index: u32) -> JsValue;
145 
146     /// Sets the element at the index (auto-enlarges the array if the index is out of range).
147     #[wasm_bindgen(method, structural, indexing_setter)]
set(this: &Array, index: u32, value: JsValue)148     pub fn set(this: &Array, index: u32, value: JsValue);
149 
150     /// Deletes the element at the index (does nothing if the index is out of range).
151     ///
152     /// The element at the index is set to `undefined`.
153     ///
154     /// This does not resize the array, the array will still be the same length.
155     #[wasm_bindgen(method, structural, indexing_deleter)]
delete(this: &Array, index: u32)156     pub fn delete(this: &Array, index: u32);
157 
158     /// The `Array.from()` method creates a new, shallow-copied `Array` instance
159     /// from an array-like or iterable object.
160     #[wasm_bindgen(static_method_of = Array)]
from(val: &JsValue) -> Array161     pub fn from(val: &JsValue) -> Array;
162 
163     /// The `copyWithin()` method shallow copies part of an array to another
164     /// location in the same array and returns it, without modifying its size.
165     ///
166     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin)
167     #[wasm_bindgen(method, js_name = copyWithin)]
copy_within(this: &Array, target: i32, start: i32, end: i32) -> Array168     pub fn copy_within(this: &Array, target: i32, start: i32, end: i32) -> Array;
169 
170     /// The `concat()` method is used to merge two or more arrays. This method
171     /// does not change the existing arrays, but instead returns a new array.
172     ///
173     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat)
174     #[wasm_bindgen(method)]
concat(this: &Array, array: &Array) -> Array175     pub fn concat(this: &Array, array: &Array) -> Array;
176 
177     /// The `every()` method tests whether all elements in the array pass the test
178     /// implemented by the provided function.
179     ///
180     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every)
181     #[wasm_bindgen(method)]
every(this: &Array, predicate: &mut dyn FnMut(JsValue, u32, Array) -> bool) -> bool182     pub fn every(this: &Array, predicate: &mut dyn FnMut(JsValue, u32, Array) -> bool) -> bool;
183 
184     /// The `fill()` method fills all the elements of an array from a start index
185     /// to an end index with a static value. The end index is not included.
186     ///
187     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fill)
188     #[wasm_bindgen(method)]
fill(this: &Array, value: &JsValue, start: u32, end: u32) -> Array189     pub fn fill(this: &Array, value: &JsValue, start: u32, end: u32) -> Array;
190 
191     /// The `filter()` method creates a new array with all elements that pass the
192     /// test implemented by the provided function.
193     ///
194     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter)
195     #[wasm_bindgen(method)]
filter(this: &Array, predicate: &mut dyn FnMut(JsValue, u32, Array) -> bool) -> Array196     pub fn filter(this: &Array, predicate: &mut dyn FnMut(JsValue, u32, Array) -> bool) -> Array;
197 
198     /// The `find()` method returns the value of the first element in the array that satisfies
199     ///  the provided testing function. Otherwise `undefined` is returned.
200     ///
201     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find)
202     #[wasm_bindgen(method)]
find(this: &Array, predicate: &mut dyn FnMut(JsValue, u32, Array) -> bool) -> JsValue203     pub fn find(this: &Array, predicate: &mut dyn FnMut(JsValue, u32, Array) -> bool) -> JsValue;
204 
205     /// The `findIndex()` method returns the index of the first element in the array that
206     /// satisfies the provided testing function. Otherwise -1 is returned.
207     ///
208     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex)
209     #[wasm_bindgen(method, js_name = findIndex)]
find_index(this: &Array, predicate: &mut dyn FnMut(JsValue, u32, Array) -> bool) -> i32210     pub fn find_index(this: &Array, predicate: &mut dyn FnMut(JsValue, u32, Array) -> bool) -> i32;
211 
212     /// The `flat()` method creates a new array with all sub-array elements concatenated into it
213     /// recursively up to the specified depth.
214     ///
215     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat)
216     #[wasm_bindgen(method)]
flat(this: &Array, depth: i32) -> Array217     pub fn flat(this: &Array, depth: i32) -> Array;
218 
219     /// The `flatMap()` method first maps each element using a mapping function, then flattens
220     /// the result into a new array.
221     ///
222     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap)
223     #[wasm_bindgen(method, js_name = flatMap)]
flat_map( this: &Array, callback: &mut dyn FnMut(JsValue, u32, Array) -> Vec<JsValue>, ) -> Array224     pub fn flat_map(
225         this: &Array,
226         callback: &mut dyn FnMut(JsValue, u32, Array) -> Vec<JsValue>,
227     ) -> Array;
228 
229     /// The `forEach()` method executes a provided function once for each array element.
230     ///
231     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach)
232     #[wasm_bindgen(method, js_name = forEach)]
for_each(this: &Array, callback: &mut dyn FnMut(JsValue, u32, Array))233     pub fn for_each(this: &Array, callback: &mut dyn FnMut(JsValue, u32, Array));
234 
235     /// The `includes()` method determines whether an array includes a certain
236     /// element, returning true or false as appropriate.
237     ///
238     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes)
239     #[wasm_bindgen(method)]
includes(this: &Array, value: &JsValue, from_index: i32) -> bool240     pub fn includes(this: &Array, value: &JsValue, from_index: i32) -> bool;
241 
242     /// The `indexOf()` method returns the first index at which a given element
243     /// can be found in the array, or -1 if it is not present.
244     ///
245     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf)
246     #[wasm_bindgen(method, js_name = indexOf)]
index_of(this: &Array, value: &JsValue, from_index: i32) -> i32247     pub fn index_of(this: &Array, value: &JsValue, from_index: i32) -> i32;
248 
249     /// The `Array.isArray()` method determines whether the passed value is an Array.
250     ///
251     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray)
252     #[wasm_bindgen(static_method_of = Array, js_name = isArray)]
is_array(value: &JsValue) -> bool253     pub fn is_array(value: &JsValue) -> bool;
254 
255     /// The `join()` method joins all elements of an array (or an array-like object)
256     /// into a string and returns this string.
257     ///
258     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join)
259     #[wasm_bindgen(method)]
join(this: &Array, delimiter: &str) -> JsString260     pub fn join(this: &Array, delimiter: &str) -> JsString;
261 
262     /// The `lastIndexOf()` method returns the last index at which a given element
263     /// can be found in the array, or -1 if it is not present. The array is
264     /// searched backwards, starting at fromIndex.
265     ///
266     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf)
267     #[wasm_bindgen(method, js_name = lastIndexOf)]
last_index_of(this: &Array, value: &JsValue, from_index: i32) -> i32268     pub fn last_index_of(this: &Array, value: &JsValue, from_index: i32) -> i32;
269 
270     /// The length property of an object which is an instance of type Array
271     /// sets or returns the number of elements in that array. The value is an
272     /// unsigned, 32-bit integer that is always numerically greater than the
273     /// highest index in the array.
274     ///
275     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/length)
276     #[wasm_bindgen(method, getter, structural)]
length(this: &Array) -> u32277     pub fn length(this: &Array) -> u32;
278 
279     /// `map()` calls a provided callback function once for each element in an array,
280     /// in order, and constructs a new array from the results. callback is invoked
281     /// only for indexes of the array which have assigned values, including undefined.
282     /// It is not called for missing elements of the array (that is, indexes that have
283     /// never been set, which have been deleted or which have never been assigned a value).
284     ///
285     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map)
286     #[wasm_bindgen(method)]
map(this: &Array, predicate: &mut dyn FnMut(JsValue, u32, Array) -> JsValue) -> Array287     pub fn map(this: &Array, predicate: &mut dyn FnMut(JsValue, u32, Array) -> JsValue) -> Array;
288 
289     /// The `Array.of()` method creates a new Array instance with a variable
290     /// number of arguments, regardless of number or type of the arguments.
291     ///
292     /// The difference between `Array.of()` and the `Array` constructor is in the
293     /// handling of integer arguments: `Array.of(7)` creates an array with a single
294     /// element, `7`, whereas `Array(7)` creates an empty array with a `length`
295     /// property of `7` (Note: this implies an array of 7 empty slots, not slots
296     /// with actual undefined values).
297     ///
298     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/of)
299     ///
300     /// # Notes
301     ///
302     /// There are a few bindings to `of` in `js-sys`: `of1`, `of2`, etc...
303     /// with different arities.
304     #[wasm_bindgen(static_method_of = Array, js_name = of)]
of1(a: &JsValue) -> Array305     pub fn of1(a: &JsValue) -> Array;
306 
307     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/of)
308     #[wasm_bindgen(static_method_of = Array, js_name = of)]
of2(a: &JsValue, b: &JsValue) -> Array309     pub fn of2(a: &JsValue, b: &JsValue) -> Array;
310 
311     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/of)
312     #[wasm_bindgen(static_method_of = Array, js_name = of)]
of3(a: &JsValue, b: &JsValue, c: &JsValue) -> Array313     pub fn of3(a: &JsValue, b: &JsValue, c: &JsValue) -> Array;
314 
315     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/of)
316     #[wasm_bindgen(static_method_of = Array, js_name = of)]
of4(a: &JsValue, b: &JsValue, c: &JsValue, d: &JsValue) -> Array317     pub fn of4(a: &JsValue, b: &JsValue, c: &JsValue, d: &JsValue) -> Array;
318 
319     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/of)
320     #[wasm_bindgen(static_method_of = Array, js_name = of)]
of5(a: &JsValue, b: &JsValue, c: &JsValue, d: &JsValue, e: &JsValue) -> Array321     pub fn of5(a: &JsValue, b: &JsValue, c: &JsValue, d: &JsValue, e: &JsValue) -> Array;
322 
323     /// The `pop()` method removes the last element from an array and returns that
324     /// element. This method changes the length of the array.
325     ///
326     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/pop)
327     #[wasm_bindgen(method)]
pop(this: &Array) -> JsValue328     pub fn pop(this: &Array) -> JsValue;
329 
330     /// The `push()` method adds one or more elements to the end of an array and
331     /// returns the new length of the array.
332     ///
333     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push)
334     #[wasm_bindgen(method)]
push(this: &Array, value: &JsValue) -> u32335     pub fn push(this: &Array, value: &JsValue) -> u32;
336 
337     /// The `reduce()` method applies a function against an accumulator and each element in
338     /// the array (from left to right) to reduce it to a single value.
339     ///
340     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce)
341     #[wasm_bindgen(method)]
reduce( this: &Array, predicate: &mut dyn FnMut(JsValue, JsValue, u32, Array) -> JsValue, initial_value: &JsValue, ) -> JsValue342     pub fn reduce(
343         this: &Array,
344         predicate: &mut dyn FnMut(JsValue, JsValue, u32, Array) -> JsValue,
345         initial_value: &JsValue,
346     ) -> JsValue;
347 
348     /// The `reduceRight()` method applies a function against an accumulator and each value
349     /// of the array (from right-to-left) to reduce it to a single value.
350     ///
351     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/ReduceRight)
352     #[wasm_bindgen(method, js_name = reduceRight)]
reduce_right( this: &Array, predicate: &mut dyn FnMut(JsValue, JsValue, u32, Array) -> JsValue, initial_value: &JsValue, ) -> JsValue353     pub fn reduce_right(
354         this: &Array,
355         predicate: &mut dyn FnMut(JsValue, JsValue, u32, Array) -> JsValue,
356         initial_value: &JsValue,
357     ) -> JsValue;
358 
359     /// The `reverse()` method reverses an array in place. The first array
360     /// element becomes the last, and the last array element becomes the first.
361     ///
362     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse)
363     #[wasm_bindgen(method)]
reverse(this: &Array) -> Array364     pub fn reverse(this: &Array) -> Array;
365 
366     /// The `shift()` method removes the first element from an array and returns
367     /// that removed element. This method changes the length of the array.
368     ///
369     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/shift)
370     #[wasm_bindgen(method)]
shift(this: &Array) -> JsValue371     pub fn shift(this: &Array) -> JsValue;
372 
373     /// The `slice()` method returns a shallow copy of a portion of an array into
374     /// a new array object selected from begin to end (end not included).
375     /// The original array will not be modified.
376     ///
377     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice)
378     #[wasm_bindgen(method)]
slice(this: &Array, start: u32, end: u32) -> Array379     pub fn slice(this: &Array, start: u32, end: u32) -> Array;
380 
381     /// The `some()` method tests whether at least one element in the array passes the test implemented
382     /// by the provided function.
383     /// Note: This method returns false for any condition put on an empty array.
384     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some)
385     #[wasm_bindgen(method)]
some(this: &Array, predicate: &mut dyn FnMut(JsValue) -> bool) -> bool386     pub fn some(this: &Array, predicate: &mut dyn FnMut(JsValue) -> bool) -> bool;
387 
388     /// The `sort()` method sorts the elements of an array in place and returns
389     /// the array. The sort is not necessarily stable. The default sort
390     /// order is according to string Unicode code points.
391     ///
392     /// The time and space complexity of the sort cannot be guaranteed as it
393     /// is implementation dependent.
394     ///
395     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort)
396     #[wasm_bindgen(method)]
sort(this: &Array) -> Array397     pub fn sort(this: &Array) -> Array;
398 
399     /// The `splice()` method changes the contents of an array by removing existing elements and/or
400     /// adding new elements.
401     ///
402     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice)
403     #[wasm_bindgen(method)]
splice(this: &Array, start: u32, delete_count: u32, item: &JsValue) -> Array404     pub fn splice(this: &Array, start: u32, delete_count: u32, item: &JsValue) -> Array;
405 
406     /// The `toLocaleString()` method returns a string representing the elements of the array.
407     /// The elements are converted to Strings using their toLocaleString methods and these
408     /// Strings are separated by a locale-specific String (such as a comma “,”).
409     ///
410     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toLocaleString)
411     #[wasm_bindgen(method, js_name = toLocaleString)]
to_locale_string(this: &Array, locales: &JsValue, options: &JsValue) -> JsString412     pub fn to_locale_string(this: &Array, locales: &JsValue, options: &JsValue) -> JsString;
413 
414     /// The `toString()` method returns a string representing the specified array
415     /// and its elements.
416     ///
417     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toString)
418     #[wasm_bindgen(method, js_name = toString)]
to_string(this: &Array) -> JsString419     pub fn to_string(this: &Array) -> JsString;
420 
421     /// The `unshift()` method adds one or more elements to the beginning of an
422     /// array and returns the new length of the array.
423     ///
424     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/unshift)
425     #[wasm_bindgen(method)]
unshift(this: &Array, value: &JsValue) -> u32426     pub fn unshift(this: &Array, value: &JsValue) -> u32;
427 }
428 
429 /// Iterator returned by `Array::iter`
430 #[derive(Debug, Clone)]
431 pub struct ArrayIter<'a> {
432     range: std::ops::Range<u32>,
433     array: &'a Array,
434 }
435 
436 impl<'a> std::iter::Iterator for ArrayIter<'a> {
437     type Item = JsValue;
438 
next(&mut self) -> Option<Self::Item>439     fn next(&mut self) -> Option<Self::Item> {
440         let index = self.range.next()?;
441         Some(self.array.get(index))
442     }
443 
444     #[inline]
size_hint(&self) -> (usize, Option<usize>)445     fn size_hint(&self) -> (usize, Option<usize>) {
446         self.range.size_hint()
447     }
448 }
449 
450 impl<'a> std::iter::DoubleEndedIterator for ArrayIter<'a> {
next_back(&mut self) -> Option<Self::Item>451     fn next_back(&mut self) -> Option<Self::Item> {
452         let index = self.range.next_back()?;
453         Some(self.array.get(index))
454     }
455 }
456 
457 impl<'a> std::iter::FusedIterator for ArrayIter<'a> {}
458 
459 impl<'a> std::iter::ExactSizeIterator for ArrayIter<'a> {}
460 
461 impl Array {
462     /// Returns an iterator over the values of the JS array.
iter(&self) -> ArrayIter<'_>463     pub fn iter(&self) -> ArrayIter<'_> {
464         ArrayIter {
465             range: 0..self.length(),
466             array: self,
467         }
468     }
469 
470     /// Converts the JS array into a new Vec.
to_vec(&self) -> Vec<JsValue>471     pub fn to_vec(&self) -> Vec<JsValue> {
472         let len = self.length();
473 
474         let mut output = Vec::with_capacity(len as usize);
475 
476         for i in 0..len {
477             output.push(self.get(i));
478         }
479 
480         output
481     }
482 }
483 
484 // TODO pre-initialize the Array with the correct length using TrustedLen
485 impl<A> std::iter::FromIterator<A> for Array
486 where
487     A: AsRef<JsValue>,
488 {
from_iter<T>(iter: T) -> Array where T: IntoIterator<Item = A>,489     fn from_iter<T>(iter: T) -> Array
490     where
491         T: IntoIterator<Item = A>,
492     {
493         let out = Array::new();
494 
495         for value in iter {
496             out.push(value.as_ref());
497         }
498 
499         out
500     }
501 }
502 
503 // ArrayBuffer
504 #[wasm_bindgen]
505 extern "C" {
506     #[wasm_bindgen(extends = Object, typescript_type = "ArrayBuffer")]
507     #[derive(Clone, Debug, PartialEq, Eq)]
508     pub type ArrayBuffer;
509 
510     /// The `ArrayBuffer` object is used to represent a generic,
511     /// fixed-length raw binary data buffer. You cannot directly
512     /// manipulate the contents of an `ArrayBuffer`; instead, you
513     /// create one of the typed array objects or a `DataView` object
514     /// which represents the buffer in a specific format, and use that
515     /// to read and write the contents of the buffer.
516     ///
517     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer)
518     #[wasm_bindgen(constructor)]
new(length: u32) -> ArrayBuffer519     pub fn new(length: u32) -> ArrayBuffer;
520 
521     /// The byteLength property of an object which is an instance of type ArrayBuffer
522     /// it's an accessor property whose set accessor function is undefined,
523     /// meaning that you can only read this property.
524     /// The value is established when the array is constructed and cannot be changed.
525     /// This property returns 0 if this ArrayBuffer has been detached.
526     ///
527     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/byteLength)
528     #[wasm_bindgen(method, getter, js_name = byteLength)]
byte_length(this: &ArrayBuffer) -> u32529     pub fn byte_length(this: &ArrayBuffer) -> u32;
530 
531     /// The `isView()` method returns true if arg is one of the `ArrayBuffer`
532     /// views, such as typed array objects or a DataView; false otherwise.
533     ///
534     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/isView)
535     #[wasm_bindgen(static_method_of = ArrayBuffer, js_name = isView)]
is_view(value: &JsValue) -> bool536     pub fn is_view(value: &JsValue) -> bool;
537 
538     /// The `slice()` method returns a new `ArrayBuffer` whose contents
539     /// are a copy of this `ArrayBuffer`'s bytes from begin, inclusive,
540     /// up to end, exclusive.
541     ///
542     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/slice)
543     #[wasm_bindgen(method)]
slice(this: &ArrayBuffer, begin: u32) -> ArrayBuffer544     pub fn slice(this: &ArrayBuffer, begin: u32) -> ArrayBuffer;
545 
546     /// Like `slice()` but with the `end` argument.
547     ///
548     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/slice)
549     #[wasm_bindgen(method, js_name = slice)]
slice_with_end(this: &ArrayBuffer, begin: u32, end: u32) -> ArrayBuffer550     pub fn slice_with_end(this: &ArrayBuffer, begin: u32, end: u32) -> ArrayBuffer;
551 }
552 
553 // SharedArrayBuffer
554 #[wasm_bindgen]
555 extern "C" {
556     #[wasm_bindgen(extends = Object, typescript_type = "SharedArrayBuffer")]
557     #[derive(Clone, Debug)]
558     pub type SharedArrayBuffer;
559 
560     /// The `SharedArrayBuffer` object is used to represent a generic,
561     /// fixed-length raw binary data buffer, similar to the `ArrayBuffer`
562     /// object, but in a way that they can be used to create views
563     /// on shared memory. Unlike an `ArrayBuffer`, a `SharedArrayBuffer`
564     /// cannot become detached.
565     ///
566     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer)
567     #[wasm_bindgen(constructor)]
new(length: u32) -> SharedArrayBuffer568     pub fn new(length: u32) -> SharedArrayBuffer;
569 
570     /// The byteLength accessor property represents the length of
571     /// an `SharedArrayBuffer` in bytes. This is established when
572     /// the `SharedArrayBuffer` is constructed and cannot be changed.
573     ///
574     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/byteLength)
575     #[wasm_bindgen(method, getter, js_name = byteLength)]
byte_length(this: &SharedArrayBuffer) -> u32576     pub fn byte_length(this: &SharedArrayBuffer) -> u32;
577 
578     /// The `slice()` method returns a new `SharedArrayBuffer` whose contents
579     /// are a copy of this `SharedArrayBuffer`'s bytes from begin, inclusive,
580     /// up to end, exclusive.
581     ///
582     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/slice)
583     #[wasm_bindgen(method)]
slice(this: &SharedArrayBuffer, begin: u32) -> SharedArrayBuffer584     pub fn slice(this: &SharedArrayBuffer, begin: u32) -> SharedArrayBuffer;
585 
586     /// Like `slice()` but with the `end` argument.
587     ///
588     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/slice)
589     #[wasm_bindgen(method, js_name = slice)]
slice_with_end(this: &SharedArrayBuffer, begin: u32, end: u32) -> SharedArrayBuffer590     pub fn slice_with_end(this: &SharedArrayBuffer, begin: u32, end: u32) -> SharedArrayBuffer;
591 }
592 
593 // Array Iterator
594 #[wasm_bindgen]
595 extern "C" {
596     /// The `keys()` method returns a new Array Iterator object that contains the
597     /// keys for each index in the array.
598     ///
599     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/keys)
600     #[wasm_bindgen(method)]
keys(this: &Array) -> Iterator601     pub fn keys(this: &Array) -> Iterator;
602 
603     /// The `entries()` method returns a new Array Iterator object that contains
604     /// the key/value pairs for each index in the array.
605     ///
606     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/entries)
607     #[wasm_bindgen(method)]
entries(this: &Array) -> Iterator608     pub fn entries(this: &Array) -> Iterator;
609 
610     /// The `values()` method returns a new Array Iterator object that
611     /// contains the values for each index in the array.
612     ///
613     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/values)
614     #[wasm_bindgen(method)]
values(this: &Array) -> Iterator615     pub fn values(this: &Array) -> Iterator;
616 }
617 
618 /// The `Atomics` object provides atomic operations as static methods.
619 /// They are used with `SharedArrayBuffer` objects.
620 ///
621 /// The Atomic operations are installed on an `Atomics` module. Unlike
622 /// the other global objects, `Atomics` is not a constructor. You cannot
623 /// use it with a new operator or invoke the `Atomics` object as a
624 /// function. All properties and methods of `Atomics` are static
625 /// (as is the case with the Math object, for example).
626 /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics)
627 #[allow(non_snake_case)]
628 pub mod Atomics {
629     use super::*;
630 
631     #[wasm_bindgen]
632     extern "C" {
633         /// The static `Atomics.add()` method adds a given value at a given
634         /// position in the array and returns the old value at that position.
635         /// This atomic operation guarantees that no other write happens
636         /// until the modified value is written back.
637         ///
638         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/add)
639         #[wasm_bindgen(js_namespace = Atomics, catch)]
add(typed_array: &JsValue, index: u32, value: i32) -> Result<i32, JsValue>640         pub fn add(typed_array: &JsValue, index: u32, value: i32) -> Result<i32, JsValue>;
641 
642         /// The static `Atomics.and()` method computes a bitwise AND with a given
643         /// value at a given position in the array, and returns the old value
644         /// at that position.
645         /// This atomic operation guarantees that no other write happens
646         /// until the modified value is written back.
647         ///
648         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/and)
649         #[wasm_bindgen(js_namespace = Atomics, catch)]
and(typed_array: &JsValue, index: u32, value: i32) -> Result<i32, JsValue>650         pub fn and(typed_array: &JsValue, index: u32, value: i32) -> Result<i32, JsValue>;
651 
652         /// The static `Atomics.compareExchange()` method exchanges a given
653         /// replacement value at a given position in the array, if a given expected
654         /// value equals the old value. It returns the old value at that position
655         /// whether it was equal to the expected value or not.
656         /// This atomic operation guarantees that no other write happens
657         /// until the modified value is written back.
658         ///
659         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/compareExchange)
660         #[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>661         pub fn compare_exchange(
662             typed_array: &JsValue,
663             index: u32,
664             expected_value: i32,
665             replacement_value: i32,
666         ) -> Result<i32, JsValue>;
667 
668         /// The static `Atomics.exchange()` method stores a given value at a given
669         /// position in the array and returns the old value at that position.
670         /// This atomic operation guarantees that no other write happens
671         /// until the modified value is written back.
672         ///
673         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/exchange)
674         #[wasm_bindgen(js_namespace = Atomics, catch)]
exchange(typed_array: &JsValue, index: u32, value: i32) -> Result<i32, JsValue>675         pub fn exchange(typed_array: &JsValue, index: u32, value: i32) -> Result<i32, JsValue>;
676 
677         /// The static `Atomics.isLockFree()` method is used to determine
678         /// whether to use locks or atomic operations. It returns true,
679         /// if the given size is one of the `BYTES_PER_ELEMENT` property
680         /// of integer `TypedArray` types.
681         ///
682         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/isLockFree)
683         #[wasm_bindgen(js_namespace = Atomics, js_name = isLockFree)]
is_lock_free(size: u32) -> bool684         pub fn is_lock_free(size: u32) -> bool;
685 
686         /// The static `Atomics.load()` method returns a value at a given
687         /// position in the array.
688         ///
689         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/load)
690         #[wasm_bindgen(js_namespace = Atomics, catch)]
load(typed_array: &JsValue, index: u32) -> Result<i32, JsValue>691         pub fn load(typed_array: &JsValue, index: u32) -> Result<i32, JsValue>;
692 
693         /// The static `Atomics.notify()` method notifies up some agents that
694         /// are sleeping in the wait queue.
695         /// Note: This operation works with a shared `Int32Array` only.
696         /// If `count` is not provided, notifies all the agents in the queue.
697         ///
698         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/notify)
699         #[wasm_bindgen(js_namespace = Atomics, catch)]
notify(typed_array: &Int32Array, index: u32) -> Result<u32, JsValue>700         pub fn notify(typed_array: &Int32Array, index: u32) -> Result<u32, JsValue>;
701 
702         /// Notifies up to `count` agents in the wait queue.
703         #[wasm_bindgen(js_namespace = Atomics, catch, js_name = notify)]
notify_with_count( typed_array: &Int32Array, index: u32, count: u32, ) -> Result<u32, JsValue>704         pub fn notify_with_count(
705             typed_array: &Int32Array,
706             index: u32,
707             count: u32,
708         ) -> Result<u32, JsValue>;
709 
710         /// The static `Atomics.or()` method computes a bitwise OR with a given value
711         /// at a given position in the array, and returns the old value at that position.
712         /// This atomic operation guarantees that no other write happens
713         /// until the modified value is written back.
714         ///
715         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/or)
716         #[wasm_bindgen(js_namespace = Atomics, catch)]
or(typed_array: &JsValue, index: u32, value: i32) -> Result<i32, JsValue>717         pub fn or(typed_array: &JsValue, index: u32, value: i32) -> Result<i32, JsValue>;
718 
719         /// The static `Atomics.store()` method stores a given value at the given
720         /// position in the array and returns that value.
721         ///
722         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/store)
723         #[wasm_bindgen(js_namespace = Atomics, catch)]
store(typed_array: &JsValue, index: u32, value: i32) -> Result<i32, JsValue>724         pub fn store(typed_array: &JsValue, index: u32, value: i32) -> Result<i32, JsValue>;
725 
726         /// The static `Atomics.sub()` method substracts a given value at a
727         /// given position in the array and returns the old value at that position.
728         /// This atomic operation guarantees that no other write happens
729         /// until the modified value is written back.
730         ///
731         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/sub)
732         #[wasm_bindgen(js_namespace = Atomics, catch)]
sub(typed_array: &JsValue, index: u32, value: i32) -> Result<i32, JsValue>733         pub fn sub(typed_array: &JsValue, index: u32, value: i32) -> Result<i32, JsValue>;
734 
735         /// The static `Atomics.wait()` method verifies that a given
736         /// position in an `Int32Array` still contains a given value
737         /// and if so sleeps, awaiting a wakeup or a timeout.
738         /// It returns a string which is either "ok", "not-equal", or "timed-out".
739         /// Note: This operation only works with a shared `Int32Array`
740         /// and may not be allowed on the main thread.
741         ///
742         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/wait)
743         #[wasm_bindgen(js_namespace = Atomics, catch)]
wait(typed_array: &Int32Array, index: u32, value: i32) -> Result<JsString, JsValue>744         pub fn wait(typed_array: &Int32Array, index: u32, value: i32) -> Result<JsString, JsValue>;
745 
746         /// Like `wait()`, but with timeout
747         ///
748         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/wait)
749         #[wasm_bindgen(js_namespace = Atomics, catch, js_name = wait)]
wait_with_timeout( typed_array: &Int32Array, index: u32, value: i32, timeout: f64, ) -> Result<JsString, JsValue>750         pub fn wait_with_timeout(
751             typed_array: &Int32Array,
752             index: u32,
753             value: i32,
754             timeout: f64,
755         ) -> Result<JsString, JsValue>;
756 
757         /// The static `Atomics.xor()` method computes a bitwise XOR
758         /// with a given value at a given position in the array,
759         /// and returns the old value at that position.
760         /// This atomic operation guarantees that no other write happens
761         /// until the modified value is written back.
762         ///
763         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/xor)
764         #[wasm_bindgen(js_namespace = Atomics, catch)]
xor(typed_array: &JsValue, index: u32, value: i32) -> Result<i32, JsValue>765         pub fn xor(typed_array: &JsValue, index: u32, value: i32) -> Result<i32, JsValue>;
766     }
767 }
768 
769 // Boolean
770 #[wasm_bindgen]
771 extern "C" {
772     #[wasm_bindgen(extends = Object, is_type_of = |v| v.as_bool().is_some(), typescript_type = "boolean")]
773     #[derive(Clone, PartialEq, Eq)]
774     pub type Boolean;
775 
776     /// The `Boolean()` constructor creates an object wrapper for a boolean value.
777     ///
778     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)
779     #[wasm_bindgen(constructor)]
780     #[deprecated(note = "recommended to use `Boolean::from` instead")]
781     #[allow(deprecated)]
new(value: &JsValue) -> Boolean782     pub fn new(value: &JsValue) -> Boolean;
783 
784     /// The `valueOf()` method returns the primitive value of a `Boolean` object.
785     ///
786     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean/valueOf)
787     #[wasm_bindgen(method, js_name = valueOf)]
value_of(this: &Boolean) -> bool788     pub fn value_of(this: &Boolean) -> bool;
789 }
790 
791 impl From<bool> for Boolean {
792     #[inline]
from(b: bool) -> Boolean793     fn from(b: bool) -> Boolean {
794         Boolean::unchecked_from_js(JsValue::from(b))
795     }
796 }
797 
798 impl From<Boolean> for bool {
799     #[inline]
from(b: Boolean) -> bool800     fn from(b: Boolean) -> bool {
801         b.value_of()
802     }
803 }
804 
805 impl PartialEq<bool> for Boolean {
806     #[inline]
eq(&self, other: &bool) -> bool807     fn eq(&self, other: &bool) -> bool {
808         self.value_of() == *other
809     }
810 }
811 
812 impl fmt::Debug for Boolean {
fmt(&self, f: &mut fmt::Formatter) -> fmt::Result813     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
814         self.value_of().fmt(f)
815     }
816 }
817 
818 // DataView
819 #[wasm_bindgen]
820 extern "C" {
821     #[wasm_bindgen(extends = Object, typescript_type = "DataView")]
822     #[derive(Clone, Debug, PartialEq, Eq)]
823     pub type DataView;
824 
825     /// The `DataView` view provides a low-level interface for reading and
826     /// writing multiple number types in an `ArrayBuffer` irrespective of the
827     /// platform's endianness.
828     ///
829     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView)
830     #[wasm_bindgen(constructor)]
new(buffer: &ArrayBuffer, byteOffset: usize, byteLength: usize) -> DataView831     pub fn new(buffer: &ArrayBuffer, byteOffset: usize, byteLength: usize) -> DataView;
832 
833     /// The ArrayBuffer referenced by this view. Fixed at construction time and thus read only.
834     ///
835     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/buffer)
836     #[wasm_bindgen(method, getter, structural)]
buffer(this: &DataView) -> ArrayBuffer837     pub fn buffer(this: &DataView) -> ArrayBuffer;
838 
839     /// The length (in bytes) of this view from the start of its ArrayBuffer.
840     /// Fixed at construction time and thus read only.
841     ///
842     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/byteLength)
843     #[wasm_bindgen(method, getter, structural, js_name = byteLength)]
byte_length(this: &DataView) -> usize844     pub fn byte_length(this: &DataView) -> usize;
845 
846     /// The offset (in bytes) of this view from the start of its ArrayBuffer.
847     /// Fixed at construction time and thus read only.
848     ///
849     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/byteOffset)
850     #[wasm_bindgen(method, getter, structural, js_name = byteOffset)]
byte_offset(this: &DataView) -> usize851     pub fn byte_offset(this: &DataView) -> usize;
852 
853     /// The `getInt8()` method gets a signed 8-bit integer (byte) at the
854     /// specified byte offset from the start of the DataView.
855     ///
856     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getInt8)
857     #[wasm_bindgen(method, js_name = getInt8)]
get_int8(this: &DataView, byte_offset: usize) -> i8858     pub fn get_int8(this: &DataView, byte_offset: usize) -> i8;
859 
860     /// The `getUint8()` method gets a unsigned 8-bit integer (byte) at the specified
861     /// byte offset from the start of the DataView.
862     ///
863     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getUint8)
864     #[wasm_bindgen(method, js_name = getUint8)]
get_uint8(this: &DataView, byte_offset: usize) -> u8865     pub fn get_uint8(this: &DataView, byte_offset: usize) -> u8;
866 
867     /// The `getInt16()` method gets a signed 16-bit integer (short) at the specified
868     /// byte offset from the start of the DataView.
869     ///
870     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getInt16)
871     #[wasm_bindgen(method, js_name = getInt16)]
get_int16(this: &DataView, byte_offset: usize) -> i16872     pub fn get_int16(this: &DataView, byte_offset: usize) -> i16;
873 
874     /// The `getInt16()` method gets a signed 16-bit integer (short) at the specified
875     /// byte offset from the start of the DataView.
876     ///
877     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getInt16)
878     #[wasm_bindgen(method, js_name = getInt16)]
get_int16_endian(this: &DataView, byte_offset: usize, little_endian: bool) -> i16879     pub fn get_int16_endian(this: &DataView, byte_offset: usize, little_endian: bool) -> i16;
880 
881     /// The `getUint16()` method gets an unsigned 16-bit integer (unsigned short) at the specified
882     /// byte offset from the start of the view.
883     ///
884     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getUint16)
885     #[wasm_bindgen(method, js_name = getUint16)]
get_uint16(this: &DataView, byte_offset: usize) -> u16886     pub fn get_uint16(this: &DataView, byte_offset: usize) -> u16;
887 
888     /// The `getUint16()` method gets an unsigned 16-bit integer (unsigned short) at the specified
889     /// byte offset from the start of the view.
890     ///
891     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getUint16)
892     #[wasm_bindgen(method, js_name = getUint16)]
get_uint16_endian(this: &DataView, byte_offset: usize, little_endian: bool) -> u16893     pub fn get_uint16_endian(this: &DataView, byte_offset: usize, little_endian: bool) -> u16;
894 
895     /// The `getInt32()` method gets a signed 32-bit integer (long) at the specified
896     /// byte offset from the start of the DataView.
897     ///
898     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getInt32)
899     #[wasm_bindgen(method, js_name = getInt32)]
get_int32(this: &DataView, byte_offset: usize) -> i32900     pub fn get_int32(this: &DataView, byte_offset: usize) -> i32;
901 
902     /// The `getInt32()` method gets a signed 32-bit integer (long) at the specified
903     /// byte offset from the start of the DataView.
904     ///
905     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getInt32)
906     #[wasm_bindgen(method, js_name = getInt32)]
get_int32_endian(this: &DataView, byte_offset: usize, little_endian: bool) -> i32907     pub fn get_int32_endian(this: &DataView, byte_offset: usize, little_endian: bool) -> i32;
908 
909     /// The `getUint32()` method gets an unsigned 32-bit integer (unsigned long) at the specified
910     /// byte offset from the start of the view.
911     ///
912     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getUint32)
913     #[wasm_bindgen(method, js_name = getUint32)]
get_uint32(this: &DataView, byte_offset: usize) -> u32914     pub fn get_uint32(this: &DataView, byte_offset: usize) -> u32;
915 
916     /// The `getUint32()` method gets an unsigned 32-bit integer (unsigned long) at the specified
917     /// byte offset from the start of the view.
918     ///
919     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getUint32)
920     #[wasm_bindgen(method, js_name = getUint32)]
get_uint32_endian(this: &DataView, byte_offset: usize, little_endian: bool) -> u32921     pub fn get_uint32_endian(this: &DataView, byte_offset: usize, little_endian: bool) -> u32;
922 
923     /// The `getFloat32()` method gets a signed 32-bit float (float) at the specified
924     /// byte offset from the start of the DataView.
925     ///
926     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getFloat32)
927     #[wasm_bindgen(method, js_name = getFloat32)]
get_float32(this: &DataView, byte_offset: usize) -> f32928     pub fn get_float32(this: &DataView, byte_offset: usize) -> f32;
929 
930     /// The `getFloat32()` method gets a signed 32-bit float (float) at the specified
931     /// byte offset from the start of the DataView.
932     ///
933     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getFloat32)
934     #[wasm_bindgen(method, js_name = getFloat32)]
get_float32_endian(this: &DataView, byte_offset: usize, little_endian: bool) -> f32935     pub fn get_float32_endian(this: &DataView, byte_offset: usize, little_endian: bool) -> f32;
936 
937     /// The `getFloat64()` method gets a signed 64-bit float (double) at the specified
938     /// byte offset from the start of the DataView.
939     ///
940     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getFloat64)
941     #[wasm_bindgen(method, js_name = getFloat64)]
get_float64(this: &DataView, byte_offset: usize) -> f64942     pub fn get_float64(this: &DataView, byte_offset: usize) -> f64;
943 
944     /// The `getFloat64()` method gets a signed 64-bit float (double) at the specified
945     /// byte offset from the start of the DataView.
946     ///
947     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getFloat64)
948     #[wasm_bindgen(method, js_name = getFloat64)]
get_float64_endian(this: &DataView, byte_offset: usize, little_endian: bool) -> f64949     pub fn get_float64_endian(this: &DataView, byte_offset: usize, little_endian: bool) -> f64;
950 
951     /// The `setInt8()` method stores a signed 8-bit integer (byte) value at the
952     /// specified byte offset from the start of the DataView.
953     ///
954     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setInt8)
955     #[wasm_bindgen(method, js_name = setInt8)]
set_int8(this: &DataView, byte_offset: usize, value: i8)956     pub fn set_int8(this: &DataView, byte_offset: usize, value: i8);
957 
958     /// The `setUint8()` method stores an unsigned 8-bit integer (byte) value at the
959     /// specified byte offset from the start of the DataView.
960     ///
961     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setUint8)
962     #[wasm_bindgen(method, js_name = setUint8)]
set_uint8(this: &DataView, byte_offset: usize, value: u8)963     pub fn set_uint8(this: &DataView, byte_offset: usize, value: u8);
964 
965     /// The `setInt16()` method stores a signed 16-bit integer (short) value at the
966     /// specified byte offset from the start of the DataView.
967     ///
968     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setInt16)
969     #[wasm_bindgen(method, js_name = setInt16)]
set_int16(this: &DataView, byte_offset: usize, value: i16)970     pub fn set_int16(this: &DataView, byte_offset: usize, value: i16);
971 
972     /// The `setInt16()` method stores a signed 16-bit integer (short) value at the
973     /// specified byte offset from the start of the DataView.
974     ///
975     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setInt16)
976     #[wasm_bindgen(method, js_name = setInt16)]
set_int16_endian(this: &DataView, byte_offset: usize, value: i16, little_endian: bool)977     pub fn set_int16_endian(this: &DataView, byte_offset: usize, value: i16, little_endian: bool);
978 
979     /// The `setUint16()` method stores an unsigned 16-bit integer (unsigned short) value at the
980     /// specified byte offset from the start of the DataView.
981     ///
982     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setUint16)
983     #[wasm_bindgen(method, js_name = setUint16)]
set_uint16(this: &DataView, byte_offset: usize, value: u16)984     pub fn set_uint16(this: &DataView, byte_offset: usize, value: u16);
985 
986     /// The `setUint16()` method stores an unsigned 16-bit integer (unsigned short) value at the
987     /// specified byte offset from the start of the DataView.
988     ///
989     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setUint16)
990     #[wasm_bindgen(method, js_name = setUint16)]
set_uint16_endian(this: &DataView, byte_offset: usize, value: u16, little_endian: bool)991     pub fn set_uint16_endian(this: &DataView, byte_offset: usize, value: u16, little_endian: bool);
992 
993     /// The `setInt32()` method stores a signed 32-bit integer (long) value at the
994     /// specified byte offset from the start of the DataView.
995     ///
996     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setInt32)
997     #[wasm_bindgen(method, js_name = setInt32)]
set_int32(this: &DataView, byte_offset: usize, value: i32)998     pub fn set_int32(this: &DataView, byte_offset: usize, value: i32);
999 
1000     /// The `setInt32()` method stores a signed 32-bit integer (long) value at the
1001     /// specified byte offset from the start of the DataView.
1002     ///
1003     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setInt32)
1004     #[wasm_bindgen(method, js_name = setInt32)]
set_int32_endian(this: &DataView, byte_offset: usize, value: i32, little_endian: bool)1005     pub fn set_int32_endian(this: &DataView, byte_offset: usize, value: i32, little_endian: bool);
1006 
1007     /// The `setUint32()` method stores an unsigned 32-bit integer (unsigned long) value at the
1008     /// specified byte offset from the start of the DataView.
1009     ///
1010     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setUint32)
1011     #[wasm_bindgen(method, js_name = setUint32)]
set_uint32(this: &DataView, byte_offset: usize, value: u32)1012     pub fn set_uint32(this: &DataView, byte_offset: usize, value: u32);
1013 
1014     /// The `setUint32()` method stores an unsigned 32-bit integer (unsigned long) value at the
1015     /// specified byte offset from the start of the DataView.
1016     ///
1017     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setUint32)
1018     #[wasm_bindgen(method, js_name = setUint32)]
set_uint32_endian(this: &DataView, byte_offset: usize, value: u32, little_endian: bool)1019     pub fn set_uint32_endian(this: &DataView, byte_offset: usize, value: u32, little_endian: bool);
1020 
1021     /// The `setFloat32()` method stores a signed 32-bit float (float) value at the
1022     /// specified byte offset from the start of the DataView.
1023     ///
1024     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setFloat32)
1025     #[wasm_bindgen(method, js_name = setFloat32)]
set_float32(this: &DataView, byte_offset: usize, value: f32)1026     pub fn set_float32(this: &DataView, byte_offset: usize, value: f32);
1027 
1028     /// The `setFloat32()` method stores a signed 32-bit float (float) value at the
1029     /// specified byte offset from the start of the DataView.
1030     ///
1031     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setFloat32)
1032     #[wasm_bindgen(method, js_name = setFloat32)]
set_float32_endian(this: &DataView, byte_offset: usize, value: f32, little_endian: bool)1033     pub fn set_float32_endian(this: &DataView, byte_offset: usize, value: f32, little_endian: bool);
1034 
1035     /// The `setFloat64()` method stores a signed 64-bit float (double) value at the
1036     /// specified byte offset from the start of the DataView.
1037     ///
1038     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setFloat64)
1039     #[wasm_bindgen(method, js_name = setFloat64)]
set_float64(this: &DataView, byte_offset: usize, value: f64)1040     pub fn set_float64(this: &DataView, byte_offset: usize, value: f64);
1041 
1042     /// The `setFloat64()` method stores a signed 64-bit float (double) value at the
1043     /// specified byte offset from the start of the DataView.
1044     ///
1045     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setFloat64)
1046     #[wasm_bindgen(method, js_name = setFloat64)]
set_float64_endian(this: &DataView, byte_offset: usize, value: f64, little_endian: bool)1047     pub fn set_float64_endian(this: &DataView, byte_offset: usize, value: f64, little_endian: bool);
1048 }
1049 
1050 // Error
1051 #[wasm_bindgen]
1052 extern "C" {
1053     #[wasm_bindgen(extends = Object, typescript_type = "Error")]
1054     #[derive(Clone, Debug, PartialEq, Eq)]
1055     pub type Error;
1056 
1057     /// The Error constructor creates an error object.
1058     /// Instances of Error objects are thrown when runtime errors occur.
1059     /// The Error object can also be used as a base object for user-defined exceptions.
1060     /// See below for standard built-in error types.
1061     ///
1062     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error)
1063     #[wasm_bindgen(constructor)]
new(message: &str) -> Error1064     pub fn new(message: &str) -> Error;
1065 
1066     /// The message property is a human-readable description of the error.
1067     ///
1068     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/message)
1069     #[wasm_bindgen(method, getter, structural)]
message(this: &Error) -> JsString1070     pub fn message(this: &Error) -> JsString;
1071     #[wasm_bindgen(method, setter, structural)]
set_message(this: &Error, message: &str)1072     pub fn set_message(this: &Error, message: &str);
1073 
1074     /// The name property represents a name for the type of error. The initial value is "Error".
1075     ///
1076     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/name)
1077     #[wasm_bindgen(method, getter, structural)]
name(this: &Error) -> JsString1078     pub fn name(this: &Error) -> JsString;
1079     #[wasm_bindgen(method, setter, structural)]
set_name(this: &Error, name: &str)1080     pub fn set_name(this: &Error, name: &str);
1081 
1082     /// The `toString()` method returns a string representing the specified Error object
1083     ///
1084     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/toString)
1085     #[wasm_bindgen(method, js_name = toString)]
to_string(this: &Error) -> JsString1086     pub fn to_string(this: &Error) -> JsString;
1087 }
1088 
1089 // EvalError
1090 #[wasm_bindgen]
1091 extern "C" {
1092     #[wasm_bindgen(extends = Object, extends = Error, typescript_type = "EvalError")]
1093     #[derive(Clone, Debug, PartialEq, Eq)]
1094     pub type EvalError;
1095 
1096     /// The EvalError object indicates an error regarding the global eval() function. This
1097     /// exception is not thrown by JavaScript anymore, however the EvalError object remains for
1098     /// compatibility.
1099     ///
1100     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError)
1101     #[wasm_bindgen(constructor)]
new(message: &str) -> EvalError1102     pub fn new(message: &str) -> EvalError;
1103 }
1104 
1105 // Function
1106 #[wasm_bindgen]
1107 extern "C" {
1108     #[wasm_bindgen(extends = Object, is_type_of = JsValue::is_function, typescript_type = "Function")]
1109     #[derive(Clone, Debug, PartialEq, Eq)]
1110     pub type Function;
1111 
1112     /// The `Function` constructor creates a new `Function` object. Calling the
1113     /// constructor directly can create functions dynamically, but suffers from
1114     /// security and similar (but far less significant) performance issues
1115     /// similar to `eval`. However, unlike `eval`, the `Function` constructor
1116     /// allows executing code in the global scope, prompting better programming
1117     /// habits and allowing for more efficient code minification.
1118     ///
1119     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function)
1120     #[wasm_bindgen(constructor)]
new_with_args(args: &str, body: &str) -> Function1121     pub fn new_with_args(args: &str, body: &str) -> Function;
1122 
1123     /// The `Function` constructor creates a new `Function` object. Calling the
1124     /// constructor directly can create functions dynamically, but suffers from
1125     /// security and similar (but far less significant) performance issues
1126     /// similar to `eval`. However, unlike `eval`, the `Function` constructor
1127     /// allows executing code in the global scope, prompting better programming
1128     /// habits and allowing for more efficient code minification.
1129     ///
1130     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function)
1131     #[wasm_bindgen(constructor)]
new_no_args(body: &str) -> Function1132     pub fn new_no_args(body: &str) -> Function;
1133 
1134     /// The `apply()` method calls a function with a given this value, and arguments provided as an array
1135     /// (or an array-like object).
1136     ///
1137     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/apply)
1138     #[wasm_bindgen(method, catch)]
apply(this: &Function, context: &JsValue, args: &Array) -> Result<JsValue, JsValue>1139     pub fn apply(this: &Function, context: &JsValue, args: &Array) -> Result<JsValue, JsValue>;
1140 
1141     /// The `call()` method calls a function with a given this value and
1142     /// arguments provided individually.
1143     ///
1144     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
1145     #[wasm_bindgen(method, catch, js_name = call)]
call0(this: &Function, context: &JsValue) -> Result<JsValue, JsValue>1146     pub fn call0(this: &Function, context: &JsValue) -> Result<JsValue, JsValue>;
1147 
1148     /// The `call()` method calls a function with a given this value and
1149     /// arguments provided individually.
1150     ///
1151     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
1152     #[wasm_bindgen(method, catch, js_name = call)]
call1(this: &Function, context: &JsValue, arg1: &JsValue) -> Result<JsValue, JsValue>1153     pub fn call1(this: &Function, context: &JsValue, arg1: &JsValue) -> Result<JsValue, JsValue>;
1154 
1155     /// The `call()` method calls a function with a given this value and
1156     /// arguments provided individually.
1157     ///
1158     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
1159     #[wasm_bindgen(method, catch, js_name = call)]
call2( this: &Function, context: &JsValue, arg1: &JsValue, arg2: &JsValue, ) -> Result<JsValue, JsValue>1160     pub fn call2(
1161         this: &Function,
1162         context: &JsValue,
1163         arg1: &JsValue,
1164         arg2: &JsValue,
1165     ) -> Result<JsValue, JsValue>;
1166 
1167     /// The `call()` method calls a function with a given this value and
1168     /// arguments provided individually.
1169     ///
1170     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
1171     #[wasm_bindgen(method, catch, js_name = call)]
call3( this: &Function, context: &JsValue, arg1: &JsValue, arg2: &JsValue, arg3: &JsValue, ) -> Result<JsValue, JsValue>1172     pub fn call3(
1173         this: &Function,
1174         context: &JsValue,
1175         arg1: &JsValue,
1176         arg2: &JsValue,
1177         arg3: &JsValue,
1178     ) -> Result<JsValue, JsValue>;
1179 
1180     /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
1181     /// with a given sequence of arguments preceding any provided when the new function is called.
1182     ///
1183     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
1184     #[wasm_bindgen(method, js_name = bind)]
bind(this: &Function, context: &JsValue) -> Function1185     pub fn bind(this: &Function, context: &JsValue) -> Function;
1186 
1187     /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
1188     /// with a given sequence of arguments preceding any provided when the new function is called.
1189     ///
1190     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
1191     #[wasm_bindgen(method, js_name = bind)]
bind0(this: &Function, context: &JsValue) -> Function1192     pub fn bind0(this: &Function, context: &JsValue) -> Function;
1193 
1194     /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
1195     /// with a given sequence of arguments preceding any provided when the new function is called.
1196     ///
1197     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
1198     #[wasm_bindgen(method, js_name = bind)]
bind1(this: &Function, context: &JsValue, arg1: &JsValue) -> Function1199     pub fn bind1(this: &Function, context: &JsValue, arg1: &JsValue) -> Function;
1200 
1201     /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
1202     /// with a given sequence of arguments preceding any provided when the new function is called.
1203     ///
1204     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
1205     #[wasm_bindgen(method, js_name = bind)]
bind2(this: &Function, context: &JsValue, arg1: &JsValue, arg2: &JsValue) -> Function1206     pub fn bind2(this: &Function, context: &JsValue, arg1: &JsValue, arg2: &JsValue) -> Function;
1207 
1208     /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
1209     /// with a given sequence of arguments preceding any provided when the new function is called.
1210     ///
1211     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
1212     #[wasm_bindgen(method, js_name = bind)]
bind3( this: &Function, context: &JsValue, arg1: &JsValue, arg2: &JsValue, arg3: &JsValue, ) -> Function1213     pub fn bind3(
1214         this: &Function,
1215         context: &JsValue,
1216         arg1: &JsValue,
1217         arg2: &JsValue,
1218         arg3: &JsValue,
1219     ) -> Function;
1220 
1221     /// The length property indicates the number of arguments expected by the function.
1222     ///
1223     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/length)
1224     #[wasm_bindgen(method, getter, structural)]
length(this: &Function) -> u321225     pub fn length(this: &Function) -> u32;
1226 
1227     /// A Function object's read-only name property indicates the function's
1228     /// name as specified when it was created or "anonymous" for functions
1229     /// created anonymously.
1230     ///
1231     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name)
1232     #[wasm_bindgen(method, getter, structural)]
name(this: &Function) -> JsString1233     pub fn name(this: &Function) -> JsString;
1234 
1235     /// The `toString()` method returns a string representing the source code of the function.
1236     ///
1237     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/toString)
1238     #[wasm_bindgen(method, js_name = toString)]
to_string(this: &Function) -> JsString1239     pub fn to_string(this: &Function) -> JsString;
1240 }
1241 
1242 impl Function {
1243     /// Returns the `Function` value of this JS value if it's an instance of a
1244     /// function.
1245     ///
1246     /// If this JS value is not an instance of a function then this returns
1247     /// `None`.
1248     #[deprecated(note = "recommended to use dyn_ref instead which is now equivalent")]
try_from(val: &JsValue) -> Option<&Function>1249     pub fn try_from(val: &JsValue) -> Option<&Function> {
1250         val.dyn_ref()
1251     }
1252 }
1253 
1254 // Generator
1255 #[wasm_bindgen]
1256 extern "C" {
1257     #[wasm_bindgen(extends = Object, typescript_type = "Generator<any, any, any>")]
1258     #[derive(Clone, Debug, PartialEq, Eq)]
1259     pub type Generator;
1260 
1261     /// The `next()` method returns an object with two properties done and value.
1262     /// You can also provide a parameter to the next method to send a value to the generator.
1263     ///
1264     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/next)
1265     #[wasm_bindgen(method, structural, catch)]
next(this: &Generator, value: &JsValue) -> Result<JsValue, JsValue>1266     pub fn next(this: &Generator, value: &JsValue) -> Result<JsValue, JsValue>;
1267 
1268     /// The `return()` method returns the given value and finishes the generator.
1269     ///
1270     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/return)
1271     #[wasm_bindgen(method, structural, js_name = return)]
return_(this: &Generator, value: &JsValue) -> JsValue1272     pub fn return_(this: &Generator, value: &JsValue) -> JsValue;
1273 
1274     /// The `throw()` method resumes the execution of a generator by throwing an error into it
1275     /// and returns an object with two properties done and value.
1276     ///
1277     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/throw)
1278     #[wasm_bindgen(method, structural, catch)]
throw(this: &Generator, error: &Error) -> Result<JsValue, JsValue>1279     pub fn throw(this: &Generator, error: &Error) -> Result<JsValue, JsValue>;
1280 }
1281 
1282 // Map
1283 #[wasm_bindgen]
1284 extern "C" {
1285     #[wasm_bindgen(extends = Object, typescript_type = "Map<any, any>")]
1286     #[derive(Clone, Debug, PartialEq, Eq)]
1287     pub type Map;
1288 
1289     /// The `clear()` method removes all elements from a Map object.
1290     ///
1291     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/clear)
1292     #[wasm_bindgen(method)]
clear(this: &Map)1293     pub fn clear(this: &Map);
1294 
1295     /// The `delete()` method removes the specified element from a Map object.
1296     ///
1297     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/delete)
1298     #[wasm_bindgen(method)]
delete(this: &Map, key: &JsValue) -> bool1299     pub fn delete(this: &Map, key: &JsValue) -> bool;
1300 
1301     /// The `forEach()` method executes a provided function once per each
1302     /// key/value pair in the Map object, in insertion order.
1303     /// Note that in Javascript land the `Key` and `Value` are reversed compared to normal expectations:
1304     /// # Examples
1305     /// ```
1306     /// let js_map = Map::new();
1307     /// js_map.for_each(&mut |value, key| {
1308     ///     // Do something here...
1309     /// })
1310     /// ```
1311     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/forEach)
1312     #[wasm_bindgen(method, js_name = forEach)]
for_each(this: &Map, callback: &mut dyn FnMut(JsValue, JsValue))1313     pub fn for_each(this: &Map, callback: &mut dyn FnMut(JsValue, JsValue));
1314 
1315     /// The `get()` method returns a specified element from a Map object.
1316     ///
1317     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/get)
1318     #[wasm_bindgen(method)]
get(this: &Map, key: &JsValue) -> JsValue1319     pub fn get(this: &Map, key: &JsValue) -> JsValue;
1320 
1321     /// The `has()` method returns a boolean indicating whether an element with
1322     /// the specified key exists or not.
1323     ///
1324     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/has)
1325     #[wasm_bindgen(method)]
has(this: &Map, key: &JsValue) -> bool1326     pub fn has(this: &Map, key: &JsValue) -> bool;
1327 
1328     /// The Map object holds key-value pairs. Any value (both objects and
1329     /// primitive values) maybe used as either a key or a value.
1330     ///
1331     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map)
1332     #[wasm_bindgen(constructor)]
new() -> Map1333     pub fn new() -> Map;
1334 
1335     /// The `set()` method adds or updates an element with a specified key
1336     /// and value to a Map object.
1337     ///
1338     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/set)
1339     #[wasm_bindgen(method)]
set(this: &Map, key: &JsValue, value: &JsValue) -> Map1340     pub fn set(this: &Map, key: &JsValue, value: &JsValue) -> Map;
1341 
1342     /// The value of size is an integer representing how many entries
1343     /// the Map object has. A set accessor function for size is undefined;
1344     /// you can not change this property.
1345     ///
1346     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/size)
1347     #[wasm_bindgen(method, getter, structural)]
size(this: &Map) -> u321348     pub fn size(this: &Map) -> u32;
1349 }
1350 
1351 // Map Iterator
1352 #[wasm_bindgen]
1353 extern "C" {
1354     /// The `entries()` method returns a new Iterator object that contains
1355     /// the [key, value] pairs for each element in the Map object in
1356     /// insertion order.
1357     ///
1358     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/entries)
1359     #[wasm_bindgen(method)]
entries(this: &Map) -> Iterator1360     pub fn entries(this: &Map) -> Iterator;
1361 
1362     /// The `keys()` method returns a new Iterator object that contains the
1363     /// keys for each element in the Map object in insertion order.
1364     ///
1365     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/keys)
1366     #[wasm_bindgen(method)]
keys(this: &Map) -> Iterator1367     pub fn keys(this: &Map) -> Iterator;
1368 
1369     /// The `values()` method returns a new Iterator object that contains the
1370     /// values for each element in the Map object in insertion order.
1371     ///
1372     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/values)
1373     #[wasm_bindgen(method)]
values(this: &Map) -> Iterator1374     pub fn values(this: &Map) -> Iterator;
1375 }
1376 
1377 // Iterator
1378 #[wasm_bindgen]
1379 extern "C" {
1380     /// Any object that conforms to the JS iterator protocol. For example,
1381     /// something returned by `myArray[Symbol.iterator]()`.
1382     ///
1383     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols)
1384     #[derive(Clone, Debug)]
1385     #[wasm_bindgen(is_type_of = Iterator::looks_like_iterator, typescript_type = "Iterator<any>")]
1386     pub type Iterator;
1387 
1388     /// The `next()` method always has to return an object with appropriate
1389     /// properties including done and value. If a non-object value gets returned
1390     /// (such as false or undefined), a TypeError ("iterator.next() returned a
1391     /// non-object value") will be thrown.
1392     #[wasm_bindgen(catch, method, structural)]
next(this: &Iterator) -> Result<IteratorNext, JsValue>1393     pub fn next(this: &Iterator) -> Result<IteratorNext, JsValue>;
1394 }
1395 
1396 impl Iterator {
looks_like_iterator(it: &JsValue) -> bool1397     fn looks_like_iterator(it: &JsValue) -> bool {
1398         #[wasm_bindgen]
1399         extern "C" {
1400             type MaybeIterator;
1401 
1402             #[wasm_bindgen(method, getter)]
1403             fn next(this: &MaybeIterator) -> JsValue;
1404         }
1405 
1406         if !it.is_object() {
1407             return false;
1408         }
1409 
1410         let it = it.unchecked_ref::<MaybeIterator>();
1411 
1412         it.next().is_function()
1413     }
1414 }
1415 
1416 // Async Iterator
1417 #[wasm_bindgen]
1418 extern "C" {
1419     /// Any object that conforms to the JS async iterator protocol. For example,
1420     /// something returned by `myObject[Symbol.asyncIterator]()`.
1421     ///
1422     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of)
1423     #[derive(Clone, Debug)]
1424     #[wasm_bindgen(is_type_of = Iterator::looks_like_iterator, typescript_type = "Iterator<Promise<any>>")]
1425     pub type AsyncIterator;
1426 
1427     /// The `next()` method always has to return a Promise which resolves to an object
1428     /// with appropriate properties including done and value. If a non-object value
1429     /// gets returned (such as false or undefined), a TypeError ("iterator.next()
1430     /// returned a non-object value") will be thrown.
1431     #[wasm_bindgen(catch, method, structural)]
next(this: &AsyncIterator) -> Result<Promise, JsValue>1432     pub fn next(this: &AsyncIterator) -> Result<Promise, JsValue>;
1433 }
1434 
1435 /// An iterator over the JS `Symbol.iterator` iteration protocol.
1436 ///
1437 /// Use the `IntoIterator for &js_sys::Iterator` implementation to create this.
1438 pub struct Iter<'a> {
1439     js: &'a Iterator,
1440     state: IterState,
1441 }
1442 
1443 /// An iterator over the JS `Symbol.iterator` iteration protocol.
1444 ///
1445 /// Use the `IntoIterator for js_sys::Iterator` implementation to create this.
1446 pub struct IntoIter {
1447     js: Iterator,
1448     state: IterState,
1449 }
1450 
1451 struct IterState {
1452     done: bool,
1453 }
1454 
1455 impl<'a> IntoIterator for &'a Iterator {
1456     type Item = Result<JsValue, JsValue>;
1457     type IntoIter = Iter<'a>;
1458 
into_iter(self) -> Iter<'a>1459     fn into_iter(self) -> Iter<'a> {
1460         Iter {
1461             js: self,
1462             state: IterState::new(),
1463         }
1464     }
1465 }
1466 
1467 impl<'a> std::iter::Iterator for Iter<'a> {
1468     type Item = Result<JsValue, JsValue>;
1469 
next(&mut self) -> Option<Self::Item>1470     fn next(&mut self) -> Option<Self::Item> {
1471         self.state.next(self.js)
1472     }
1473 }
1474 
1475 impl IntoIterator for Iterator {
1476     type Item = Result<JsValue, JsValue>;
1477     type IntoIter = IntoIter;
1478 
into_iter(self) -> IntoIter1479     fn into_iter(self) -> IntoIter {
1480         IntoIter {
1481             js: self,
1482             state: IterState::new(),
1483         }
1484     }
1485 }
1486 
1487 impl std::iter::Iterator for IntoIter {
1488     type Item = Result<JsValue, JsValue>;
1489 
next(&mut self) -> Option<Self::Item>1490     fn next(&mut self) -> Option<Self::Item> {
1491         self.state.next(&self.js)
1492     }
1493 }
1494 
1495 impl IterState {
new() -> IterState1496     fn new() -> IterState {
1497         IterState { done: false }
1498     }
1499 
next(&mut self, js: &Iterator) -> Option<Result<JsValue, JsValue>>1500     fn next(&mut self, js: &Iterator) -> Option<Result<JsValue, JsValue>> {
1501         if self.done {
1502             return None;
1503         }
1504         let next = match js.next() {
1505             Ok(val) => val,
1506             Err(e) => {
1507                 self.done = true;
1508                 return Some(Err(e));
1509             }
1510         };
1511         if next.done() {
1512             self.done = true;
1513             None
1514         } else {
1515             Some(Ok(next.value()))
1516         }
1517     }
1518 }
1519 
1520 /// Create an iterator over `val` using the JS iteration protocol and
1521 /// `Symbol.iterator`.
try_iter(val: &JsValue) -> Result<Option<IntoIter>, JsValue>1522 pub fn try_iter(val: &JsValue) -> Result<Option<IntoIter>, JsValue> {
1523     let iter_sym = Symbol::iterator();
1524     let iter_fn = Reflect::get(val, iter_sym.as_ref())?;
1525 
1526     let iter_fn: Function = match iter_fn.dyn_into() {
1527         Ok(iter_fn) => iter_fn,
1528         Err(_) => return Ok(None),
1529     };
1530 
1531     let it: Iterator = match iter_fn.call0(val)?.dyn_into() {
1532         Ok(it) => it,
1533         Err(_) => return Ok(None),
1534     };
1535 
1536     Ok(Some(it.into_iter()))
1537 }
1538 
1539 // IteratorNext
1540 #[wasm_bindgen]
1541 extern "C" {
1542     /// The result of calling `next()` on a JS iterator.
1543     ///
1544     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols)
1545     #[wasm_bindgen(extends = Object, typescript_type = "IteratorResult<any>")]
1546     #[derive(Clone, Debug, PartialEq, Eq)]
1547     pub type IteratorNext;
1548 
1549     /// Has the value `true` if the iterator is past the end of the iterated
1550     /// sequence. In this case value optionally specifies the return value of
1551     /// the iterator.
1552     ///
1553     /// Has the value `false` if the iterator was able to produce the next value
1554     /// in the sequence. This is equivalent of not specifying the done property
1555     /// altogether.
1556     #[wasm_bindgen(method, getter, structural)]
done(this: &IteratorNext) -> bool1557     pub fn done(this: &IteratorNext) -> bool;
1558 
1559     /// Any JavaScript value returned by the iterator. Can be omitted when done
1560     /// is true.
1561     #[wasm_bindgen(method, getter, structural)]
value(this: &IteratorNext) -> JsValue1562     pub fn value(this: &IteratorNext) -> JsValue;
1563 }
1564 
1565 #[allow(non_snake_case)]
1566 pub mod Math {
1567     use super::*;
1568 
1569     // Math
1570     #[wasm_bindgen]
1571     extern "C" {
1572         /// The `Math.abs()` function returns the absolute value of a number, that is
1573         /// Math.abs(x) = |x|
1574         ///
1575         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/abs)
1576         #[wasm_bindgen(js_namespace = Math)]
abs(x: f64) -> f641577         pub fn abs(x: f64) -> f64;
1578 
1579         /// The `Math.acos()` function returns the arccosine (in radians) of a
1580         /// number, that is ∀x∊[-1;1]
1581         /// Math.acos(x) = arccos(x) = the unique y∊[0;π] such that cos(y)=x
1582         ///
1583         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/acos)
1584         #[wasm_bindgen(js_namespace = Math)]
acos(x: f64) -> f641585         pub fn acos(x: f64) -> f64;
1586 
1587         /// The `Math.acosh()` function returns the hyperbolic arc-cosine of a
1588         /// number, that is ∀x ≥ 1
1589         /// Math.acosh(x) = arcosh(x) = the unique y ≥ 0 such that cosh(y) = x
1590         ///
1591         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/acosh)
1592         #[wasm_bindgen(js_namespace = Math)]
acosh(x: f64) -> f641593         pub fn acosh(x: f64) -> f64;
1594 
1595         /// The `Math.asin()` function returns the arcsine (in radians) of a
1596         /// number, that is ∀x ∊ [-1;1]
1597         /// Math.asin(x) = arcsin(x) = the unique y∊[-π2;π2] such that sin(y) = x
1598         ///
1599         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/asin)
1600         #[wasm_bindgen(js_namespace = Math)]
asin(x: f64) -> f641601         pub fn asin(x: f64) -> f64;
1602 
1603         /// The `Math.asinh()` function returns the hyperbolic arcsine of a
1604         /// number, that is Math.asinh(x) = arsinh(x) = the unique y such that sinh(y) = x
1605         ///
1606         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/asinh)
1607         #[wasm_bindgen(js_namespace = Math)]
asinh(x: f64) -> f641608         pub fn asinh(x: f64) -> f64;
1609 
1610         /// The `Math.atan()` function returns the arctangent (in radians) of a
1611         /// number, that is Math.atan(x) = arctan(x) = the unique y ∊ [-π2;π2]such that
1612         /// tan(y) = x
1613         #[wasm_bindgen(js_namespace = Math)]
atan(x: f64) -> f641614         pub fn atan(x: f64) -> f64;
1615 
1616         /// The `Math.atan2()` function returns the arctangent of the quotient of
1617         /// its arguments.
1618         ///
1619         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atan2)
1620         #[wasm_bindgen(js_namespace = Math)]
atan2(y: f64, x: f64) -> f641621         pub fn atan2(y: f64, x: f64) -> f64;
1622 
1623         /// The `Math.atanh()` function returns the hyperbolic arctangent of a number,
1624         /// that is ∀x ∊ (-1,1), Math.atanh(x) = arctanh(x) = the unique y such that
1625         /// tanh(y) = x
1626         ///
1627         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atanh)
1628         #[wasm_bindgen(js_namespace = Math)]
atanh(x: f64) -> f641629         pub fn atanh(x: f64) -> f64;
1630 
1631         /// The `Math.cbrt() `function returns the cube root of a number, that is
1632         /// Math.cbrt(x) = ∛x = the unique y such that y^3 = x
1633         ///
1634         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cbrt)
1635         #[wasm_bindgen(js_namespace = Math)]
cbrt(x: f64) -> f641636         pub fn cbrt(x: f64) -> f64;
1637 
1638         /// The `Math.ceil()` function returns the smallest integer greater than
1639         /// or equal to a given number.
1640         ///
1641         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/ceil)
1642         #[wasm_bindgen(js_namespace = Math)]
ceil(x: f64) -> f641643         pub fn ceil(x: f64) -> f64;
1644 
1645         /// The `Math.clz32()` function returns the number of leading zero bits in
1646         /// the 32-bit binary representation of a number.
1647         ///
1648         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/clz32)
1649         #[wasm_bindgen(js_namespace = Math)]
clz32(x: i32) -> u321650         pub fn clz32(x: i32) -> u32;
1651 
1652         /// The `Math.cos()` static function returns the cosine of the specified angle,
1653         /// which must be specified in radians. This value is length(adjacent)/length(hypotenuse).
1654         ///
1655         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cos)
1656         #[wasm_bindgen(js_namespace = Math)]
cos(x: f64) -> f641657         pub fn cos(x: f64) -> f64;
1658 
1659         /// The `Math.cosh()` function returns the hyperbolic cosine of a number,
1660         /// that can be expressed using the constant e.
1661         ///
1662         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cosh)
1663         #[wasm_bindgen(js_namespace = Math)]
cosh(x: f64) -> f641664         pub fn cosh(x: f64) -> f64;
1665 
1666         /// The `Math.exp()` function returns e^x, where x is the argument, and e is Euler's number
1667         /// (also known as Napier's constant), the base of the natural logarithms.
1668         ///
1669         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/exp)
1670         #[wasm_bindgen(js_namespace = Math)]
exp(x: f64) -> f641671         pub fn exp(x: f64) -> f64;
1672 
1673         /// The `Math.expm1()` function returns e^x - 1, where x is the argument, and e the base of the
1674         /// natural logarithms.
1675         ///
1676         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/expm1)
1677         #[wasm_bindgen(js_namespace = Math)]
expm1(x: f64) -> f641678         pub fn expm1(x: f64) -> f64;
1679 
1680         /// The `Math.floor()` function returns the largest integer less than or
1681         /// equal to a given number.
1682         ///
1683         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/floor)
1684         #[wasm_bindgen(js_namespace = Math)]
floor(x: f64) -> f641685         pub fn floor(x: f64) -> f64;
1686 
1687         /// The `Math.fround()` function returns the nearest 32-bit single precision float representation
1688         /// of a Number.
1689         ///
1690         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/fround)
1691         #[wasm_bindgen(js_namespace = Math)]
fround(x: f64) -> f321692         pub fn fround(x: f64) -> f32;
1693 
1694         /// The `Math.hypot()` function returns the square root of the sum of squares of its arguments.
1695         ///
1696         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/hypot)
1697         #[wasm_bindgen(js_namespace = Math)]
hypot(x: f64, y: f64) -> f641698         pub fn hypot(x: f64, y: f64) -> f64;
1699 
1700         /// The `Math.imul()` function returns the result of the C-like 32-bit multiplication of the
1701         /// two parameters.
1702         ///
1703         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul)
1704         #[wasm_bindgen(js_namespace = Math)]
imul(x: i32, y: i32) -> i321705         pub fn imul(x: i32, y: i32) -> i32;
1706 
1707         /// The `Math.log()` function returns the natural logarithm (base e) of a number.
1708         /// The JavaScript `Math.log()` function is equivalent to ln(x) in mathematics.
1709         ///
1710         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log)
1711         #[wasm_bindgen(js_namespace = Math)]
log(x: f64) -> f641712         pub fn log(x: f64) -> f64;
1713 
1714         /// The `Math.log10()` function returns the base 10 logarithm of a number.
1715         ///
1716         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log10)
1717         #[wasm_bindgen(js_namespace = Math)]
log10(x: f64) -> f641718         pub fn log10(x: f64) -> f64;
1719 
1720         /// The `Math.log1p()` function returns the natural logarithm (base e) of 1 + a number.
1721         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log1p)
1722         #[wasm_bindgen(js_namespace = Math)]
log1p(x: f64) -> f641723         pub fn log1p(x: f64) -> f64;
1724 
1725         /// The `Math.log2()` function returns the base 2 logarithm of a number.
1726         ///
1727         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log2)
1728         #[wasm_bindgen(js_namespace = Math)]
log2(x: f64) -> f641729         pub fn log2(x: f64) -> f64;
1730 
1731         /// The `Math.max()` function returns the largest of two numbers.
1732         ///
1733         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/max)
1734         #[wasm_bindgen(js_namespace = Math)]
max(x: f64, y: f64) -> f641735         pub fn max(x: f64, y: f64) -> f64;
1736 
1737         /// The static function `Math.min()` returns the lowest-valued number passed into it.
1738         ///
1739         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/min)
1740         #[wasm_bindgen(js_namespace = Math)]
min(x: f64, y: f64) -> f641741         pub fn min(x: f64, y: f64) -> f64;
1742 
1743         /// The `Math.pow()` function returns the base to the exponent power, that is, base^exponent.
1744         ///
1745         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/pow)
1746         #[wasm_bindgen(js_namespace = Math)]
pow(base: f64, exponent: f64) -> f641747         pub fn pow(base: f64, exponent: f64) -> f64;
1748 
1749         /// The `Math.random()` function returns a floating-point, pseudo-random number
1750         /// in the range 0–1 (inclusive of 0, but not 1) with approximately uniform distribution
1751         /// over that range — which you can then scale to your desired range.
1752         /// The implementation selects the initial seed to the random number generation algorithm;
1753         /// it cannot be chosen or reset by the user.
1754         ///
1755         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random)
1756         #[wasm_bindgen(js_namespace = Math)]
random() -> f641757         pub fn random() -> f64;
1758 
1759         /// The `Math.round()` function returns the value of a number rounded to the nearest integer.
1760         ///
1761         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/round)
1762         #[wasm_bindgen(js_namespace = Math)]
round(x: f64) -> f641763         pub fn round(x: f64) -> f64;
1764 
1765         /// The `Math.sign()` function returns the sign of a number, indicating whether the number is
1766         /// positive, negative or zero.
1767         ///
1768         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sign)
1769         #[wasm_bindgen(js_namespace = Math)]
sign(x: f64) -> f641770         pub fn sign(x: f64) -> f64;
1771 
1772         /// The `Math.sin()` function returns the sine of a number.
1773         ///
1774         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sin)
1775         #[wasm_bindgen(js_namespace = Math)]
sin(x: f64) -> f641776         pub fn sin(x: f64) -> f64;
1777 
1778         /// The `Math.sinh()` function returns the hyperbolic sine of a number, that can be expressed
1779         /// using the constant e: Math.sinh(x) = (e^x - e^-x)/2
1780         ///
1781         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sinh)
1782         #[wasm_bindgen(js_namespace = Math)]
sinh(x: f64) -> f641783         pub fn sinh(x: f64) -> f64;
1784 
1785         /// The `Math.sqrt()` function returns the square root of a number, that is
1786         /// ∀x ≥ 0, Math.sqrt(x) = √x = the unique y ≥ 0 such that y^2 = x
1787         ///
1788         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sqrt)
1789         #[wasm_bindgen(js_namespace = Math)]
sqrt(x: f64) -> f641790         pub fn sqrt(x: f64) -> f64;
1791 
1792         /// The `Math.tan()` function returns the tangent of a number.
1793         ///
1794         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/tan)
1795         #[wasm_bindgen(js_namespace = Math)]
tan(x: f64) -> f641796         pub fn tan(x: f64) -> f64;
1797 
1798         /// The `Math.tanh()` function returns the hyperbolic tangent of a number, that is
1799         /// tanh x = sinh x / cosh x = (e^x - e^-x)/(e^x + e^-x) = (e^2x - 1)/(e^2x + 1)
1800         ///
1801         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/tanh)
1802         #[wasm_bindgen(js_namespace = Math)]
tanh(x: f64) -> f641803         pub fn tanh(x: f64) -> f64;
1804 
1805         /// The `Math.trunc()` function returns the integer part of a number by removing any fractional
1806         /// digits.
1807         ///
1808         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/trunc)
1809         #[wasm_bindgen(js_namespace = Math)]
trunc(x: f64) -> f641810         pub fn trunc(x: f64) -> f64;
1811     }
1812 }
1813 
1814 // Number.
1815 #[wasm_bindgen]
1816 extern "C" {
1817     #[wasm_bindgen(extends = Object, is_type_of = |v| v.as_f64().is_some(), typescript_type = "number")]
1818     #[derive(Clone)]
1819     pub type Number;
1820 
1821     /// The `Number.isFinite()` method determines whether the passed value is a finite number.
1822     ///
1823     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isFinite)
1824     #[wasm_bindgen(static_method_of = Number, js_name = isFinite)]
is_finite(value: &JsValue) -> bool1825     pub fn is_finite(value: &JsValue) -> bool;
1826 
1827     /// The `Number.isInteger()` method determines whether the passed value is an integer.
1828     ///
1829     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger)
1830     #[wasm_bindgen(static_method_of = Number, js_name = isInteger)]
is_integer(value: &JsValue) -> bool1831     pub fn is_integer(value: &JsValue) -> bool;
1832 
1833     /// The `Number.isNaN()` method determines whether the passed value is `NaN` and its type is Number.
1834     /// It is a more robust version of the original, global isNaN().
1835     ///
1836     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isNaN)
1837     #[wasm_bindgen(static_method_of = Number, js_name = isNaN)]
is_nan(value: &JsValue) -> bool1838     pub fn is_nan(value: &JsValue) -> bool;
1839 
1840     /// The `Number.isSafeInteger()` method determines whether the provided value is a number
1841     /// that is a safe integer.
1842     ///
1843     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger)
1844     #[wasm_bindgen(static_method_of = Number, js_name = isSafeInteger)]
is_safe_integer(value: &JsValue) -> bool1845     pub fn is_safe_integer(value: &JsValue) -> bool;
1846 
1847     /// The `Number` JavaScript object is a wrapper object allowing
1848     /// you to work with numerical values. A `Number` object is
1849     /// created using the `Number()` constructor.
1850     ///
1851     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)
1852     #[wasm_bindgen(constructor)]
1853     #[deprecated(note = "recommended to use `Number::from` instead")]
1854     #[allow(deprecated)]
new(value: &JsValue) -> Number1855     pub fn new(value: &JsValue) -> Number;
1856 
1857     /// The `Number.parseInt()` method parses a string argument and returns an
1858     /// integer of the specified radix or base.
1859     ///
1860     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/parseInt)
1861     #[wasm_bindgen(static_method_of = Number, js_name = parseInt)]
parse_int(text: &str, radix: u8) -> f641862     pub fn parse_int(text: &str, radix: u8) -> f64;
1863 
1864     /// The `Number.parseFloat()` method parses a string argument and returns a
1865     /// floating point number.
1866     ///
1867     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/parseFloat)
1868     #[wasm_bindgen(static_method_of = Number, js_name = parseFloat)]
parse_float(text: &str) -> f641869     pub fn parse_float(text: &str) -> f64;
1870 
1871     /// The `toLocaleString()` method returns a string with a language sensitive
1872     /// representation of this number.
1873     ///
1874     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString)
1875     #[wasm_bindgen(method, js_name = toLocaleString)]
to_locale_string(this: &Number, locale: &str) -> JsString1876     pub fn to_locale_string(this: &Number, locale: &str) -> JsString;
1877 
1878     /// The `toPrecision()` method returns a string representing the Number
1879     /// object to the specified precision.
1880     ///
1881     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toPrecision)
1882     #[wasm_bindgen(catch, method, js_name = toPrecision)]
to_precision(this: &Number, precision: u8) -> Result<JsString, JsValue>1883     pub fn to_precision(this: &Number, precision: u8) -> Result<JsString, JsValue>;
1884 
1885     /// The `toFixed()` method returns a string representing the Number
1886     /// object using fixed-point notation.
1887     ///
1888     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed)
1889     #[wasm_bindgen(catch, method, js_name = toFixed)]
to_fixed(this: &Number, digits: u8) -> Result<JsString, JsValue>1890     pub fn to_fixed(this: &Number, digits: u8) -> Result<JsString, JsValue>;
1891 
1892     /// The `toExponential()` method returns a string representing the Number
1893     /// object in exponential notation.
1894     ///
1895     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toExponential)
1896     #[wasm_bindgen(catch, method, js_name = toExponential)]
to_exponential(this: &Number, fraction_digits: u8) -> Result<JsString, JsValue>1897     pub fn to_exponential(this: &Number, fraction_digits: u8) -> Result<JsString, JsValue>;
1898 
1899     /// The `toString()` method returns a string representing the
1900     /// specified Number object.
1901     ///
1902     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString)
1903     #[wasm_bindgen(catch, method, js_name = toString)]
to_string(this: &Number, radix: u8) -> Result<JsString, JsValue>1904     pub fn to_string(this: &Number, radix: u8) -> Result<JsString, JsValue>;
1905 
1906     /// The `valueOf()` method returns the wrapped primitive value of
1907     /// a Number object.
1908     ///
1909     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/valueOf)
1910     #[wasm_bindgen(method, js_name = valueOf)]
value_of(this: &Number) -> f641911     pub fn value_of(this: &Number) -> f64;
1912 }
1913 
1914 impl Number {
1915     /// The smallest interval between two representable numbers.
1916     ///
1917     /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/EPSILON)
1918     pub const EPSILON: f64 = f64::EPSILON;
1919     /// The maximum safe integer in JavaScript (2^53 - 1).
1920     ///
1921     /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER)
1922     pub const MAX_SAFE_INTEGER: f64 = 9007199254740991.0;
1923     /// The largest positive representable number.
1924     ///
1925     /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_VALUE)
1926     pub const MAX_VALUE: f64 = f64::MAX;
1927     /// The minimum safe integer in JavaScript (-(2^53 - 1)).
1928     ///
1929     /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MIN_SAFE_INTEGER)
1930     pub const MIN_SAFE_INTEGER: f64 = -9007199254740991.0;
1931     /// The smallest positive representable number—that is, the positive number closest to zero
1932     /// (without actually being zero).
1933     ///
1934     /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MIN_VALUE)
1935     // Cannot use f64::MIN_POSITIVE since that is the smallest **normal** postitive number.
1936     pub const MIN_VALUE: f64 = 5E-324;
1937     /// Special "Not a Number" value.
1938     ///
1939     /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/NaN)
1940     pub const NAN: f64 = f64::NAN;
1941     /// Special value representing negative infinity. Returned on overflow.
1942     ///
1943     /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/NEGATIVE_INFINITY)
1944     pub const NEGATIVE_INFINITY: f64 = f64::NEG_INFINITY;
1945     /// Special value representing infinity. Returned on overflow.
1946     ///
1947     /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/POSITIVE_INFINITY)
1948     pub const POSITIVE_INFINITY: f64 = f64::INFINITY;
1949 }
1950 
1951 macro_rules! number_from {
1952     ($($x:ident)*) => ($(
1953         impl From<$x> for Number {
1954             #[inline]
1955             fn from(x: $x) -> Number {
1956                 Number::unchecked_from_js(JsValue::from(x))
1957             }
1958         }
1959 
1960         impl PartialEq<$x> for Number {
1961             #[inline]
1962             fn eq(&self, other: &$x) -> bool {
1963                 self.value_of() == f64::from(*other)
1964             }
1965         }
1966     )*)
1967 }
1968 number_from!(i8 u8 i16 u16 i32 u32 f32 f64);
1969 
1970 impl From<Number> for f64 {
1971     #[inline]
from(n: Number) -> f641972     fn from(n: Number) -> f64 {
1973         n.value_of()
1974     }
1975 }
1976 
1977 impl fmt::Debug for Number {
fmt(&self, f: &mut fmt::Formatter) -> fmt::Result1978     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1979         self.value_of().fmt(f)
1980     }
1981 }
1982 
1983 // Date.
1984 #[wasm_bindgen]
1985 extern "C" {
1986     #[wasm_bindgen(extends = Object, typescript_type = "Date")]
1987     #[derive(Clone, Debug, PartialEq, Eq)]
1988     pub type Date;
1989 
1990     /// The `getDate()` method returns the day of the month for the
1991     /// specified date according to local time.
1992     ///
1993     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getDate)
1994     #[wasm_bindgen(method, js_name = getDate)]
get_date(this: &Date) -> u321995     pub fn get_date(this: &Date) -> u32;
1996 
1997     /// The `getDay()` method returns the day of the week for the specified date according to local time,
1998     /// where 0 represents Sunday. For the day of the month see getDate().
1999     ///
2000     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getDay)
2001     #[wasm_bindgen(method, js_name = getDay)]
get_day(this: &Date) -> u322002     pub fn get_day(this: &Date) -> u32;
2003 
2004     /// The `getFullYear()` method returns the year of the specified date according to local time.
2005     ///
2006     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getFullYear)
2007     #[wasm_bindgen(method, js_name = getFullYear)]
get_full_year(this: &Date) -> u322008     pub fn get_full_year(this: &Date) -> u32;
2009 
2010     /// The `getHours()` method returns the hour for the specified date, according to local time.
2011     ///
2012     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getHours)
2013     #[wasm_bindgen(method, js_name = getHours)]
get_hours(this: &Date) -> u322014     pub fn get_hours(this: &Date) -> u32;
2015 
2016     /// The `getMilliseconds()` method returns the milliseconds in the specified date according to local time.
2017     ///
2018     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMilliseconds)
2019     #[wasm_bindgen(method, js_name = getMilliseconds)]
get_milliseconds(this: &Date) -> u322020     pub fn get_milliseconds(this: &Date) -> u32;
2021 
2022     /// The `getMinutes()` method returns the minutes in the specified date according to local time.
2023     ///
2024     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMinutes)
2025     #[wasm_bindgen(method, js_name = getMinutes)]
get_minutes(this: &Date) -> u322026     pub fn get_minutes(this: &Date) -> u32;
2027 
2028     /// The `getMonth()` method returns the month in the specified date according to local time,
2029     /// as a zero-based value (where zero indicates the first month of the year).
2030     ///
2031     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMonth)
2032     #[wasm_bindgen(method, js_name = getMonth)]
get_month(this: &Date) -> u322033     pub fn get_month(this: &Date) -> u32;
2034 
2035     /// The `getSeconds()` method returns the seconds in the specified date according to local time.
2036     ///
2037     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getSeconds)
2038     #[wasm_bindgen(method, js_name = getSeconds)]
get_seconds(this: &Date) -> u322039     pub fn get_seconds(this: &Date) -> u32;
2040 
2041     /// The `getTime()` method returns the numeric value corresponding to the time for the specified date
2042     /// according to universal time.
2043     ///
2044     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTime)
2045     #[wasm_bindgen(method, js_name = getTime)]
get_time(this: &Date) -> f642046     pub fn get_time(this: &Date) -> f64;
2047 
2048     /// The `getTimezoneOffset()` method returns the time zone difference, in minutes,
2049     /// from current locale (host system settings) to UTC.
2050     ///
2051     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset)
2052     #[wasm_bindgen(method, js_name = getTimezoneOffset)]
get_timezone_offset(this: &Date) -> f642053     pub fn get_timezone_offset(this: &Date) -> f64;
2054 
2055     /// The `getUTCDate()` method returns the day (date) of the month in the specified date
2056     /// according to universal time.
2057     ///
2058     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCDate)
2059     #[wasm_bindgen(method, js_name = getUTCDate)]
get_utc_date(this: &Date) -> u322060     pub fn get_utc_date(this: &Date) -> u32;
2061 
2062     /// The `getUTCDay()` method returns the day of the week in the specified date according to universal time,
2063     /// where 0 represents Sunday.
2064     ///
2065     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCDay)
2066     #[wasm_bindgen(method, js_name = getUTCDay)]
get_utc_day(this: &Date) -> u322067     pub fn get_utc_day(this: &Date) -> u32;
2068 
2069     /// The `getUTCFullYear()` method returns the year in the specified date according to universal time.
2070     ///
2071     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCFullYear)
2072     #[wasm_bindgen(method, js_name = getUTCFullYear)]
get_utc_full_year(this: &Date) -> u322073     pub fn get_utc_full_year(this: &Date) -> u32;
2074 
2075     /// The `getUTCHours()` method returns the hours in the specified date according to universal time.
2076     ///
2077     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCHours)
2078     #[wasm_bindgen(method, js_name = getUTCHours)]
get_utc_hours(this: &Date) -> u322079     pub fn get_utc_hours(this: &Date) -> u32;
2080 
2081     /// The `getUTCMilliseconds()` method returns the milliseconds in the specified date
2082     /// according to universal time.
2083     ///
2084     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMilliseconds)
2085     #[wasm_bindgen(method, js_name = getUTCMilliseconds)]
get_utc_milliseconds(this: &Date) -> u322086     pub fn get_utc_milliseconds(this: &Date) -> u32;
2087 
2088     /// The `getUTCMinutes()` method returns the minutes in the specified date according to universal time.
2089     ///
2090     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMinutes)
2091     #[wasm_bindgen(method, js_name = getUTCMinutes)]
get_utc_minutes(this: &Date) -> u322092     pub fn get_utc_minutes(this: &Date) -> u32;
2093 
2094     /// The `getUTCMonth()` returns the month of the specified date according to universal time,
2095     /// as a zero-based value (where zero indicates the first month of the year).
2096     ///
2097     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMonth)
2098     #[wasm_bindgen(method, js_name = getUTCMonth)]
get_utc_month(this: &Date) -> u322099     pub fn get_utc_month(this: &Date) -> u32;
2100 
2101     /// The `getUTCSeconds()` method returns the seconds in the specified date according to universal time.
2102     ///
2103     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCSeconds)
2104     #[wasm_bindgen(method, js_name = getUTCSeconds)]
get_utc_seconds(this: &Date) -> u322105     pub fn get_utc_seconds(this: &Date) -> u32;
2106 
2107     /// Creates a JavaScript `Date` instance that represents
2108     /// a single moment in time. `Date` objects are based on a time value that is
2109     /// the number of milliseconds since 1 January 1970 UTC.
2110     ///
2111     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
2112     #[wasm_bindgen(constructor)]
new(init: &JsValue) -> Date2113     pub fn new(init: &JsValue) -> Date;
2114 
2115     /// Creates a JavaScript `Date` instance that represents the current moment in
2116     /// time.
2117     ///
2118     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
2119     #[wasm_bindgen(constructor)]
new_0() -> Date2120     pub fn new_0() -> Date;
2121 
2122     /// Creates a JavaScript `Date` instance that represents
2123     /// a single moment in time. `Date` objects are based on a time value that is
2124     /// the number of milliseconds since 1 January 1970 UTC.
2125     ///
2126     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
2127     #[wasm_bindgen(constructor)]
new_with_year_month(year: u32, month: i32) -> Date2128     pub fn new_with_year_month(year: u32, month: i32) -> Date;
2129 
2130     /// Creates a JavaScript `Date` instance that represents
2131     /// a single moment in time. `Date` objects are based on a time value that is
2132     /// the number of milliseconds since 1 January 1970 UTC.
2133     ///
2134     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
2135     #[wasm_bindgen(constructor)]
new_with_year_month_day(year: u32, month: i32, day: i32) -> Date2136     pub fn new_with_year_month_day(year: u32, month: i32, day: i32) -> Date;
2137 
2138     /// Creates a JavaScript `Date` instance that represents
2139     /// a single moment in time. `Date` objects are based on a time value that is
2140     /// the number of milliseconds since 1 January 1970 UTC.
2141     ///
2142     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
2143     #[wasm_bindgen(constructor)]
new_with_year_month_day_hr(year: u32, month: i32, day: i32, hr: i32) -> Date2144     pub fn new_with_year_month_day_hr(year: u32, month: i32, day: i32, hr: i32) -> Date;
2145 
2146     /// Creates a JavaScript `Date` instance that represents
2147     /// a single moment in time. `Date` objects are based on a time value that is
2148     /// the number of milliseconds since 1 January 1970 UTC.
2149     ///
2150     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
2151     #[wasm_bindgen(constructor)]
new_with_year_month_day_hr_min( year: u32, month: i32, day: i32, hr: i32, min: i32, ) -> Date2152     pub fn new_with_year_month_day_hr_min(
2153         year: u32,
2154         month: i32,
2155         day: i32,
2156         hr: i32,
2157         min: i32,
2158     ) -> Date;
2159 
2160     /// Creates a JavaScript `Date` instance that represents
2161     /// a single moment in time. `Date` objects are based on a time value that is
2162     /// the number of milliseconds since 1 January 1970 UTC.
2163     ///
2164     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
2165     #[wasm_bindgen(constructor)]
new_with_year_month_day_hr_min_sec( year: u32, month: i32, day: i32, hr: i32, min: i32, sec: i32, ) -> Date2166     pub fn new_with_year_month_day_hr_min_sec(
2167         year: u32,
2168         month: i32,
2169         day: i32,
2170         hr: i32,
2171         min: i32,
2172         sec: i32,
2173     ) -> Date;
2174 
2175     /// Creates a JavaScript `Date` instance that represents
2176     /// a single moment in time. `Date` objects are based on a time value that is
2177     /// the number of milliseconds since 1 January 1970 UTC.
2178     ///
2179     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
2180     #[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, ) -> Date2181     pub fn new_with_year_month_day_hr_min_sec_milli(
2182         year: u32,
2183         month: i32,
2184         day: i32,
2185         hr: i32,
2186         min: i32,
2187         sec: i32,
2188         milli: i32,
2189     ) -> Date;
2190 
2191     /// The `Date.now()` method returns the number of milliseconds
2192     /// elapsed since January 1, 1970 00:00:00 UTC.
2193     ///
2194     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now)
2195     #[wasm_bindgen(static_method_of = Date)]
now() -> f642196     pub fn now() -> f64;
2197 
2198     /// The `Date.parse()` method parses a string representation of a date, and returns the number of milliseconds
2199     /// since January 1, 1970, 00:00:00 UTC or `NaN` if the string is unrecognized or, in some cases,
2200     /// contains illegal date values (e.g. 2015-02-31).
2201     ///
2202     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse)
2203     #[wasm_bindgen(static_method_of = Date)]
parse(date: &str) -> f642204     pub fn parse(date: &str) -> f64;
2205 
2206     /// The `setDate()` method sets the day of the Date object relative to the beginning of the currently set month.
2207     ///
2208     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setDate)
2209     #[wasm_bindgen(method, js_name = setDate)]
set_date(this: &Date, day: u32) -> f642210     pub fn set_date(this: &Date, day: u32) -> f64;
2211 
2212     /// The `setFullYear()` method sets the full year for a specified date according to local time.
2213     /// Returns new timestamp.
2214     ///
2215     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setFullYear)
2216     #[wasm_bindgen(method, js_name = setFullYear)]
set_full_year(this: &Date, year: u32) -> f642217     pub fn set_full_year(this: &Date, year: u32) -> f64;
2218 
2219     /// The `setFullYear()` method sets the full year for a specified date according to local time.
2220     /// Returns new timestamp.
2221     ///
2222     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setFullYear)
2223     #[wasm_bindgen(method, js_name = setFullYear)]
set_full_year_with_month(this: &Date, year: u32, month: i32) -> f642224     pub fn set_full_year_with_month(this: &Date, year: u32, month: i32) -> f64;
2225 
2226     /// The `setFullYear()` method sets the full year for a specified date according to local time.
2227     /// Returns new timestamp.
2228     ///
2229     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setFullYear)
2230     #[wasm_bindgen(method, js_name = setFullYear)]
set_full_year_with_month_date(this: &Date, year: u32, month: i32, date: i32) -> f642231     pub fn set_full_year_with_month_date(this: &Date, year: u32, month: i32, date: i32) -> f64;
2232 
2233     /// The `setHours()` method sets the hours for a specified date according to local time,
2234     /// and returns the number of milliseconds since January 1, 1970 00:00:00 UTC until the time represented
2235     /// by the updated Date instance.
2236     ///
2237     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setHours)
2238     #[wasm_bindgen(method, js_name = setHours)]
set_hours(this: &Date, hours: u32) -> f642239     pub fn set_hours(this: &Date, hours: u32) -> f64;
2240 
2241     /// The `setMilliseconds()` method sets the milliseconds for a specified date according to local time.
2242     ///
2243     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setMilliseconds)
2244     #[wasm_bindgen(method, js_name = setMilliseconds)]
set_milliseconds(this: &Date, milliseconds: u32) -> f642245     pub fn set_milliseconds(this: &Date, milliseconds: u32) -> f64;
2246 
2247     /// The `setMinutes()` method sets the minutes for a specified date according to local time.
2248     ///
2249     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setMinutes)
2250     #[wasm_bindgen(method, js_name = setMinutes)]
set_minutes(this: &Date, minutes: u32) -> f642251     pub fn set_minutes(this: &Date, minutes: u32) -> f64;
2252 
2253     /// The `setMonth()` method sets the month for a specified date according to the currently set year.
2254     ///
2255     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setMonth)
2256     #[wasm_bindgen(method, js_name = setMonth)]
set_month(this: &Date, month: u32) -> f642257     pub fn set_month(this: &Date, month: u32) -> f64;
2258 
2259     /// The `setSeconds()` method sets the seconds for a specified date according to local time.
2260     ///
2261     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setSeconds)
2262     #[wasm_bindgen(method, js_name = setSeconds)]
set_seconds(this: &Date, seconds: u32) -> f642263     pub fn set_seconds(this: &Date, seconds: u32) -> f64;
2264 
2265     /// The `setTime()` method sets the Date object to the time represented by a number of milliseconds
2266     /// since January 1, 1970, 00:00:00 UTC.
2267     ///
2268     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setTime)
2269     #[wasm_bindgen(method, js_name = setTime)]
set_time(this: &Date, time: f64) -> f642270     pub fn set_time(this: &Date, time: f64) -> f64;
2271 
2272     /// The `setUTCDate()` method sets the day of the month for a specified date
2273     /// according to universal time.
2274     ///
2275     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCDate)
2276     #[wasm_bindgen(method, js_name = setUTCDate)]
set_utc_date(this: &Date, day: u32) -> f642277     pub fn set_utc_date(this: &Date, day: u32) -> f64;
2278 
2279     /// The `setUTCFullYear()` method sets the full year for a specified date according to universal time.
2280     ///
2281     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCFullYear)
2282     #[wasm_bindgen(method, js_name = setUTCFullYear)]
set_utc_full_year(this: &Date, year: u32) -> f642283     pub fn set_utc_full_year(this: &Date, year: u32) -> f64;
2284 
2285     /// The `setUTCFullYear()` method sets the full year for a specified date according to universal time.
2286     ///
2287     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCFullYear)
2288     #[wasm_bindgen(method, js_name = setUTCFullYear)]
set_utc_full_year_with_month(this: &Date, year: u32, month: i32) -> f642289     pub fn set_utc_full_year_with_month(this: &Date, year: u32, month: i32) -> f64;
2290 
2291     /// The `setUTCFullYear()` method sets the full year for a specified date according to universal time.
2292     ///
2293     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCFullYear)
2294     #[wasm_bindgen(method, js_name = setUTCFullYear)]
set_utc_full_year_with_month_date(this: &Date, year: u32, month: i32, date: i32) -> f642295     pub fn set_utc_full_year_with_month_date(this: &Date, year: u32, month: i32, date: i32) -> f64;
2296 
2297     /// The `setUTCHours()` method sets the hour for a specified date according to universal time,
2298     /// and returns the number of milliseconds since  January 1, 1970 00:00:00 UTC until the time
2299     /// represented by the updated Date instance.
2300     ///
2301     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCHours)
2302     #[wasm_bindgen(method, js_name = setUTCHours)]
set_utc_hours(this: &Date, hours: u32) -> f642303     pub fn set_utc_hours(this: &Date, hours: u32) -> f64;
2304 
2305     /// The `setUTCMilliseconds()` method sets the milliseconds for a specified date
2306     /// according to universal time.
2307     ///
2308     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCMilliseconds)
2309     #[wasm_bindgen(method, js_name = setUTCMilliseconds)]
set_utc_milliseconds(this: &Date, milliseconds: u32) -> f642310     pub fn set_utc_milliseconds(this: &Date, milliseconds: u32) -> f64;
2311 
2312     /// The `setUTCMinutes()` method sets the minutes for a specified date according to universal time.
2313     ///
2314     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCMinutes)
2315     #[wasm_bindgen(method, js_name = setUTCMinutes)]
set_utc_minutes(this: &Date, minutes: u32) -> f642316     pub fn set_utc_minutes(this: &Date, minutes: u32) -> f64;
2317 
2318     /// The `setUTCMonth()` method sets the month for a specified date according to universal time.
2319     ///
2320     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCMonth)
2321     #[wasm_bindgen(method, js_name = setUTCMonth)]
set_utc_month(this: &Date, month: u32) -> f642322     pub fn set_utc_month(this: &Date, month: u32) -> f64;
2323 
2324     /// The `setUTCSeconds()` method sets the seconds for a specified date according to universal time.
2325     ///
2326     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCSeconds)
2327     #[wasm_bindgen(method, js_name = setUTCSeconds)]
set_utc_seconds(this: &Date, seconds: u32) -> f642328     pub fn set_utc_seconds(this: &Date, seconds: u32) -> f64;
2329 
2330     /// The `toDateString()` method returns the date portion of a Date object
2331     /// in human readable form in American English.
2332     ///
2333     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toDateString)
2334     #[wasm_bindgen(method, js_name = toDateString)]
to_date_string(this: &Date) -> JsString2335     pub fn to_date_string(this: &Date) -> JsString;
2336 
2337     /// The `toISOString()` method returns a string in simplified extended ISO format (ISO
2338     /// 8601), which is always 24 or 27 characters long (YYYY-MM-DDTHH:mm:ss.sssZ or
2339     /// ±YYYYYY-MM-DDTHH:mm:ss.sssZ, respectively). The timezone is always zero UTC offset,
2340     /// as denoted by the suffix "Z"
2341     ///
2342     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
2343     #[wasm_bindgen(method, js_name = toISOString)]
to_iso_string(this: &Date) -> JsString2344     pub fn to_iso_string(this: &Date) -> JsString;
2345 
2346     /// The `toJSON()` method returns a string representation of the Date object.
2347     ///
2348     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toJSON)
2349     #[wasm_bindgen(method, js_name = toJSON)]
to_json(this: &Date) -> JsString2350     pub fn to_json(this: &Date) -> JsString;
2351 
2352     /// The `toLocaleDateString()` method returns a string with a language sensitive
2353     /// representation of the date portion of this date. The new locales and options
2354     /// arguments let applications specify the language whose formatting conventions
2355     /// should be used and allow to customize the behavior of the function.
2356     /// In older implementations, which ignore the locales and options arguments,
2357     /// the locale used and the form of the string
2358     /// returned are entirely implementation dependent.
2359     ///
2360     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString)
2361     #[wasm_bindgen(method, js_name = toLocaleDateString)]
to_locale_date_string(this: &Date, locale: &str, options: &JsValue) -> JsString2362     pub fn to_locale_date_string(this: &Date, locale: &str, options: &JsValue) -> JsString;
2363 
2364     /// The `toLocaleString()` method returns a string with a language sensitive
2365     /// representation of this date. The new locales and options arguments
2366     /// let applications specify the language whose formatting conventions
2367     /// should be used and customize the behavior of the function.
2368     /// In older implementations, which ignore the locales
2369     /// and options arguments, the locale used and the form of the string
2370     /// returned are entirely implementation dependent.
2371     ///
2372     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString)
2373     #[wasm_bindgen(method, js_name = toLocaleString)]
to_locale_string(this: &Date, locale: &str, options: &JsValue) -> JsString2374     pub fn to_locale_string(this: &Date, locale: &str, options: &JsValue) -> JsString;
2375 
2376     /// The `toLocaleTimeString()` method returns a string with a language sensitive
2377     /// representation of the time portion of this date. The new locales and options
2378     /// arguments let applications specify the language whose formatting conventions should be
2379     /// used and customize the behavior of the function. In older implementations, which ignore
2380     /// the locales and options arguments, the locale used and the form of the string
2381     /// returned are entirely implementation dependent.
2382     ///
2383     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleTimeString)
2384     #[wasm_bindgen(method, js_name = toLocaleTimeString)]
to_locale_time_string(this: &Date, locale: &str) -> JsString2385     pub fn to_locale_time_string(this: &Date, locale: &str) -> JsString;
2386 
2387     /// The `toString()` method returns a string representing
2388     /// the specified Date object.
2389     ///
2390     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toString)
2391     #[wasm_bindgen(method, js_name = toString)]
to_string(this: &Date) -> JsString2392     pub fn to_string(this: &Date) -> JsString;
2393 
2394     /// The `toTimeString()` method returns the time portion of a Date object in human
2395     /// readable form in American English.
2396     ///
2397     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toTimeString)
2398     #[wasm_bindgen(method, js_name = toTimeString)]
to_time_string(this: &Date) -> JsString2399     pub fn to_time_string(this: &Date) -> JsString;
2400 
2401     /// The `toUTCString()` method converts a date to a string,
2402     /// using the UTC time zone.
2403     ///
2404     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toUTCString)
2405     #[wasm_bindgen(method, js_name = toUTCString)]
to_utc_string(this: &Date) -> JsString2406     pub fn to_utc_string(this: &Date) -> JsString;
2407 
2408     /// The `Date.UTC()` method accepts the same parameters as the
2409     /// longest form of the constructor, and returns the number of
2410     /// milliseconds in a `Date` object since January 1, 1970,
2411     /// 00:00:00, universal time.
2412     ///
2413     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/UTC)
2414     #[wasm_bindgen(static_method_of = Date, js_name = UTC)]
utc(year: f64, month: f64) -> f642415     pub fn utc(year: f64, month: f64) -> f64;
2416 
2417     /// The `valueOf()` method  returns the primitive value of
2418     /// a Date object.
2419     ///
2420     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/valueOf)
2421     #[wasm_bindgen(method, js_name = valueOf)]
value_of(this: &Date) -> f642422     pub fn value_of(this: &Date) -> f64;
2423 }
2424 
2425 // Object.
2426 #[wasm_bindgen]
2427 extern "C" {
2428     #[wasm_bindgen(typescript_type = "object")]
2429     #[derive(Clone, Debug)]
2430     pub type Object;
2431 
2432     /// The `Object.assign()` method is used to copy the values of all enumerable
2433     /// own properties from one or more source objects to a target object. It
2434     /// will return the target object.
2435     ///
2436     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign)
2437     #[wasm_bindgen(static_method_of = Object)]
assign(target: &Object, source: &Object) -> Object2438     pub fn assign(target: &Object, source: &Object) -> Object;
2439 
2440     /// The `Object.assign()` method is used to copy the values of all enumerable
2441     /// own properties from one or more source objects to a target object. It
2442     /// will return the target object.
2443     ///
2444     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign)
2445     #[wasm_bindgen(static_method_of = Object, js_name = assign)]
assign2(target: &Object, source1: &Object, source2: &Object) -> Object2446     pub fn assign2(target: &Object, source1: &Object, source2: &Object) -> Object;
2447 
2448     /// The `Object.assign()` method is used to copy the values of all enumerable
2449     /// own properties from one or more source objects to a target object. It
2450     /// will return the target object.
2451     ///
2452     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign)
2453     #[wasm_bindgen(static_method_of = Object, js_name = assign)]
assign3(target: &Object, source1: &Object, source2: &Object, source3: &Object) -> Object2454     pub fn assign3(target: &Object, source1: &Object, source2: &Object, source3: &Object)
2455         -> Object;
2456 
2457     /// The constructor property returns a reference to the `Object` constructor
2458     /// function that created the instance object.
2459     ///
2460     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/constructor)
2461     #[wasm_bindgen(method, getter)]
constructor(this: &Object) -> Function2462     pub fn constructor(this: &Object) -> Function;
2463 
2464     /// The `Object.create()` method creates a new object, using an existing
2465     /// object to provide the newly created object's prototype.
2466     ///
2467     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create)
2468     #[wasm_bindgen(static_method_of = Object)]
create(prototype: &Object) -> Object2469     pub fn create(prototype: &Object) -> Object;
2470 
2471     /// The static method `Object.defineProperty()` defines a new
2472     /// property directly on an object, or modifies an existing
2473     /// property on an object, and returns the object.
2474     ///
2475     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty)
2476     #[wasm_bindgen(static_method_of = Object, js_name = defineProperty)]
define_property(obj: &Object, prop: &JsValue, descriptor: &Object) -> Object2477     pub fn define_property(obj: &Object, prop: &JsValue, descriptor: &Object) -> Object;
2478 
2479     /// The `Object.defineProperties()` method defines new or modifies
2480     /// existing properties directly on an object, returning the
2481     /// object.
2482     ///
2483     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperties)
2484     #[wasm_bindgen(static_method_of = Object, js_name = defineProperties)]
define_properties(obj: &Object, props: &Object) -> Object2485     pub fn define_properties(obj: &Object, props: &Object) -> Object;
2486 
2487     /// The `Object.entries()` method returns an array of a given
2488     /// object's own enumerable property [key, value] pairs, in the
2489     /// same order as that provided by a for...in loop (the difference
2490     /// being that a for-in loop enumerates properties in the
2491     /// prototype chain as well).
2492     ///
2493     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries)
2494     #[wasm_bindgen(static_method_of = Object)]
entries(object: &Object) -> Array2495     pub fn entries(object: &Object) -> Array;
2496 
2497     /// The `Object.freeze()` method freezes an object: that is, prevents new
2498     /// properties from being added to it; prevents existing properties from
2499     /// being removed; and prevents existing properties, or their enumerability,
2500     /// configurability, or writability, from being changed, it also prevents
2501     /// the prototype from being changed. The method returns the passed object.
2502     ///
2503     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze)
2504     #[wasm_bindgen(static_method_of = Object)]
freeze(value: &Object) -> Object2505     pub fn freeze(value: &Object) -> Object;
2506 
2507     /// The `Object.fromEntries()` method transforms a list of key-value pairs
2508     /// into an object.
2509     ///
2510     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/fromEntries)
2511     #[wasm_bindgen(static_method_of = Object, catch, js_name = fromEntries)]
from_entries(iterable: &JsValue) -> Result<Object, JsValue>2512     pub fn from_entries(iterable: &JsValue) -> Result<Object, JsValue>;
2513 
2514     /// The `Object.getOwnPropertyDescriptor()` method returns a
2515     /// property descriptor for an own property (that is, one directly
2516     /// present on an object and not in the object's prototype chain)
2517     /// of a given object.
2518     ///
2519     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor)
2520     #[wasm_bindgen(static_method_of = Object, js_name = getOwnPropertyDescriptor)]
get_own_property_descriptor(obj: &Object, prop: &JsValue) -> JsValue2521     pub fn get_own_property_descriptor(obj: &Object, prop: &JsValue) -> JsValue;
2522 
2523     /// The `Object.getOwnPropertyDescriptors()` method returns all own
2524     /// property descriptors of a given object.
2525     ///
2526     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptors)
2527     #[wasm_bindgen(static_method_of = Object, js_name = getOwnPropertyDescriptors)]
get_own_property_descriptors(obj: &Object) -> JsValue2528     pub fn get_own_property_descriptors(obj: &Object) -> JsValue;
2529 
2530     /// The `Object.getOwnPropertyNames()` method returns an array of
2531     /// all properties (including non-enumerable properties except for
2532     /// those which use Symbol) found directly upon a given object.
2533     ///
2534     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames)
2535     #[wasm_bindgen(static_method_of = Object, js_name = getOwnPropertyNames)]
get_own_property_names(obj: &Object) -> Array2536     pub fn get_own_property_names(obj: &Object) -> Array;
2537 
2538     /// The `Object.getOwnPropertySymbols()` method returns an array of
2539     /// all symbol properties found directly upon a given object.
2540     ///
2541     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertySymbols)
2542     #[wasm_bindgen(static_method_of = Object, js_name = getOwnPropertySymbols)]
get_own_property_symbols(obj: &Object) -> Array2543     pub fn get_own_property_symbols(obj: &Object) -> Array;
2544 
2545     /// The `Object.getPrototypeOf()` method returns the prototype
2546     /// (i.e. the value of the internal [[Prototype]] property) of the
2547     /// specified object.
2548     ///
2549     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getPrototypeOf)
2550     #[wasm_bindgen(static_method_of = Object, js_name = getPrototypeOf)]
get_prototype_of(obj: &JsValue) -> Object2551     pub fn get_prototype_of(obj: &JsValue) -> Object;
2552 
2553     /// The `hasOwnProperty()` method returns a boolean indicating whether the
2554     /// object has the specified property as its own property (as opposed to
2555     /// inheriting it).
2556     ///
2557     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty)
2558     #[wasm_bindgen(method, js_name = hasOwnProperty)]
has_own_property(this: &Object, property: &JsValue) -> bool2559     pub fn has_own_property(this: &Object, property: &JsValue) -> bool;
2560 
2561     /// The `Object.is()` method determines whether two values are the same value.
2562     ///
2563     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is)
2564     #[wasm_bindgen(static_method_of = Object)]
is(value_1: &JsValue, value_2: &JsValue) -> bool2565     pub fn is(value_1: &JsValue, value_2: &JsValue) -> bool;
2566 
2567     /// The `Object.isExtensible()` method determines if an object is extensible
2568     /// (whether it can have new properties added to it).
2569     ///
2570     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isExtensible)
2571     #[wasm_bindgen(static_method_of = Object, js_name = isExtensible)]
is_extensible(object: &Object) -> bool2572     pub fn is_extensible(object: &Object) -> bool;
2573 
2574     /// The `Object.isFrozen()` determines if an object is frozen.
2575     ///
2576     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isFrozen)
2577     #[wasm_bindgen(static_method_of = Object, js_name = isFrozen)]
is_frozen(object: &Object) -> bool2578     pub fn is_frozen(object: &Object) -> bool;
2579 
2580     /// The `Object.isSealed()` method determines if an object is sealed.
2581     ///
2582     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isSealed)
2583     #[wasm_bindgen(static_method_of = Object, js_name = isSealed)]
is_sealed(object: &Object) -> bool2584     pub fn is_sealed(object: &Object) -> bool;
2585 
2586     /// The `isPrototypeOf()` method checks if an object exists in another
2587     /// object's prototype chain.
2588     ///
2589     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isPrototypeOf)
2590     #[wasm_bindgen(method, js_name = isPrototypeOf)]
is_prototype_of(this: &Object, value: &JsValue) -> bool2591     pub fn is_prototype_of(this: &Object, value: &JsValue) -> bool;
2592 
2593     /// The `Object.keys()` method returns an array of a given object's property
2594     /// names, in the same order as we get with a normal loop.
2595     ///
2596     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys)
2597     #[wasm_bindgen(static_method_of = Object)]
keys(object: &Object) -> Array2598     pub fn keys(object: &Object) -> Array;
2599 
2600     /// The [`Object`] constructor creates an object wrapper.
2601     ///
2602     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)
2603     #[wasm_bindgen(constructor)]
new() -> Object2604     pub fn new() -> Object;
2605 
2606     /// The `Object.preventExtensions()` method prevents new properties from
2607     /// ever being added to an object (i.e. prevents future extensions to the
2608     /// object).
2609     ///
2610     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/preventExtensions)
2611     #[wasm_bindgen(static_method_of = Object, js_name = preventExtensions)]
prevent_extensions(object: &Object)2612     pub fn prevent_extensions(object: &Object);
2613 
2614     /// The `propertyIsEnumerable()` method returns a Boolean indicating
2615     /// whether the specified property is enumerable.
2616     ///
2617     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/propertyIsEnumerable)
2618     #[wasm_bindgen(method, js_name = propertyIsEnumerable)]
property_is_enumerable(this: &Object, property: &JsValue) -> bool2619     pub fn property_is_enumerable(this: &Object, property: &JsValue) -> bool;
2620 
2621     /// The `Object.seal()` method seals an object, preventing new properties
2622     /// from being added to it and marking all existing properties as
2623     /// non-configurable.  Values of present properties can still be changed as
2624     /// long as they are writable.
2625     ///
2626     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/seal)
2627     #[wasm_bindgen(static_method_of = Object)]
seal(value: &Object) -> Object2628     pub fn seal(value: &Object) -> Object;
2629 
2630     /// The `Object.setPrototypeOf()` method sets the prototype (i.e., the
2631     /// internal `[[Prototype]]` property) of a specified object to another
2632     /// object or `null`.
2633     ///
2634     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/setPrototypeOf)
2635     #[wasm_bindgen(static_method_of = Object, js_name = setPrototypeOf)]
set_prototype_of(object: &Object, prototype: &Object) -> Object2636     pub fn set_prototype_of(object: &Object, prototype: &Object) -> Object;
2637 
2638     /// The `toLocaleString()` method returns a string representing the object.
2639     /// This method is meant to be overridden by derived objects for
2640     /// locale-specific purposes.
2641     ///
2642     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toLocaleString)
2643     #[wasm_bindgen(method, js_name = toLocaleString)]
to_locale_string(this: &Object) -> JsString2644     pub fn to_locale_string(this: &Object) -> JsString;
2645 
2646     /// The `toString()` method returns a string representing the object.
2647     ///
2648     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString)
2649     #[wasm_bindgen(method, js_name = toString)]
to_string(this: &Object) -> JsString2650     pub fn to_string(this: &Object) -> JsString;
2651 
2652     /// The `valueOf()` method returns the primitive value of the
2653     /// specified object.
2654     ///
2655     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/valueOf)
2656     #[wasm_bindgen(method, js_name = valueOf)]
value_of(this: &Object) -> Object2657     pub fn value_of(this: &Object) -> Object;
2658 
2659     /// The `Object.values()` method returns an array of a given object's own
2660     /// enumerable property values, in the same order as that provided by a
2661     /// `for...in` loop (the difference being that a for-in loop enumerates
2662     /// properties in the prototype chain as well).
2663     ///
2664     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/values)
2665     #[wasm_bindgen(static_method_of = Object)]
values(object: &Object) -> Array2666     pub fn values(object: &Object) -> Array;
2667 }
2668 
2669 impl Object {
2670     /// Returns the `Object` value of this JS value if it's an instance of an
2671     /// object.
2672     ///
2673     /// If this JS value is not an instance of an object then this returns
2674     /// `None`.
try_from(val: &JsValue) -> Option<&Object>2675     pub fn try_from(val: &JsValue) -> Option<&Object> {
2676         if val.is_object() {
2677             Some(val.unchecked_ref())
2678         } else {
2679             None
2680         }
2681     }
2682 }
2683 
2684 impl PartialEq for Object {
2685     #[inline]
eq(&self, other: &Object) -> bool2686     fn eq(&self, other: &Object) -> bool {
2687         Object::is(self.as_ref(), other.as_ref())
2688     }
2689 }
2690 
2691 impl Eq for Object {}
2692 
2693 // Proxy
2694 #[wasm_bindgen]
2695 extern "C" {
2696     #[wasm_bindgen(typescript_type = "ProxyConstructor")]
2697     #[derive(Clone, Debug)]
2698     pub type Proxy;
2699 
2700     /// The [`Proxy`] object is used to define custom behavior for fundamental
2701     /// operations (e.g. property lookup, assignment, enumeration, function
2702     /// invocation, etc).
2703     ///
2704     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy)
2705     #[wasm_bindgen(constructor)]
new(target: &JsValue, handler: &Object) -> Proxy2706     pub fn new(target: &JsValue, handler: &Object) -> Proxy;
2707 
2708     /// The `Proxy.revocable()` method is used to create a revocable [`Proxy`]
2709     /// object.
2710     ///
2711     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/revocable)
2712     #[wasm_bindgen(static_method_of = Proxy)]
revocable(target: &JsValue, handler: &Object) -> Object2713     pub fn revocable(target: &JsValue, handler: &Object) -> Object;
2714 }
2715 
2716 // RangeError
2717 #[wasm_bindgen]
2718 extern "C" {
2719     /// The `RangeError` object indicates an error when a value is not in the set
2720     /// or range of allowed values.
2721     ///
2722     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError)
2723     #[wasm_bindgen(extends = Error, extends = Object, typescript_type = "RangeError")]
2724     #[derive(Clone, Debug, PartialEq, Eq)]
2725     pub type RangeError;
2726 
2727     /// The `RangeError` object indicates an error when a value is not in the set
2728     /// or range of allowed values.
2729     ///
2730     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError)
2731     #[wasm_bindgen(constructor)]
new(message: &str) -> RangeError2732     pub fn new(message: &str) -> RangeError;
2733 }
2734 
2735 // ReferenceError
2736 #[wasm_bindgen]
2737 extern "C" {
2738     /// The `ReferenceError` object represents an error when a non-existent
2739     /// variable is referenced.
2740     ///
2741     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError)
2742     #[wasm_bindgen(extends = Error, extends = Object, typescript_type = "ReferenceError")]
2743     #[derive(Clone, Debug, PartialEq, Eq)]
2744     pub type ReferenceError;
2745 
2746     /// The `ReferenceError` object represents an error when a non-existent
2747     /// variable is referenced.
2748     ///
2749     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError)
2750     #[wasm_bindgen(constructor)]
new(message: &str) -> ReferenceError2751     pub fn new(message: &str) -> ReferenceError;
2752 }
2753 
2754 #[allow(non_snake_case)]
2755 pub mod Reflect {
2756     use super::*;
2757 
2758     // Reflect
2759     #[wasm_bindgen]
2760     extern "C" {
2761         /// The static `Reflect.apply()` method calls a target function with
2762         /// arguments as specified.
2763         ///
2764         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/apply)
2765         #[wasm_bindgen(js_namespace = Reflect, catch)]
apply( target: &Function, this_argument: &JsValue, arguments_list: &Array, ) -> Result<JsValue, JsValue>2766         pub fn apply(
2767             target: &Function,
2768             this_argument: &JsValue,
2769             arguments_list: &Array,
2770         ) -> Result<JsValue, JsValue>;
2771 
2772         /// The static `Reflect.construct()` method acts like the new operator, but
2773         /// as a function.  It is equivalent to calling `new target(...args)`. It
2774         /// gives also the added option to specify a different prototype.
2775         ///
2776         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/construct)
2777         #[wasm_bindgen(js_namespace = Reflect, catch)]
construct(target: &Function, arguments_list: &Array) -> Result<JsValue, JsValue>2778         pub fn construct(target: &Function, arguments_list: &Array) -> Result<JsValue, JsValue>;
2779 
2780         /// The static `Reflect.construct()` method acts like the new operator, but
2781         /// as a function.  It is equivalent to calling `new target(...args)`. It
2782         /// gives also the added option to specify a different prototype.
2783         ///
2784         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/construct)
2785         #[wasm_bindgen(js_namespace = Reflect, js_name = construct, catch)]
construct_with_new_target( target: &Function, arguments_list: &Array, new_target: &Function, ) -> Result<JsValue, JsValue>2786         pub fn construct_with_new_target(
2787             target: &Function,
2788             arguments_list: &Array,
2789             new_target: &Function,
2790         ) -> Result<JsValue, JsValue>;
2791 
2792         /// The static `Reflect.defineProperty()` method is like
2793         /// `Object.defineProperty()` but returns a `Boolean`.
2794         ///
2795         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/defineProperty)
2796         #[wasm_bindgen(js_namespace = Reflect, js_name = defineProperty, catch)]
define_property( target: &Object, property_key: &JsValue, attributes: &Object, ) -> Result<bool, JsValue>2797         pub fn define_property(
2798             target: &Object,
2799             property_key: &JsValue,
2800             attributes: &Object,
2801         ) -> Result<bool, JsValue>;
2802 
2803         /// The static `Reflect.deleteProperty()` method allows to delete
2804         /// properties.  It is like the `delete` operator as a function.
2805         ///
2806         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/deleteProperty)
2807         #[wasm_bindgen(js_namespace = Reflect, js_name = deleteProperty, catch)]
delete_property(target: &Object, key: &JsValue) -> Result<bool, JsValue>2808         pub fn delete_property(target: &Object, key: &JsValue) -> Result<bool, JsValue>;
2809 
2810         /// The static `Reflect.get()` method works like getting a property from
2811         /// an object (`target[propertyKey]`) as a function.
2812         ///
2813         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/get)
2814         #[wasm_bindgen(js_namespace = Reflect, catch)]
get(target: &JsValue, key: &JsValue) -> Result<JsValue, JsValue>2815         pub fn get(target: &JsValue, key: &JsValue) -> Result<JsValue, JsValue>;
2816 
2817         /// The same as [`get`](fn.get.html)
2818         /// except the key is an `f64`, which is slightly faster.
2819         #[wasm_bindgen(js_namespace = Reflect, js_name = "get", catch)]
get_f64(target: &JsValue, key: f64) -> Result<JsValue, JsValue>2820         pub fn get_f64(target: &JsValue, key: f64) -> Result<JsValue, JsValue>;
2821 
2822         /// The same as [`get`](fn.get.html)
2823         /// except the key is a `u32`, which is slightly faster.
2824         #[wasm_bindgen(js_namespace = Reflect, js_name = "get", catch)]
get_u32(target: &JsValue, key: u32) -> Result<JsValue, JsValue>2825         pub fn get_u32(target: &JsValue, key: u32) -> Result<JsValue, JsValue>;
2826 
2827         /// The static `Reflect.getOwnPropertyDescriptor()` method is similar to
2828         /// `Object.getOwnPropertyDescriptor()`. It returns a property descriptor
2829         /// of the given property if it exists on the object, `undefined` otherwise.
2830         ///
2831         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/getOwnPropertyDescriptor)
2832         #[wasm_bindgen(js_namespace = Reflect, js_name = getOwnPropertyDescriptor, catch)]
get_own_property_descriptor( target: &Object, property_key: &JsValue, ) -> Result<JsValue, JsValue>2833         pub fn get_own_property_descriptor(
2834             target: &Object,
2835             property_key: &JsValue,
2836         ) -> Result<JsValue, JsValue>;
2837 
2838         /// The static `Reflect.getPrototypeOf()` method is almost the same
2839         /// method as `Object.getPrototypeOf()`. It returns the prototype
2840         /// (i.e. the value of the internal `[[Prototype]]` property) of
2841         /// the specified object.
2842         ///
2843         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/getPrototypeOf)
2844         #[wasm_bindgen(js_namespace = Reflect, js_name = getPrototypeOf, catch)]
get_prototype_of(target: &JsValue) -> Result<Object, JsValue>2845         pub fn get_prototype_of(target: &JsValue) -> Result<Object, JsValue>;
2846 
2847         /// The static `Reflect.has()` method works like the in operator as a
2848         /// function.
2849         ///
2850         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/has)
2851         #[wasm_bindgen(js_namespace = Reflect, catch)]
has(target: &JsValue, property_key: &JsValue) -> Result<bool, JsValue>2852         pub fn has(target: &JsValue, property_key: &JsValue) -> Result<bool, JsValue>;
2853 
2854         /// The static `Reflect.isExtensible()` method determines if an object is
2855         /// extensible (whether it can have new properties added to it). It is
2856         /// similar to `Object.isExtensible()`, but with some differences.
2857         ///
2858         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/isExtensible)
2859         #[wasm_bindgen(js_namespace = Reflect, js_name = isExtensible, catch)]
is_extensible(target: &Object) -> Result<bool, JsValue>2860         pub fn is_extensible(target: &Object) -> Result<bool, JsValue>;
2861 
2862         /// The static `Reflect.ownKeys()` method returns an array of the
2863         /// target object's own property keys.
2864         ///
2865         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/ownKeys)
2866         #[wasm_bindgen(js_namespace = Reflect, js_name = ownKeys, catch)]
own_keys(target: &JsValue) -> Result<Array, JsValue>2867         pub fn own_keys(target: &JsValue) -> Result<Array, JsValue>;
2868 
2869         /// The static `Reflect.preventExtensions()` method prevents new
2870         /// properties from ever being added to an object (i.e. prevents
2871         /// future extensions to the object). It is similar to
2872         /// `Object.preventExtensions()`, but with some differences.
2873         ///
2874         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/preventExtensions)
2875         #[wasm_bindgen(js_namespace = Reflect, js_name = preventExtensions, catch)]
prevent_extensions(target: &Object) -> Result<bool, JsValue>2876         pub fn prevent_extensions(target: &Object) -> Result<bool, JsValue>;
2877 
2878         /// The static `Reflect.set()` method works like setting a
2879         /// property on an object.
2880         ///
2881         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/set)
2882         #[wasm_bindgen(js_namespace = Reflect, catch)]
set( target: &JsValue, property_key: &JsValue, value: &JsValue, ) -> Result<bool, JsValue>2883         pub fn set(
2884             target: &JsValue,
2885             property_key: &JsValue,
2886             value: &JsValue,
2887         ) -> Result<bool, JsValue>;
2888 
2889         /// The same as [`set`](fn.set.html)
2890         /// except the key is an `f64`, which is slightly faster.
2891         #[wasm_bindgen(js_namespace = Reflect, js_name = "set", catch)]
set_f64( target: &JsValue, property_key: f64, value: &JsValue, ) -> Result<bool, JsValue>2892         pub fn set_f64(
2893             target: &JsValue,
2894             property_key: f64,
2895             value: &JsValue,
2896         ) -> Result<bool, JsValue>;
2897 
2898         /// The same as [`set`](fn.set.html)
2899         /// except the key is a `u32`, which is slightly faster.
2900         #[wasm_bindgen(js_namespace = Reflect, js_name = "set", catch)]
set_u32( target: &JsValue, property_key: u32, value: &JsValue, ) -> Result<bool, JsValue>2901         pub fn set_u32(
2902             target: &JsValue,
2903             property_key: u32,
2904             value: &JsValue,
2905         ) -> Result<bool, JsValue>;
2906 
2907         /// The static `Reflect.set()` method works like setting a
2908         /// property on an object.
2909         ///
2910         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/set)
2911         #[wasm_bindgen(js_namespace = Reflect, js_name = set, catch)]
set_with_receiver( target: &JsValue, property_key: &JsValue, value: &JsValue, receiver: &JsValue, ) -> Result<bool, JsValue>2912         pub fn set_with_receiver(
2913             target: &JsValue,
2914             property_key: &JsValue,
2915             value: &JsValue,
2916             receiver: &JsValue,
2917         ) -> Result<bool, JsValue>;
2918 
2919         /// The static `Reflect.setPrototypeOf()` method is the same
2920         /// method as `Object.setPrototypeOf()`. It sets the prototype
2921         /// (i.e., the internal `[[Prototype]]` property) of a specified
2922         /// object to another object or to null.
2923         ///
2924         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/setPrototypeOf)
2925         #[wasm_bindgen(js_namespace = Reflect, js_name = setPrototypeOf, catch)]
set_prototype_of(target: &Object, prototype: &JsValue) -> Result<bool, JsValue>2926         pub fn set_prototype_of(target: &Object, prototype: &JsValue) -> Result<bool, JsValue>;
2927     }
2928 }
2929 
2930 // RegExp
2931 #[wasm_bindgen]
2932 extern "C" {
2933     #[wasm_bindgen(extends = Object, typescript_type = "RegExp")]
2934     #[derive(Clone, Debug, PartialEq, Eq)]
2935     pub type RegExp;
2936 
2937     /// The `exec()` method executes a search for a match in a specified
2938     /// string. Returns a result array, or null.
2939     ///
2940     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec)
2941     #[wasm_bindgen(method)]
exec(this: &RegExp, text: &str) -> Option<Array>2942     pub fn exec(this: &RegExp, text: &str) -> Option<Array>;
2943 
2944     /// The flags property returns a string consisting of the flags of
2945     /// the current regular expression object.
2946     ///
2947     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/flags)
2948     #[wasm_bindgen(method, getter)]
flags(this: &RegExp) -> JsString2949     pub fn flags(this: &RegExp) -> JsString;
2950 
2951     /// The global property indicates whether or not the "g" flag is
2952     /// used with the regular expression. global is a read-only
2953     /// property of an individual regular expression instance.
2954     ///
2955     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/global)
2956     #[wasm_bindgen(method, getter)]
global(this: &RegExp) -> bool2957     pub fn global(this: &RegExp) -> bool;
2958 
2959     /// The ignoreCase property indicates whether or not the "i" flag
2960     /// is used with the regular expression. ignoreCase is a read-only
2961     /// property of an individual regular expression instance.
2962     ///
2963     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/ignoreCase)
2964     #[wasm_bindgen(method, getter, js_name = ignoreCase)]
ignore_case(this: &RegExp) -> bool2965     pub fn ignore_case(this: &RegExp) -> bool;
2966 
2967     /// The non-standard input property is a static property of
2968     /// regular expressions that contains the string against which a
2969     /// regular expression is matched. RegExp.$_ is an alias for this
2970     /// property.
2971     ///
2972     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/input)
2973     #[wasm_bindgen(static_method_of = RegExp, getter)]
input() -> JsString2974     pub fn input() -> JsString;
2975 
2976     /// The lastIndex is a read/write integer property of regular expression
2977     /// instances that specifies the index at which to start the next match.
2978     ///
2979     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastIndex)
2980     #[wasm_bindgen(structural, getter = lastIndex, method)]
last_index(this: &RegExp) -> u322981     pub fn last_index(this: &RegExp) -> u32;
2982 
2983     /// The lastIndex is a read/write integer property of regular expression
2984     /// instances that specifies the index at which to start the next match.
2985     ///
2986     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastIndex)
2987     #[wasm_bindgen(structural, setter = lastIndex, method)]
set_last_index(this: &RegExp, index: u32)2988     pub fn set_last_index(this: &RegExp, index: u32);
2989 
2990     /// The non-standard lastMatch property is a static and read-only
2991     /// property of regular expressions that contains the last matched
2992     /// characters. `RegExp.$&` is an alias for this property.
2993     ///
2994     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastMatch)
2995     #[wasm_bindgen(static_method_of = RegExp, getter, js_name = lastMatch)]
last_match() -> JsString2996     pub fn last_match() -> JsString;
2997 
2998     /// The non-standard lastParen property is a static and read-only
2999     /// property of regular expressions that contains the last
3000     /// parenthesized substring match, if any. `RegExp.$+` is an alias
3001     /// for this property.
3002     ///
3003     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastParen)
3004     #[wasm_bindgen(static_method_of = RegExp, getter, js_name = lastParen)]
last_paren() -> JsString3005     pub fn last_paren() -> JsString;
3006 
3007     /// The non-standard leftContext property is a static and
3008     /// read-only property of regular expressions that contains the
3009     /// substring preceding the most recent match. `RegExp.$`` is an
3010     /// alias for this property.
3011     ///
3012     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/leftContext)
3013     #[wasm_bindgen(static_method_of = RegExp, getter, js_name = leftContext)]
left_context() -> JsString3014     pub fn left_context() -> JsString;
3015 
3016     /// The multiline property indicates whether or not the "m" flag
3017     /// is used with the regular expression. multiline is a read-only
3018     /// property of an individual regular expression instance.
3019     ///
3020     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/multiline)
3021     #[wasm_bindgen(method, getter)]
multiline(this: &RegExp) -> bool3022     pub fn multiline(this: &RegExp) -> bool;
3023 
3024     /// The non-standard $1, $2, $3, $4, $5, $6, $7, $8, $9 properties
3025     /// are static and read-only properties of regular expressions
3026     /// that contain parenthesized substring matches.
3027     ///
3028     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/n)
3029     #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$1")]
n1() -> JsString3030     pub fn n1() -> JsString;
3031     #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$2")]
n2() -> JsString3032     pub fn n2() -> JsString;
3033     #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$3")]
n3() -> JsString3034     pub fn n3() -> JsString;
3035     #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$4")]
n4() -> JsString3036     pub fn n4() -> JsString;
3037     #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$5")]
n5() -> JsString3038     pub fn n5() -> JsString;
3039     #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$6")]
n6() -> JsString3040     pub fn n6() -> JsString;
3041     #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$7")]
n7() -> JsString3042     pub fn n7() -> JsString;
3043     #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$8")]
n8() -> JsString3044     pub fn n8() -> JsString;
3045     #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$9")]
n9() -> JsString3046     pub fn n9() -> JsString;
3047 
3048     /// The `RegExp` constructor creates a regular expression object for matching text with a pattern.
3049     ///
3050     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp)
3051     #[wasm_bindgen(constructor)]
new(pattern: &str, flags: &str) -> RegExp3052     pub fn new(pattern: &str, flags: &str) -> RegExp;
3053     #[wasm_bindgen(constructor)]
new_regexp(pattern: &RegExp, flags: &str) -> RegExp3054     pub fn new_regexp(pattern: &RegExp, flags: &str) -> RegExp;
3055 
3056     /// The non-standard rightContext property is a static and
3057     /// read-only property of regular expressions that contains the
3058     /// substring following the most recent match. `RegExp.$'` is an
3059     /// alias for this property.
3060     ///
3061     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/rightContext)
3062     #[wasm_bindgen(static_method_of = RegExp, getter, js_name = rightContext)]
right_context() -> JsString3063     pub fn right_context() -> JsString;
3064 
3065     /// The source property returns a String containing the source
3066     /// text of the regexp object, and it doesn't contain the two
3067     /// forward slashes on both sides and any flags.
3068     ///
3069     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/source)
3070     #[wasm_bindgen(method, getter)]
source(this: &RegExp) -> JsString3071     pub fn source(this: &RegExp) -> JsString;
3072 
3073     /// The sticky property reflects whether or not the search is
3074     /// sticky (searches in strings only from the index indicated by
3075     /// the lastIndex property of this regular expression). sticky is
3076     /// a read-only property of an individual regular expression
3077     /// object.
3078     ///
3079     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/sticky)
3080     #[wasm_bindgen(method, getter)]
sticky(this: &RegExp) -> bool3081     pub fn sticky(this: &RegExp) -> bool;
3082 
3083     /// The `test()` method executes a search for a match between a
3084     /// regular expression and a specified string. Returns true or
3085     /// false.
3086     ///
3087     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test)
3088     #[wasm_bindgen(method)]
test(this: &RegExp, text: &str) -> bool3089     pub fn test(this: &RegExp, text: &str) -> bool;
3090 
3091     /// The `toString()` method returns a string representing the
3092     /// regular expression.
3093     ///
3094     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/toString)
3095     #[wasm_bindgen(method, js_name = toString)]
to_string(this: &RegExp) -> JsString3096     pub fn to_string(this: &RegExp) -> JsString;
3097 
3098     /// The unicode property indicates whether or not the "u" flag is
3099     /// used with a regular expression. unicode is a read-only
3100     /// property of an individual regular expression instance.
3101     ///
3102     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/unicode)
3103     #[wasm_bindgen(method, getter)]
unicode(this: &RegExp) -> bool3104     pub fn unicode(this: &RegExp) -> bool;
3105 }
3106 
3107 // Set
3108 #[wasm_bindgen]
3109 extern "C" {
3110     #[wasm_bindgen(extends = Object, typescript_type = "Set<any>")]
3111     #[derive(Clone, Debug, PartialEq, Eq)]
3112     pub type Set;
3113 
3114     /// The `add()` method appends a new element with a specified value to the
3115     /// end of a [`Set`] object.
3116     ///
3117     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/add)
3118     #[wasm_bindgen(method)]
add(this: &Set, value: &JsValue) -> Set3119     pub fn add(this: &Set, value: &JsValue) -> Set;
3120 
3121     /// The `clear()` method removes all elements from a [`Set`] object.
3122     ///
3123     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/clear)
3124     #[wasm_bindgen(method)]
clear(this: &Set)3125     pub fn clear(this: &Set);
3126 
3127     /// The `delete()` method removes the specified element from a [`Set`]
3128     /// object.
3129     ///
3130     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/delete)
3131     #[wasm_bindgen(method)]
delete(this: &Set, value: &JsValue) -> bool3132     pub fn delete(this: &Set, value: &JsValue) -> bool;
3133 
3134     /// The `forEach()` method executes a provided function once for each value
3135     /// in the Set object, in insertion order.
3136     ///
3137     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/forEach)
3138     #[wasm_bindgen(method, js_name = forEach)]
for_each(this: &Set, callback: &mut dyn FnMut(JsValue, JsValue, Set))3139     pub fn for_each(this: &Set, callback: &mut dyn FnMut(JsValue, JsValue, Set));
3140 
3141     /// The `has()` method returns a boolean indicating whether an element with
3142     /// the specified value exists in a [`Set`] object or not.
3143     ///
3144     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/has)
3145     #[wasm_bindgen(method)]
has(this: &Set, value: &JsValue) -> bool3146     pub fn has(this: &Set, value: &JsValue) -> bool;
3147 
3148     /// The [`Set`] object lets you store unique values of any type, whether
3149     /// primitive values or object references.
3150     ///
3151     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set)
3152     #[wasm_bindgen(constructor)]
new(init: &JsValue) -> Set3153     pub fn new(init: &JsValue) -> Set;
3154 
3155     /// The size accessor property returns the number of elements in a [`Set`]
3156     /// object.
3157     ///
3158     /// [MDN documentation](https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Set/size)
3159     #[wasm_bindgen(method, getter, structural)]
size(this: &Set) -> u323160     pub fn size(this: &Set) -> u32;
3161 }
3162 
3163 // SetIterator
3164 #[wasm_bindgen]
3165 extern "C" {
3166     /// The `entries()` method returns a new Iterator object that contains an
3167     /// array of [value, value] for each element in the Set object, in insertion
3168     /// order. For Set objects there is no key like in Map objects. However, to
3169     /// keep the API similar to the Map object, each entry has the same value
3170     /// for its key and value here, so that an array [value, value] is returned.
3171     ///
3172     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/entries)
3173     #[wasm_bindgen(method)]
entries(set: &Set) -> Iterator3174     pub fn entries(set: &Set) -> Iterator;
3175 
3176     /// The `keys()` method is an alias for this method (for similarity with
3177     /// Map objects); it behaves exactly the same and returns values
3178     /// of Set elements.
3179     ///
3180     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/values)
3181     #[wasm_bindgen(method)]
keys(set: &Set) -> Iterator3182     pub fn keys(set: &Set) -> Iterator;
3183 
3184     /// The `values()` method returns a new Iterator object that contains the
3185     /// values for each element in the Set object in insertion order.
3186     ///
3187     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/values)
3188     #[wasm_bindgen(method)]
values(set: &Set) -> Iterator3189     pub fn values(set: &Set) -> Iterator;
3190 }
3191 
3192 // SyntaxError
3193 #[wasm_bindgen]
3194 extern "C" {
3195     /// A `SyntaxError` is thrown when the JavaScript engine encounters tokens or
3196     /// token order that does not conform to the syntax of the language when
3197     /// parsing code.
3198     ///
3199     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError)
3200     #[wasm_bindgen(extends = Error, extends = Object, typescript_type = "SyntaxError")]
3201     #[derive(Clone, Debug, PartialEq, Eq)]
3202     pub type SyntaxError;
3203 
3204     /// A `SyntaxError` is thrown when the JavaScript engine encounters tokens or
3205     /// token order that does not conform to the syntax of the language when
3206     /// parsing code.
3207     ///
3208     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError)
3209     #[wasm_bindgen(constructor)]
new(message: &str) -> SyntaxError3210     pub fn new(message: &str) -> SyntaxError;
3211 }
3212 
3213 // TypeError
3214 #[wasm_bindgen]
3215 extern "C" {
3216     /// The `TypeError` object represents an error when a value is not of the
3217     /// expected type.
3218     ///
3219     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError)
3220     #[wasm_bindgen(extends = Error, extends = Object, typescript_type = "TypeError")]
3221     #[derive(Clone, Debug, PartialEq, Eq)]
3222     pub type TypeError;
3223 
3224     /// The `TypeError` object represents an error when a value is not of the
3225     /// expected type.
3226     ///
3227     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError)
3228     #[wasm_bindgen(constructor)]
new(message: &str) -> TypeError3229     pub fn new(message: &str) -> TypeError;
3230 }
3231 
3232 // URIError
3233 #[wasm_bindgen]
3234 extern "C" {
3235     /// The `URIError` object represents an error when a global URI handling
3236     /// function was used in a wrong way.
3237     ///
3238     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError)
3239     #[wasm_bindgen(extends = Error, extends = Object, js_name = URIError, typescript_type = "URIError")]
3240     #[derive(Clone, Debug, PartialEq, Eq)]
3241     pub type UriError;
3242 
3243     /// The `URIError` object represents an error when a global URI handling
3244     /// function was used in a wrong way.
3245     ///
3246     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError)
3247     #[wasm_bindgen(constructor, js_class = "URIError")]
new(message: &str) -> UriError3248     pub fn new(message: &str) -> UriError;
3249 }
3250 
3251 // WeakMap
3252 #[wasm_bindgen]
3253 extern "C" {
3254     #[wasm_bindgen(extends = Object, typescript_type = "WeakMap<object, any>")]
3255     #[derive(Clone, Debug, PartialEq, Eq)]
3256     pub type WeakMap;
3257 
3258     /// The [`WeakMap`] object is a collection of key/value pairs in which the
3259     /// keys are weakly referenced.  The keys must be objects and the values can
3260     /// be arbitrary values.
3261     ///
3262     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap)
3263     #[wasm_bindgen(constructor)]
new() -> WeakMap3264     pub fn new() -> WeakMap;
3265 
3266     /// The `set()` method sets the value for the key in the [`WeakMap`] object.
3267     /// Returns the [`WeakMap`] object.
3268     ///
3269     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/set)
3270     #[wasm_bindgen(method, js_class = "WeakMap")]
set(this: &WeakMap, key: &Object, value: &JsValue) -> WeakMap3271     pub fn set(this: &WeakMap, key: &Object, value: &JsValue) -> WeakMap;
3272 
3273     /// The `get()` method returns a specified by key element
3274     /// from a [`WeakMap`] object.
3275     ///
3276     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/get)
3277     #[wasm_bindgen(method)]
get(this: &WeakMap, key: &Object) -> JsValue3278     pub fn get(this: &WeakMap, key: &Object) -> JsValue;
3279 
3280     /// The `has()` method returns a boolean indicating whether an element with
3281     /// the specified key exists in the [`WeakMap`] object or not.
3282     ///
3283     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/has)
3284     #[wasm_bindgen(method)]
has(this: &WeakMap, key: &Object) -> bool3285     pub fn has(this: &WeakMap, key: &Object) -> bool;
3286 
3287     /// The `delete()` method removes the specified element from a [`WeakMap`]
3288     /// object.
3289     ///
3290     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/delete)
3291     #[wasm_bindgen(method)]
delete(this: &WeakMap, key: &Object) -> bool3292     pub fn delete(this: &WeakMap, key: &Object) -> bool;
3293 }
3294 
3295 // WeakSet
3296 #[wasm_bindgen]
3297 extern "C" {
3298     #[wasm_bindgen(extends = Object, typescript_type = "WeakSet<object>")]
3299     #[derive(Clone, Debug, PartialEq, Eq)]
3300     pub type WeakSet;
3301 
3302     /// The `WeakSet` object lets you store weakly held objects in a collection.
3303     ///
3304     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet)
3305     #[wasm_bindgen(constructor)]
new() -> WeakSet3306     pub fn new() -> WeakSet;
3307 
3308     /// The `has()` method returns a boolean indicating whether an object exists
3309     /// in a WeakSet or not.
3310     ///
3311     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet/has)
3312     #[wasm_bindgen(method)]
has(this: &WeakSet, value: &Object) -> bool3313     pub fn has(this: &WeakSet, value: &Object) -> bool;
3314 
3315     /// The `add()` method appends a new object to the end of a WeakSet object.
3316     ///
3317     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet/add)
3318     #[wasm_bindgen(method)]
add(this: &WeakSet, value: &Object) -> WeakSet3319     pub fn add(this: &WeakSet, value: &Object) -> WeakSet;
3320 
3321     /// The `delete()` method removes the specified element from a WeakSet
3322     /// object.
3323     ///
3324     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet/delete)
3325     #[wasm_bindgen(method)]
delete(this: &WeakSet, value: &Object) -> bool3326     pub fn delete(this: &WeakSet, value: &Object) -> bool;
3327 }
3328 
3329 #[allow(non_snake_case)]
3330 pub mod WebAssembly {
3331     use super::*;
3332 
3333     // WebAssembly
3334     #[wasm_bindgen]
3335     extern "C" {
3336         /// The `WebAssembly.compile()` function compiles a `WebAssembly.Module`
3337         /// from WebAssembly binary code.  This function is useful if it is
3338         /// necessary to a compile a module before it can be instantiated
3339         /// (otherwise, the `WebAssembly.instantiate()` function should be used).
3340         ///
3341         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/compile)
3342         #[wasm_bindgen(js_namespace = WebAssembly)]
compile(buffer_source: &JsValue) -> Promise3343         pub fn compile(buffer_source: &JsValue) -> Promise;
3344 
3345         /// The `WebAssembly.instantiate()` function allows you to compile and
3346         /// instantiate WebAssembly code.
3347         ///
3348         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiate)
3349         #[wasm_bindgen(js_namespace = WebAssembly, js_name = instantiate)]
instantiate_buffer(buffer: &[u8], imports: &Object) -> Promise3350         pub fn instantiate_buffer(buffer: &[u8], imports: &Object) -> Promise;
3351 
3352         /// The `WebAssembly.instantiate()` function allows you to compile and
3353         /// instantiate WebAssembly code.
3354         ///
3355         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiate)
3356         #[wasm_bindgen(js_namespace = WebAssembly, js_name = instantiate)]
instantiate_module(module: &Module, imports: &Object) -> Promise3357         pub fn instantiate_module(module: &Module, imports: &Object) -> Promise;
3358 
3359         /// The `WebAssembly.instantiateStreaming()` function compiles and
3360         /// instantiates a WebAssembly module directly from a streamed
3361         /// underlying source. This is the most efficient, optimized way to load
3362         /// wasm code.
3363         ///
3364         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiateStreaming)
3365         #[wasm_bindgen(js_namespace = WebAssembly, js_name = instantiateStreaming)]
instantiate_streaming(response: &Promise, imports: &Object) -> Promise3366         pub fn instantiate_streaming(response: &Promise, imports: &Object) -> Promise;
3367 
3368         /// The `WebAssembly.validate()` function validates a given typed
3369         /// array of WebAssembly binary code, returning whether the bytes
3370         /// form a valid wasm module (`true`) or not (`false`).
3371         ///
3372         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/validate)
3373         #[wasm_bindgen(js_namespace = WebAssembly, catch)]
validate(buffer_source: &JsValue) -> Result<bool, JsValue>3374         pub fn validate(buffer_source: &JsValue) -> Result<bool, JsValue>;
3375     }
3376 
3377     // WebAssembly.CompileError
3378     #[wasm_bindgen]
3379     extern "C" {
3380         /// The `WebAssembly.CompileError()` constructor creates a new
3381         /// WebAssembly `CompileError` object, which indicates an error during
3382         /// WebAssembly decoding or validation.
3383         ///
3384         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/CompileError)
3385         #[wasm_bindgen(extends = Error, js_namespace = WebAssembly, typescript_type = "WebAssembly.CompileError")]
3386         #[derive(Clone, Debug, PartialEq, Eq)]
3387         pub type CompileError;
3388 
3389         /// The `WebAssembly.CompileError()` constructor creates a new
3390         /// WebAssembly `CompileError` object, which indicates an error during
3391         /// WebAssembly decoding or validation.
3392         ///
3393         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/CompileError)
3394         #[wasm_bindgen(constructor, js_namespace = WebAssembly)]
new(message: &str) -> CompileError3395         pub fn new(message: &str) -> CompileError;
3396     }
3397 
3398     // WebAssembly.Instance
3399     #[wasm_bindgen]
3400     extern "C" {
3401         /// A `WebAssembly.Instance` object is a stateful, executable instance
3402         /// of a `WebAssembly.Module`. Instance objects contain all the exported
3403         /// WebAssembly functions that allow calling into WebAssembly code from
3404         /// JavaScript.
3405         ///
3406         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance)
3407         #[wasm_bindgen(extends = Object, js_namespace = WebAssembly, typescript_type = "WebAssembly.Instance")]
3408         #[derive(Clone, Debug, PartialEq, Eq)]
3409         pub type Instance;
3410 
3411         /// The `WebAssembly.Instance()` constructor function can be called to
3412         /// synchronously instantiate a given `WebAssembly.Module`
3413         /// object. However, the primary way to get an `Instance` is through the
3414         /// asynchronous `WebAssembly.instantiateStreaming()` function.
3415         ///
3416         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance)
3417         #[wasm_bindgen(catch, constructor, js_namespace = WebAssembly)]
new(module: &Module, imports: &Object) -> Result<Instance, JsValue>3418         pub fn new(module: &Module, imports: &Object) -> Result<Instance, JsValue>;
3419 
3420         /// The `exports` readonly property of the `WebAssembly.Instance` object
3421         /// prototype returns an object containing as its members all the
3422         /// functions exported from the WebAssembly module instance, to allow
3423         /// them to be accessed and used by JavaScript.
3424         ///
3425         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance/exports)
3426         #[wasm_bindgen(getter, method, js_namespace = WebAssembly)]
exports(this: &Instance) -> Object3427         pub fn exports(this: &Instance) -> Object;
3428     }
3429 
3430     // WebAssembly.LinkError
3431     #[wasm_bindgen]
3432     extern "C" {
3433         /// The `WebAssembly.LinkError()` constructor creates a new WebAssembly
3434         /// LinkError object, which indicates an error during module
3435         /// instantiation (besides traps from the start function).
3436         ///
3437         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/LinkError)
3438         #[wasm_bindgen(extends = Error, js_namespace = WebAssembly, typescript_type = "WebAssembly.LinkError")]
3439         #[derive(Clone, Debug, PartialEq, Eq)]
3440         pub type LinkError;
3441 
3442         /// The `WebAssembly.LinkError()` constructor creates a new WebAssembly
3443         /// LinkError object, which indicates an error during module
3444         /// instantiation (besides traps from the start function).
3445         ///
3446         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/LinkError)
3447         #[wasm_bindgen(constructor, js_namespace = WebAssembly)]
new(message: &str) -> LinkError3448         pub fn new(message: &str) -> LinkError;
3449     }
3450 
3451     // WebAssembly.RuntimeError
3452     #[wasm_bindgen]
3453     extern "C" {
3454         /// The `WebAssembly.RuntimeError()` constructor creates a new WebAssembly
3455         /// `RuntimeError` object — the type that is thrown whenever WebAssembly
3456         /// specifies a trap.
3457         ///
3458         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/RuntimeError)
3459         #[wasm_bindgen(extends = Error, js_namespace = WebAssembly, typescript_type = "WebAssembly.RuntimeError")]
3460         #[derive(Clone, Debug, PartialEq, Eq)]
3461         pub type RuntimeError;
3462 
3463         /// The `WebAssembly.RuntimeError()` constructor creates a new WebAssembly
3464         /// `RuntimeError` object — the type that is thrown whenever WebAssembly
3465         /// specifies a trap.
3466         ///
3467         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/RuntimeError)
3468         #[wasm_bindgen(constructor, js_namespace = WebAssembly)]
new(message: &str) -> RuntimeError3469         pub fn new(message: &str) -> RuntimeError;
3470     }
3471 
3472     // WebAssembly.Module
3473     #[wasm_bindgen]
3474     extern "C" {
3475         /// A `WebAssembly.Module` object contains stateless WebAssembly code
3476         /// that has already been compiled by the browser and can be
3477         /// efficiently shared with Workers, and instantiated multiple times.
3478         ///
3479         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module)
3480         #[wasm_bindgen(js_namespace = WebAssembly, extends = Object, typescript_type = "WebAssembly.Module")]
3481         #[derive(Clone, Debug, PartialEq, Eq)]
3482         pub type Module;
3483 
3484         /// A `WebAssembly.Module` object contains stateless WebAssembly code
3485         /// that has already been compiled by the browser and can be
3486         /// efficiently shared with Workers, and instantiated multiple times.
3487         ///
3488         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module)
3489         #[wasm_bindgen(constructor, js_namespace = WebAssembly, catch)]
new(buffer_source: &JsValue) -> Result<Module, JsValue>3490         pub fn new(buffer_source: &JsValue) -> Result<Module, JsValue>;
3491 
3492         /// The `WebAssembly.customSections()` function returns a copy of the
3493         /// contents of all custom sections in the given module with the given
3494         /// string name.
3495         ///
3496         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module/customSections)
3497         #[wasm_bindgen(static_method_of = Module, js_namespace = WebAssembly, js_name = customSections)]
custom_sections(module: &Module, sectionName: &str) -> Array3498         pub fn custom_sections(module: &Module, sectionName: &str) -> Array;
3499 
3500         /// The `WebAssembly.exports()` function returns an array containing
3501         /// descriptions of all the declared exports of the given `Module`.
3502         ///
3503         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module/exports)
3504         #[wasm_bindgen(static_method_of = Module, js_namespace = WebAssembly)]
exports(module: &Module) -> Array3505         pub fn exports(module: &Module) -> Array;
3506 
3507         /// The `WebAssembly.imports()` function returns an array containing
3508         /// descriptions of all the declared imports of the given `Module`.
3509         ///
3510         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module/imports)
3511         #[wasm_bindgen(static_method_of = Module, js_namespace = WebAssembly)]
imports(module: &Module) -> Array3512         pub fn imports(module: &Module) -> Array;
3513     }
3514 
3515     // WebAssembly.Table
3516     #[wasm_bindgen]
3517     extern "C" {
3518         /// The `WebAssembly.Table()` constructor creates a new `Table` object
3519         /// of the given size and element type.
3520         ///
3521         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table)
3522         #[wasm_bindgen(js_namespace = WebAssembly, extends = Object, typescript_type = "WebAssembly.Table")]
3523         #[derive(Clone, Debug, PartialEq, Eq)]
3524         pub type Table;
3525 
3526         /// The `WebAssembly.Table()` constructor creates a new `Table` object
3527         /// of the given size and element type.
3528         ///
3529         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table)
3530         #[wasm_bindgen(constructor, js_namespace = WebAssembly, catch)]
new(table_descriptor: &Object) -> Result<Table, JsValue>3531         pub fn new(table_descriptor: &Object) -> Result<Table, JsValue>;
3532 
3533         /// The length prototype property of the `WebAssembly.Table` object
3534         /// returns the length of the table, i.e. the number of elements in the
3535         /// table.
3536         ///
3537         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/length)
3538         #[wasm_bindgen(method, getter, js_namespace = WebAssembly)]
length(this: &Table) -> u323539         pub fn length(this: &Table) -> u32;
3540 
3541         /// The `get()` prototype method of the `WebAssembly.Table()` object
3542         /// retrieves a function reference stored at a given index.
3543         ///
3544         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/get)
3545         #[wasm_bindgen(method, catch, js_namespace = WebAssembly)]
get(this: &Table, index: u32) -> Result<Function, JsValue>3546         pub fn get(this: &Table, index: u32) -> Result<Function, JsValue>;
3547 
3548         /// The `grow()` prototype method of the `WebAssembly.Table` object
3549         /// increases the size of the `Table` instance by a specified number of
3550         /// elements.
3551         ///
3552         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/grow)
3553         #[wasm_bindgen(method, catch, js_namespace = WebAssembly)]
grow(this: &Table, additional_capacity: u32) -> Result<u32, JsValue>3554         pub fn grow(this: &Table, additional_capacity: u32) -> Result<u32, JsValue>;
3555 
3556         /// The `set()` prototype method of the `WebAssembly.Table` object mutates a
3557         /// reference stored at a given index to a different value.
3558         ///
3559         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/set)
3560         #[wasm_bindgen(method, catch, js_namespace = WebAssembly)]
set(this: &Table, index: u32, function: &Function) -> Result<(), JsValue>3561         pub fn set(this: &Table, index: u32, function: &Function) -> Result<(), JsValue>;
3562     }
3563 
3564     // WebAssembly.Memory
3565     #[wasm_bindgen]
3566     extern "C" {
3567         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory)
3568         #[wasm_bindgen(js_namespace = WebAssembly, extends = Object, typescript_type = "WebAssembly.Memory")]
3569         #[derive(Clone, Debug, PartialEq, Eq)]
3570         pub type Memory;
3571 
3572         /// The `WebAssembly.Memory()` constructor creates a new `Memory` object
3573         /// which is a resizable `ArrayBuffer` that holds the raw bytes of
3574         /// memory accessed by a WebAssembly `Instance`.
3575         ///
3576         /// A memory created by JavaScript or in WebAssembly code will be
3577         /// accessible and mutable from both JavaScript and WebAssembly.
3578         ///
3579         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory)
3580         #[wasm_bindgen(constructor, js_namespace = WebAssembly, catch)]
new(descriptor: &Object) -> Result<Memory, JsValue>3581         pub fn new(descriptor: &Object) -> Result<Memory, JsValue>;
3582 
3583         /// An accessor property that returns the buffer contained in the
3584         /// memory.
3585         ///
3586         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory/buffer)
3587         #[wasm_bindgen(method, getter, js_namespace = WebAssembly)]
buffer(this: &Memory) -> JsValue3588         pub fn buffer(this: &Memory) -> JsValue;
3589 
3590         /// The `grow()` protoype method of the `Memory` object increases the
3591         /// size of the memory instance by a specified number of WebAssembly
3592         /// pages.
3593         ///
3594         /// Takes the number of pages to grow (64KiB in size) and returns the
3595         /// previous size of memory, in pages.
3596         ///
3597         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory/grow)
3598         #[wasm_bindgen(method, js_namespace = WebAssembly)]
grow(this: &Memory, pages: u32) -> u323599         pub fn grow(this: &Memory, pages: u32) -> u32;
3600     }
3601 }
3602 
3603 /// The `JSON` object contains methods for parsing [JavaScript Object
3604 /// Notation (JSON)](https://json.org/) and converting values to JSON. It
3605 /// can't be called or constructed, and aside from its two method
3606 /// properties, it has no interesting functionality of its own.
3607 #[allow(non_snake_case)]
3608 pub mod JSON {
3609     use super::*;
3610 
3611     // JSON
3612     #[wasm_bindgen]
3613     extern "C" {
3614         /// The `JSON.parse()` method parses a JSON string, constructing the
3615         /// JavaScript value or object described by the string.
3616         ///
3617         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse)
3618         #[wasm_bindgen(catch, js_namespace = JSON)]
parse(text: &str) -> Result<JsValue, JsValue>3619         pub fn parse(text: &str) -> Result<JsValue, JsValue>;
3620 
3621         /// The `JSON.stringify()` method converts a JavaScript value to a JSON string.
3622         ///
3623         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)
3624         #[wasm_bindgen(catch, js_namespace = JSON)]
stringify(obj: &JsValue) -> Result<JsString, JsValue>3625         pub fn stringify(obj: &JsValue) -> Result<JsString, JsValue>;
3626 
3627         /// The `JSON.stringify()` method converts a JavaScript value to a JSON string.
3628         ///
3629         /// The `replacer` argument is a function that alters the behavior of the stringification
3630         /// process, or an array of String and Number objects that serve as a whitelist
3631         /// for selecting/filtering the properties of the value object to be included
3632         /// in the JSON string. If this value is null or not provided, all properties
3633         /// of the object are included in the resulting JSON string.
3634         ///
3635         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)
3636         #[wasm_bindgen(catch, js_namespace = JSON, js_name = stringify)]
stringify_with_replacer( obj: &JsValue, replacer: &JsValue, ) -> Result<JsString, JsValue>3637         pub fn stringify_with_replacer(
3638             obj: &JsValue,
3639             replacer: &JsValue,
3640         ) -> Result<JsString, JsValue>;
3641 
3642         /// The `JSON.stringify()` method converts a JavaScript value to a JSON string.
3643         ///
3644         /// The `replacer` argument is a function that alters the behavior of the stringification
3645         /// process, or an array of String and Number objects that serve as a whitelist
3646         /// for selecting/filtering the properties of the value object to be included
3647         /// in the JSON string. If this value is null or not provided, all properties
3648         /// of the object are included in the resulting JSON string.
3649         ///
3650         /// The `space` argument is a String or Number object that's used to insert white space into
3651         /// the output JSON string for readability purposes. If this is a Number, it
3652         /// indicates the number of space characters to use as white space; this number
3653         /// is capped at 10 (if it is greater, the value is just 10). Values less than
3654         /// 1 indicate that no space should be used. If this is a String, the string
3655         /// (or the first 10 characters of the string, if it's longer than that) is
3656         /// used as white space. If this parameter is not provided (or is null), no
3657         /// white space is used.
3658         ///
3659         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)
3660         #[wasm_bindgen(catch, js_namespace = JSON, js_name = stringify)]
stringify_with_replacer_and_space( obj: &JsValue, replacer: &JsValue, space: &JsValue, ) -> Result<JsString, JsValue>3661         pub fn stringify_with_replacer_and_space(
3662             obj: &JsValue,
3663             replacer: &JsValue,
3664             space: &JsValue,
3665         ) -> Result<JsString, JsValue>;
3666 
3667     }
3668 }
3669 
3670 // JsString
3671 #[wasm_bindgen]
3672 extern "C" {
3673     #[wasm_bindgen(js_name = String, extends = Object, is_type_of = JsValue::is_string, typescript_type = "string")]
3674     #[derive(Clone, PartialEq, Eq)]
3675     pub type JsString;
3676 
3677     /// The length property of a String object indicates the length of a string,
3678     /// in UTF-16 code units.
3679     ///
3680     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length)
3681     #[wasm_bindgen(method, getter, structural)]
length(this: &JsString) -> u323682     pub fn length(this: &JsString) -> u32;
3683 
3684     /// The String object's `charAt()` method returns a new string consisting of
3685     /// the single UTF-16 code unit located at the specified offset into the
3686     /// string.
3687     ///
3688     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charAt)
3689     #[wasm_bindgen(method, js_class = "String", js_name = charAt)]
char_at(this: &JsString, index: u32) -> JsString3690     pub fn char_at(this: &JsString, index: u32) -> JsString;
3691 
3692     /// The `charCodeAt()` method returns an integer between 0 and 65535
3693     /// representing the UTF-16 code unit at the given index (the UTF-16 code
3694     /// unit matches the Unicode code point for code points representable in a
3695     /// single UTF-16 code unit, but might also be the first code unit of a
3696     /// surrogate pair for code points not representable in a single UTF-16 code
3697     /// unit, e.g. Unicode code points > 0x10000).  If you want the entire code
3698     /// point value, use `codePointAt()`.
3699     ///
3700     /// Returns `NaN` if index is out of range.
3701     ///
3702     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charCodeAt)
3703     #[wasm_bindgen(method, js_class = "String", js_name = charCodeAt)]
char_code_at(this: &JsString, index: u32) -> f643704     pub fn char_code_at(this: &JsString, index: u32) -> f64;
3705 
3706     /// The `codePointAt()` method returns a non-negative integer that is the
3707     /// Unicode code point value.
3708     ///
3709     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt)
3710     #[wasm_bindgen(method, js_class = "String", js_name = codePointAt)]
code_point_at(this: &JsString, pos: u32) -> JsValue3711     pub fn code_point_at(this: &JsString, pos: u32) -> JsValue;
3712 
3713     /// The `concat()` method concatenates the string arguments to the calling
3714     /// string and returns a new string.
3715     ///
3716     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/concat)
3717     #[wasm_bindgen(method, js_class = "String")]
concat(this: &JsString, string_2: &JsValue) -> JsString3718     pub fn concat(this: &JsString, string_2: &JsValue) -> JsString;
3719 
3720     /// The `endsWith()` method determines whether a string ends with the characters of a
3721     /// specified string, returning true or false as appropriate.
3722     ///
3723     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith)
3724     #[wasm_bindgen(method, js_class = "String", js_name = endsWith)]
ends_with(this: &JsString, search_string: &str, length: i32) -> bool3725     pub fn ends_with(this: &JsString, search_string: &str, length: i32) -> bool;
3726 
3727     /// The static `String.fromCharCode()` method returns a string created from
3728     /// the specified sequence of UTF-16 code units.
3729     ///
3730     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
3731     ///
3732     /// # Notes
3733     ///
3734     /// There are a few bindings to `from_char_code` in `js-sys`: `from_char_code1`, `from_char_code2`, etc...
3735     /// with different arities.
3736     ///
3737     /// Additionally, this function accepts `u16` for character codes, but
3738     /// fixing others requires a breaking change release
3739     /// (see https://github.com/rustwasm/wasm-bindgen/issues/1460 for details).
3740     #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode, variadic)]
from_char_code(char_codes: &[u16]) -> JsString3741     pub fn from_char_code(char_codes: &[u16]) -> JsString;
3742 
3743     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
3744     #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)]
from_char_code1(a: u32) -> JsString3745     pub fn from_char_code1(a: u32) -> JsString;
3746 
3747     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
3748     #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)]
from_char_code2(a: u32, b: u32) -> JsString3749     pub fn from_char_code2(a: u32, b: u32) -> JsString;
3750 
3751     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
3752     #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)]
from_char_code3(a: u32, b: u32, c: u32) -> JsString3753     pub fn from_char_code3(a: u32, b: u32, c: u32) -> JsString;
3754 
3755     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
3756     #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)]
from_char_code4(a: u32, b: u32, c: u32, d: u32) -> JsString3757     pub fn from_char_code4(a: u32, b: u32, c: u32, d: u32) -> JsString;
3758 
3759     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
3760     #[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) -> JsString3761     pub fn from_char_code5(a: u32, b: u32, c: u32, d: u32, e: u32) -> JsString;
3762 
3763     /// The static `String.fromCodePoint()` method returns a string created by
3764     /// using the specified sequence of code points.
3765     ///
3766     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)
3767     ///
3768     /// # Exceptions
3769     ///
3770     /// A RangeError is thrown if an invalid Unicode code point is given
3771     ///
3772     /// # Notes
3773     ///
3774     /// There are a few bindings to `from_code_point` in `js-sys`: `from_code_point1`, `from_code_point2`, etc...
3775     /// with different arities.
3776     #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = fromCodePoint, variadic)]
from_code_point(code_points: &[u32]) -> Result<JsString, JsValue>3777     pub fn from_code_point(code_points: &[u32]) -> Result<JsString, JsValue>;
3778 
3779     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)
3780     #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = fromCodePoint)]
from_code_point1(a: u32) -> Result<JsString, JsValue>3781     pub fn from_code_point1(a: u32) -> Result<JsString, JsValue>;
3782 
3783     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)
3784     #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = fromCodePoint)]
from_code_point2(a: u32, b: u32) -> Result<JsString, JsValue>3785     pub fn from_code_point2(a: u32, b: u32) -> Result<JsString, JsValue>;
3786 
3787     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)
3788     #[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>3789     pub fn from_code_point3(a: u32, b: u32, c: u32) -> Result<JsString, JsValue>;
3790 
3791     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)
3792     #[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>3793     pub fn from_code_point4(a: u32, b: u32, c: u32, d: u32) -> Result<JsString, JsValue>;
3794 
3795     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)
3796     #[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>3797     pub fn from_code_point5(a: u32, b: u32, c: u32, d: u32, e: u32) -> Result<JsString, JsValue>;
3798 
3799     /// The `includes()` method determines whether one string may be found
3800     /// within another string, returning true or false as appropriate.
3801     ///
3802     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes)
3803     #[wasm_bindgen(method, js_class = "String")]
includes(this: &JsString, search_string: &str, position: i32) -> bool3804     pub fn includes(this: &JsString, search_string: &str, position: i32) -> bool;
3805 
3806     /// The `indexOf()` method returns the index within the calling String
3807     /// object of the first occurrence of the specified value, starting the
3808     /// search at fromIndex.  Returns -1 if the value is not found.
3809     ///
3810     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf)
3811     #[wasm_bindgen(method, js_class = "String", js_name = indexOf)]
index_of(this: &JsString, search_value: &str, from_index: i32) -> i323812     pub fn index_of(this: &JsString, search_value: &str, from_index: i32) -> i32;
3813 
3814     /// The `lastIndexOf()` method returns the index within the calling String
3815     /// object of the last occurrence of the specified value, searching
3816     /// backwards from fromIndex.  Returns -1 if the value is not found.
3817     ///
3818     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/lastIndexOf)
3819     #[wasm_bindgen(method, js_class = "String", js_name = lastIndexOf)]
last_index_of(this: &JsString, search_value: &str, from_index: i32) -> i323820     pub fn last_index_of(this: &JsString, search_value: &str, from_index: i32) -> i32;
3821 
3822     /// The `localeCompare()` method returns a number indicating whether
3823     /// a reference string comes before or after or is the same as
3824     /// the given string in sort order.
3825     ///
3826     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare)
3827     #[wasm_bindgen(method, js_class = "String", js_name = localeCompare)]
locale_compare( this: &JsString, compare_string: &str, locales: &Array, options: &Object, ) -> i323828     pub fn locale_compare(
3829         this: &JsString,
3830         compare_string: &str,
3831         locales: &Array,
3832         options: &Object,
3833     ) -> i32;
3834 
3835     /// The `match()` method retrieves the matches when matching a string against a regular expression.
3836     ///
3837     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match)
3838     #[wasm_bindgen(method, js_class = "String", js_name = match)]
match_(this: &JsString, pattern: &RegExp) -> Option<Object>3839     pub fn match_(this: &JsString, pattern: &RegExp) -> Option<Object>;
3840 
3841     /// The `normalize()` method returns the Unicode Normalization Form
3842     /// of a given string (if the value isn't a string, it will be converted to one first).
3843     ///
3844     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize)
3845     #[wasm_bindgen(method, js_class = "String")]
normalize(this: &JsString, form: &str) -> JsString3846     pub fn normalize(this: &JsString, form: &str) -> JsString;
3847 
3848     /// The `padEnd()` method pads the current string with a given string
3849     /// (repeated, if needed) so that the resulting string reaches a given
3850     /// length. The padding is applied from the end (right) of the current
3851     /// string.
3852     ///
3853     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padEnd)
3854     #[wasm_bindgen(method, js_class = "String", js_name = padEnd)]
pad_end(this: &JsString, target_length: u32, pad_string: &str) -> JsString3855     pub fn pad_end(this: &JsString, target_length: u32, pad_string: &str) -> JsString;
3856 
3857     /// The `padStart()` method pads the current string with another string
3858     /// (repeated, if needed) so that the resulting string reaches the given
3859     /// length. The padding is applied from the start (left) of the current
3860     /// string.
3861     ///
3862     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padStart)
3863     #[wasm_bindgen(method, js_class = "String", js_name = padStart)]
pad_start(this: &JsString, target_length: u32, pad_string: &str) -> JsString3864     pub fn pad_start(this: &JsString, target_length: u32, pad_string: &str) -> JsString;
3865 
3866     /// The `repeat()` method constructs and returns a new string which contains the specified
3867     /// number of copies of the string on which it was called, concatenated together.
3868     ///
3869     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat)
3870     #[wasm_bindgen(method, js_class = "String")]
repeat(this: &JsString, count: i32) -> JsString3871     pub fn repeat(this: &JsString, count: i32) -> JsString;
3872 
3873     /// The `replace()` method returns a new string with some or all matches of a pattern
3874     /// replaced by a replacement. The pattern can be a string or a RegExp, and
3875     /// the replacement can be a string or a function to be called for each match.
3876     ///
3877     /// Note: The original string will remain unchanged.
3878     ///
3879     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace)
3880     #[wasm_bindgen(method, js_class = "String")]
replace(this: &JsString, pattern: &str, replacement: &str) -> JsString3881     pub fn replace(this: &JsString, pattern: &str, replacement: &str) -> JsString;
3882 
3883     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace)
3884     #[wasm_bindgen(method, js_class = "String", js_name = replace)]
replace_with_function( this: &JsString, pattern: &str, replacement: &Function, ) -> JsString3885     pub fn replace_with_function(
3886         this: &JsString,
3887         pattern: &str,
3888         replacement: &Function,
3889     ) -> JsString;
3890 
3891     #[wasm_bindgen(method, js_class = "String", js_name = replace)]
replace_by_pattern(this: &JsString, pattern: &RegExp, replacement: &str) -> JsString3892     pub fn replace_by_pattern(this: &JsString, pattern: &RegExp, replacement: &str) -> JsString;
3893 
3894     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace)
3895     #[wasm_bindgen(method, js_class = "String", js_name = replace)]
replace_by_pattern_with_function( this: &JsString, pattern: &RegExp, replacement: &Function, ) -> JsString3896     pub fn replace_by_pattern_with_function(
3897         this: &JsString,
3898         pattern: &RegExp,
3899         replacement: &Function,
3900     ) -> JsString;
3901 
3902     /// The `search()` method executes a search for a match between
3903     /// a regular expression and this String object.
3904     ///
3905     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/search)
3906     #[wasm_bindgen(method, js_class = "String")]
search(this: &JsString, pattern: &RegExp) -> i323907     pub fn search(this: &JsString, pattern: &RegExp) -> i32;
3908 
3909     /// The `slice()` method extracts a section of a string and returns it as a
3910     /// new string, without modifying the original string.
3911     ///
3912     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice)
3913     #[wasm_bindgen(method, js_class = "String")]
slice(this: &JsString, start: u32, end: u32) -> JsString3914     pub fn slice(this: &JsString, start: u32, end: u32) -> JsString;
3915 
3916     /// The `split()` method splits a String object into an array of strings by separating the string
3917     /// into substrings, using a specified separator string to determine where to make each split.
3918     ///
3919     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split)
3920     #[wasm_bindgen(method, js_class = "String")]
split(this: &JsString, separator: &str) -> Array3921     pub fn split(this: &JsString, separator: &str) -> Array;
3922 
3923     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split)
3924     #[wasm_bindgen(method, js_class = "String", js_name = split)]
split_limit(this: &JsString, separator: &str, limit: u32) -> Array3925     pub fn split_limit(this: &JsString, separator: &str, limit: u32) -> Array;
3926 
3927     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split)
3928     #[wasm_bindgen(method, js_class = "String", js_name = split)]
split_by_pattern(this: &JsString, pattern: &RegExp) -> Array3929     pub fn split_by_pattern(this: &JsString, pattern: &RegExp) -> Array;
3930 
3931     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split)
3932     #[wasm_bindgen(method, js_class = "String", js_name = split)]
split_by_pattern_limit(this: &JsString, pattern: &RegExp, limit: u32) -> Array3933     pub fn split_by_pattern_limit(this: &JsString, pattern: &RegExp, limit: u32) -> Array;
3934 
3935     /// The `startsWith()` method determines whether a string begins with the
3936     /// characters of a specified string, returning true or false as
3937     /// appropriate.
3938     ///
3939     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith)
3940     #[wasm_bindgen(method, js_class = "String", js_name = startsWith)]
starts_with(this: &JsString, search_string: &str, position: u32) -> bool3941     pub fn starts_with(this: &JsString, search_string: &str, position: u32) -> bool;
3942 
3943     /// The `substring()` method returns the part of the string between the
3944     /// start and end indexes, or to the end of the string.
3945     ///
3946     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring)
3947     #[wasm_bindgen(method, js_class = "String")]
substring(this: &JsString, index_start: u32, index_end: u32) -> JsString3948     pub fn substring(this: &JsString, index_start: u32, index_end: u32) -> JsString;
3949 
3950     /// The `substr()` method returns the part of a string between
3951     /// the start index and a number of characters after it.
3952     ///
3953     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr)
3954     #[wasm_bindgen(method, js_class = "String")]
substr(this: &JsString, start: i32, length: i32) -> JsString3955     pub fn substr(this: &JsString, start: i32, length: i32) -> JsString;
3956 
3957     /// The `toLocaleLowerCase()` method returns the calling string value converted to lower case,
3958     /// according to any locale-specific case mappings.
3959     ///
3960     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase)
3961     #[wasm_bindgen(method, js_class = "String", js_name = toLocaleLowerCase)]
to_locale_lower_case(this: &JsString, locale: Option<&str>) -> JsString3962     pub fn to_locale_lower_case(this: &JsString, locale: Option<&str>) -> JsString;
3963 
3964     /// The `toLocaleUpperCase()` method returns the calling string value converted to upper case,
3965     /// according to any locale-specific case mappings.
3966     ///
3967     /// [MDN documentation](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleUpperCase)
3968     #[wasm_bindgen(method, js_class = "String", js_name = toLocaleUpperCase)]
to_locale_upper_case(this: &JsString, locale: Option<&str>) -> JsString3969     pub fn to_locale_upper_case(this: &JsString, locale: Option<&str>) -> JsString;
3970 
3971     /// The `toLowerCase()` method returns the calling string value
3972     /// converted to lower case.
3973     ///
3974     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLowerCase)
3975     #[wasm_bindgen(method, js_class = "String", js_name = toLowerCase)]
to_lower_case(this: &JsString) -> JsString3976     pub fn to_lower_case(this: &JsString) -> JsString;
3977 
3978     /// The `toString()` method returns a string representing the specified
3979     /// object.
3980     ///
3981     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toString)
3982     #[wasm_bindgen(method, js_class = "String", js_name = toString)]
to_string(this: &JsString) -> JsString3983     pub fn to_string(this: &JsString) -> JsString;
3984 
3985     /// The `toUpperCase()` method returns the calling string value converted to
3986     /// uppercase (the value will be converted to a string if it isn't one).
3987     ///
3988     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase)
3989     #[wasm_bindgen(method, js_class = "String", js_name = toUpperCase)]
to_upper_case(this: &JsString) -> JsString3990     pub fn to_upper_case(this: &JsString) -> JsString;
3991 
3992     /// The `trim()` method removes whitespace from both ends of a string.
3993     /// Whitespace in this context is all the whitespace characters (space, tab,
3994     /// no-break space, etc.) and all the line terminator characters (LF, CR,
3995     /// etc.).
3996     ///
3997     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trim)
3998     #[wasm_bindgen(method, js_class = "String")]
trim(this: &JsString) -> JsString3999     pub fn trim(this: &JsString) -> JsString;
4000 
4001     /// The `trimEnd()` method removes whitespace from the end of a string.
4002     /// `trimRight()` is an alias of this method.
4003     ///
4004     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimEnd)
4005     #[wasm_bindgen(method, js_class = "String", js_name = trimEnd)]
trim_end(this: &JsString) -> JsString4006     pub fn trim_end(this: &JsString) -> JsString;
4007 
4008     /// The `trimEnd()` method removes whitespace from the end of a string.
4009     /// `trimRight()` is an alias of this method.
4010     ///
4011     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimEnd)
4012     #[wasm_bindgen(method, js_class = "String", js_name = trimRight)]
trim_right(this: &JsString) -> JsString4013     pub fn trim_right(this: &JsString) -> JsString;
4014 
4015     /// The `trimStart()` method removes whitespace from the beginning of a
4016     /// string. `trimLeft()` is an alias of this method.
4017     ///
4018     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimStart)
4019     #[wasm_bindgen(method, js_class = "String", js_name = trimStart)]
trim_start(this: &JsString) -> JsString4020     pub fn trim_start(this: &JsString) -> JsString;
4021 
4022     /// The `trimStart()` method removes whitespace from the beginning of a
4023     /// string. `trimLeft()` is an alias of this method.
4024     ///
4025     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimStart)
4026     #[wasm_bindgen(method, js_class = "String", js_name = trimLeft)]
trim_left(this: &JsString) -> JsString4027     pub fn trim_left(this: &JsString) -> JsString;
4028 
4029     /// The `valueOf()` method returns the primitive value of a `String` object.
4030     ///
4031     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/valueOf)
4032     #[wasm_bindgen(method, js_class = "String", js_name = valueOf)]
value_of(this: &JsString) -> JsString4033     pub fn value_of(this: &JsString) -> JsString;
4034 
4035     /// The static `raw()` method is a tag function of template literals,
4036     /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
4037     ///
4038     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
4039     #[wasm_bindgen(catch, variadic, static_method_of = JsString, js_class = "String")]
raw(call_site: &Object, substitutions: &Array) -> Result<JsString, JsValue>4040     pub fn raw(call_site: &Object, substitutions: &Array) -> Result<JsString, JsValue>;
4041 
4042     /// The static `raw()` method is a tag function of template literals,
4043     /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
4044     ///
4045     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
4046     #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = raw)]
raw_0(call_site: &Object) -> Result<JsString, JsValue>4047     pub fn raw_0(call_site: &Object) -> Result<JsString, JsValue>;
4048 
4049     /// The static `raw()` method is a tag function of template literals,
4050     /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
4051     ///
4052     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
4053     #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = raw)]
raw_1(call_site: &Object, substitutions_1: &str) -> Result<JsString, JsValue>4054     pub fn raw_1(call_site: &Object, substitutions_1: &str) -> Result<JsString, JsValue>;
4055 
4056     /// The static `raw()` method is a tag function of template literals,
4057     /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
4058     ///
4059     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
4060     #[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>4061     pub fn raw_2(
4062         call_site: &Object,
4063         substitutions_1: &str,
4064         substitutions_2: &str,
4065     ) -> Result<JsString, JsValue>;
4066 
4067     /// The static `raw()` method is a tag function of template literals,
4068     /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
4069     ///
4070     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
4071     #[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>4072     pub fn raw_3(
4073         call_site: &Object,
4074         substitutions_1: &str,
4075         substitutions_2: &str,
4076         substitutions_3: &str,
4077     ) -> Result<JsString, JsValue>;
4078 
4079     /// The static `raw()` method is a tag function of template literals,
4080     /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
4081     ///
4082     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
4083     #[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>4084     pub fn raw_4(
4085         call_site: &Object,
4086         substitutions_1: &str,
4087         substitutions_2: &str,
4088         substitutions_3: &str,
4089         substitutions_4: &str,
4090     ) -> Result<JsString, JsValue>;
4091 
4092     /// The static `raw()` method is a tag function of template literals,
4093     /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
4094     ///
4095     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
4096     #[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>4097     pub fn raw_5(
4098         call_site: &Object,
4099         substitutions_1: &str,
4100         substitutions_2: &str,
4101         substitutions_3: &str,
4102         substitutions_4: &str,
4103         substitutions_5: &str,
4104     ) -> Result<JsString, JsValue>;
4105 
4106     /// The static `raw()` method is a tag function of template literals,
4107     /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
4108     ///
4109     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
4110     #[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>4111     pub fn raw_6(
4112         call_site: &Object,
4113         substitutions_1: &str,
4114         substitutions_2: &str,
4115         substitutions_3: &str,
4116         substitutions_4: &str,
4117         substitutions_5: &str,
4118         substitutions_6: &str,
4119     ) -> Result<JsString, JsValue>;
4120 
4121     /// The static `raw()` method is a tag function of template literals,
4122     /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
4123     ///
4124     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
4125     #[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>4126     pub fn raw_7(
4127         call_site: &Object,
4128         substitutions_1: &str,
4129         substitutions_2: &str,
4130         substitutions_3: &str,
4131         substitutions_4: &str,
4132         substitutions_5: &str,
4133         substitutions_6: &str,
4134         substitutions_7: &str,
4135     ) -> Result<JsString, JsValue>;
4136 }
4137 
4138 impl JsString {
4139     /// Returns the `JsString` value of this JS value if it's an instance of a
4140     /// string.
4141     ///
4142     /// If this JS value is not an instance of a string then this returns
4143     /// `None`.
4144     #[deprecated(note = "recommended to use dyn_ref instead which is now equivalent")]
try_from(val: &JsValue) -> Option<&JsString>4145     pub fn try_from(val: &JsValue) -> Option<&JsString> {
4146         val.dyn_ref()
4147     }
4148 
4149     /// Returns whether this string is a valid UTF-16 string.
4150     ///
4151     /// This is useful for learning whether `String::from(..)` will return a
4152     /// lossless representation of the JS string. If this string contains
4153     /// unpaired surrogates then `String::from` will succeed but it will be a
4154     /// lossy representation of the JS string because unpaired surrogates will
4155     /// become replacement characters.
4156     ///
4157     /// If this function returns `false` then to get a lossless representation
4158     /// of the string you'll need to manually use the `iter` method (or the
4159     /// `char_code_at` accessor) to view the raw character codes.
4160     ///
4161     /// For more information, see the documentation on [JS strings vs Rust
4162     /// strings][docs]
4163     ///
4164     /// [docs]: https://rustwasm.github.io/docs/wasm-bindgen/reference/types/str.html
is_valid_utf16(&self) -> bool4165     pub fn is_valid_utf16(&self) -> bool {
4166         std::char::decode_utf16(self.iter()).all(|i| i.is_ok())
4167     }
4168 
4169     /// Returns an iterator over the `u16` character codes that make up this JS
4170     /// string.
4171     ///
4172     /// This method will call `char_code_at` for each code in this JS string,
4173     /// returning an iterator of the codes in sequence.
iter<'a>( &'a self, ) -> impl ExactSizeIterator<Item = u16> + DoubleEndedIterator<Item = u16> + 'a4174     pub fn iter<'a>(
4175         &'a self,
4176     ) -> impl ExactSizeIterator<Item = u16> + DoubleEndedIterator<Item = u16> + 'a {
4177         (0..self.length()).map(move |i| self.char_code_at(i) as u16)
4178     }
4179 
4180     /// If this string consists of a single Unicode code point, then this method
4181     /// converts it into a Rust `char` without doing any allocations.
4182     ///
4183     /// If this JS value is not a valid UTF-8 or consists of more than a single
4184     /// codepoint, then this returns `None`.
4185     ///
4186     /// Note that a single Unicode code point might be represented as more than
4187     /// one code unit on the JavaScript side. For example, a JavaScript string
4188     /// `"\uD801\uDC37"` is actually a single Unicode code point U+10437 which
4189     /// corresponds to a character '��'.
as_char(&self) -> Option<char>4190     pub fn as_char(&self) -> Option<char> {
4191         let len = self.length();
4192 
4193         if len == 0 || len > 2 {
4194             return None;
4195         }
4196 
4197         // This will be simplified when definitions are fixed:
4198         // https://github.com/rustwasm/wasm-bindgen/issues/1362
4199         let cp = self.code_point_at(0).as_f64().unwrap_throw() as u32;
4200 
4201         let c = std::char::from_u32(cp)?;
4202 
4203         if c.len_utf16() as u32 == len {
4204             Some(c)
4205         } else {
4206             None
4207         }
4208     }
4209 }
4210 
4211 impl PartialEq<str> for JsString {
eq(&self, other: &str) -> bool4212     fn eq(&self, other: &str) -> bool {
4213         String::from(self) == other
4214     }
4215 }
4216 
4217 impl<'a> PartialEq<&'a str> for JsString {
eq(&self, other: &&'a str) -> bool4218     fn eq(&self, other: &&'a str) -> bool {
4219         <JsString as PartialEq<str>>::eq(self, other)
4220     }
4221 }
4222 
4223 impl PartialEq<String> for JsString {
eq(&self, other: &String) -> bool4224     fn eq(&self, other: &String) -> bool {
4225         <JsString as PartialEq<str>>::eq(self, other)
4226     }
4227 }
4228 
4229 impl<'a> PartialEq<&'a String> for JsString {
eq(&self, other: &&'a String) -> bool4230     fn eq(&self, other: &&'a String) -> bool {
4231         <JsString as PartialEq<str>>::eq(self, other)
4232     }
4233 }
4234 
4235 impl<'a> From<&'a str> for JsString {
from(s: &'a str) -> Self4236     fn from(s: &'a str) -> Self {
4237         JsString::unchecked_from_js(JsValue::from_str(s))
4238     }
4239 }
4240 
4241 impl From<String> for JsString {
from(s: String) -> Self4242     fn from(s: String) -> Self {
4243         From::from(&*s)
4244     }
4245 }
4246 
4247 impl From<char> for JsString {
4248     #[inline]
from(c: char) -> Self4249     fn from(c: char) -> Self {
4250         JsString::from_code_point1(c as u32).unwrap_throw()
4251     }
4252 }
4253 
4254 impl<'a> From<&'a JsString> for String {
from(s: &'a JsString) -> Self4255     fn from(s: &'a JsString) -> Self {
4256         s.obj.as_string().unwrap_throw()
4257     }
4258 }
4259 
4260 impl From<JsString> for String {
from(s: JsString) -> Self4261     fn from(s: JsString) -> Self {
4262         From::from(&s)
4263     }
4264 }
4265 
4266 impl fmt::Debug for JsString {
fmt(&self, f: &mut fmt::Formatter) -> fmt::Result4267     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
4268         String::from(self).fmt(f)
4269     }
4270 }
4271 
4272 // Symbol
4273 #[wasm_bindgen]
4274 extern "C" {
4275     #[wasm_bindgen(is_type_of = JsValue::is_symbol, typescript_type = "Symbol")]
4276     #[derive(Clone, Debug)]
4277     pub type Symbol;
4278 
4279     /// The `Symbol.hasInstance` well-known symbol is used to determine
4280     /// if a constructor object recognizes an object as its instance.
4281     /// The `instanceof` operator's behavior can be customized by this symbol.
4282     ///
4283     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/hasInstance)
4284     #[wasm_bindgen(static_method_of = Symbol, getter, structural, js_name = hasInstance)]
has_instance() -> Symbol4285     pub fn has_instance() -> Symbol;
4286 
4287     /// The `Symbol.isConcatSpreadable` well-known symbol is used to configure
4288     /// if an object should be flattened to its array elements when using the
4289     /// `Array.prototype.concat()` method.
4290     ///
4291     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/isConcatSpreadable)
4292     #[wasm_bindgen(static_method_of = Symbol, getter, structural, js_name = isConcatSpreadable)]
is_concat_spreadable() -> Symbol4293     pub fn is_concat_spreadable() -> Symbol;
4294 
4295     /// The `Symbol.asyncIterator` well-known symbol specifies the default AsyncIterator for an object.
4296     /// If this property is set on an object, it is an async iterable and can be used in a `for await...of` loop.
4297     ///
4298     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/asyncIterator)
4299     #[wasm_bindgen(static_method_of = Symbol, getter, structural, js_name = asyncIterator)]
async_iterator() -> Symbol4300     pub fn async_iterator() -> Symbol;
4301 
4302     /// The `Symbol.iterator` well-known symbol specifies the default iterator
4303     /// for an object.  Used by `for...of`.
4304     ///
4305     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/iterator)
4306     #[wasm_bindgen(static_method_of = Symbol, getter, structural)]
iterator() -> Symbol4307     pub fn iterator() -> Symbol;
4308 
4309     /// The `Symbol.match` well-known symbol specifies the matching of a regular
4310     /// expression against a string. This function is called by the
4311     /// `String.prototype.match()` method.
4312     ///
4313     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/match)
4314     #[wasm_bindgen(static_method_of = Symbol, getter, structural, js_name = match)]
match_() -> Symbol4315     pub fn match_() -> Symbol;
4316 
4317     /// The `Symbol.replace` well-known symbol specifies the method that
4318     /// replaces matched substrings of a string.  This function is called by the
4319     /// `String.prototype.replace()` method.
4320     ///
4321     /// For more information, see `RegExp.prototype[@@replace]()` and
4322     /// `String.prototype.replace()`.
4323     ///
4324     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/replace)
4325     #[wasm_bindgen(static_method_of = Symbol, getter, structural)]
replace() -> Symbol4326     pub fn replace() -> Symbol;
4327 
4328     /// The `Symbol.search` well-known symbol specifies the method that returns
4329     /// the index within a string that matches the regular expression.  This
4330     /// function is called by the `String.prototype.search()` method.
4331     ///
4332     /// For more information, see `RegExp.prototype[@@search]()` and
4333     /// `String.prototype.search()`.
4334     ///
4335     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/search)
4336     #[wasm_bindgen(static_method_of = Symbol, getter, structural)]
search() -> Symbol4337     pub fn search() -> Symbol;
4338 
4339     /// The well-known symbol `Symbol.species` specifies a function-valued
4340     /// property that the constructor function uses to create derived objects.
4341     ///
4342     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/species)
4343     #[wasm_bindgen(static_method_of = Symbol, getter, structural)]
species() -> Symbol4344     pub fn species() -> Symbol;
4345 
4346     /// The `Symbol.split` well-known symbol specifies the method that splits a
4347     /// string at the indices that match a regular expression.  This function is
4348     /// called by the `String.prototype.split()` method.
4349     ///
4350     /// For more information, see `RegExp.prototype[@@split]()` and
4351     /// `String.prototype.split()`.
4352     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/split)
4353     #[wasm_bindgen(static_method_of = Symbol, getter, structural)]
split() -> Symbol4354     pub fn split() -> Symbol;
4355 
4356     /// The `Symbol.toPrimitive` is a symbol that specifies a function valued
4357     /// property that is called to convert an object to a corresponding
4358     /// primitive value.
4359     ///
4360     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toPrimitive)
4361     #[wasm_bindgen(static_method_of = Symbol, getter, structural, js_name = toPrimitive)]
to_primitive() -> Symbol4362     pub fn to_primitive() -> Symbol;
4363 
4364     /// The `Symbol.toStringTag` well-known symbol is a string valued property
4365     /// that is used in the creation of the default string description of an
4366     /// object.  It is accessed internally by the `Object.prototype.toString()`
4367     /// method.
4368     ///
4369     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toString)
4370     #[wasm_bindgen(static_method_of = Symbol, getter, structural, js_name = toStringTag)]
to_string_tag() -> Symbol4371     pub fn to_string_tag() -> Symbol;
4372 
4373     /// The `Symbol.for(key)` method searches for existing symbols in a runtime-wide symbol registry with
4374     /// the given key and returns it if found.
4375     /// Otherwise a new symbol gets created in the global symbol registry with this key.
4376     ///
4377     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/for)
4378     #[wasm_bindgen(static_method_of = Symbol, js_name = for)]
for_(key: &str) -> Symbol4379     pub fn for_(key: &str) -> Symbol;
4380 
4381     /// The `Symbol.keyFor(sym)` method retrieves a shared symbol key from the global symbol registry for the given symbol.
4382     ///
4383     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/keyFor)
4384     #[wasm_bindgen(static_method_of = Symbol, js_name = keyFor)]
key_for(sym: &Symbol) -> JsValue4385     pub fn key_for(sym: &Symbol) -> JsValue;
4386 
4387     /// The `toString()` method returns a string representing the specified Symbol object.
4388     ///
4389     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toString)
4390     #[wasm_bindgen(method, js_name = toString)]
to_string(this: &Symbol) -> JsString4391     pub fn to_string(this: &Symbol) -> JsString;
4392 
4393     /// The `Symbol.unscopables` well-known symbol is used to specify an object
4394     /// value of whose own and inherited property names are excluded from the
4395     /// with environment bindings of the associated object.
4396     ///
4397     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/unscopables)
4398     #[wasm_bindgen(static_method_of = Symbol, getter, structural)]
unscopables() -> Symbol4399     pub fn unscopables() -> Symbol;
4400 
4401     /// The `valueOf()` method returns the primitive value of a Symbol object.
4402     ///
4403     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/valueOf)
4404     #[wasm_bindgen(method, js_name = valueOf)]
value_of(this: &Symbol) -> Symbol4405     pub fn value_of(this: &Symbol) -> Symbol;
4406 }
4407 
4408 #[allow(non_snake_case)]
4409 pub mod Intl {
4410     use super::*;
4411 
4412     // Intl
4413     #[wasm_bindgen]
4414     extern "C" {
4415         /// The `Intl.getCanonicalLocales()` method returns an array containing
4416         /// the canonical locale names. Duplicates will be omitted and elements
4417         /// will be validated as structurally valid language tags.
4418         ///
4419         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/getCanonicalLocales)
4420         #[wasm_bindgen(js_name = getCanonicalLocales, js_namespace = Intl)]
get_canonical_locales(s: &JsValue) -> Array4421         pub fn get_canonical_locales(s: &JsValue) -> Array;
4422     }
4423 
4424     // Intl.Collator
4425     #[wasm_bindgen]
4426     extern "C" {
4427         /// The `Intl.Collator` object is a constructor for collators, objects
4428         /// that enable language sensitive string comparison.
4429         ///
4430         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator)
4431         #[wasm_bindgen(extends = Object, js_namespace = Intl, typescript_type = "Intl.Collator")]
4432         #[derive(Clone, Debug)]
4433         pub type Collator;
4434 
4435         /// The `Intl.Collator` object is a constructor for collators, objects
4436         /// that enable language sensitive string comparison.
4437         ///
4438         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator)
4439         #[wasm_bindgen(constructor, js_namespace = Intl)]
new(locales: &Array, options: &Object) -> Collator4440         pub fn new(locales: &Array, options: &Object) -> Collator;
4441 
4442         /// The Intl.Collator.prototype.compare property returns a function that
4443         /// compares two strings according to the sort order of this Collator
4444         /// object.
4445         ///
4446         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator/compare)
4447         #[wasm_bindgen(method, getter, js_class = "Intl.Collator")]
compare(this: &Collator) -> Function4448         pub fn compare(this: &Collator) -> Function;
4449 
4450         /// The `Intl.Collator.prototype.resolvedOptions()` method returns a new
4451         /// object with properties reflecting the locale and collation options
4452         /// computed during initialization of this Collator object.
4453         ///
4454         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator/resolvedOptions)
4455         #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
resolved_options(this: &Collator) -> Object4456         pub fn resolved_options(this: &Collator) -> Object;
4457 
4458         /// The `Intl.Collator.supportedLocalesOf()` method returns an array
4459         /// containing those of the provided locales that are supported in
4460         /// collation without having to fall back to the runtime's default
4461         /// locale.
4462         ///
4463         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator/supportedLocalesOf)
4464         #[wasm_bindgen(static_method_of = Collator, js_namespace = Intl, js_name = supportedLocalesOf)]
supported_locales_of(locales: &Array, options: &Object) -> Array4465         pub fn supported_locales_of(locales: &Array, options: &Object) -> Array;
4466     }
4467 
4468     // Intl.DateTimeFormat
4469     #[wasm_bindgen]
4470     extern "C" {
4471         /// The `Intl.DateTimeFormat` object is a constructor for objects
4472         /// that enable language-sensitive date and time formatting.
4473         ///
4474         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat)
4475         #[wasm_bindgen(extends = Object, js_namespace = Intl, typescript_type = "Intl.DateTimeFormat")]
4476         #[derive(Clone, Debug)]
4477         pub type DateTimeFormat;
4478 
4479         /// The `Intl.DateTimeFormat` object is a constructor for objects
4480         /// that enable language-sensitive date and time formatting.
4481         ///
4482         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat)
4483         #[wasm_bindgen(constructor, js_namespace = Intl)]
new(locales: &Array, options: &Object) -> DateTimeFormat4484         pub fn new(locales: &Array, options: &Object) -> DateTimeFormat;
4485 
4486         /// The Intl.DateTimeFormat.prototype.format property returns a getter function that
4487         /// formats a date according to the locale and formatting options of this
4488         /// Intl.DateTimeFormat object.
4489         ///
4490         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/format)
4491         #[wasm_bindgen(method, getter, js_class = "Intl.DateTimeFormat")]
format(this: &DateTimeFormat) -> Function4492         pub fn format(this: &DateTimeFormat) -> Function;
4493 
4494         /// The `Intl.DateTimeFormat.prototype.formatToParts()` method allows locale-aware
4495         /// formatting of strings produced by DateTimeFormat formatters.
4496         ///
4497         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/formatToParts)
4498         #[wasm_bindgen(method, js_class = "Intl.DateTimeFormat", js_name = formatToParts)]
format_to_parts(this: &DateTimeFormat, date: &Date) -> Array4499         pub fn format_to_parts(this: &DateTimeFormat, date: &Date) -> Array;
4500 
4501         /// The `Intl.DateTimeFormat.prototype.resolvedOptions()` method returns a new
4502         /// object with properties reflecting the locale and date and time formatting
4503         /// options computed during initialization of this DateTimeFormat object.
4504         ///
4505         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/resolvedOptions)
4506         #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
resolved_options(this: &DateTimeFormat) -> Object4507         pub fn resolved_options(this: &DateTimeFormat) -> Object;
4508 
4509         /// The `Intl.DateTimeFormat.supportedLocalesOf()` method returns an array
4510         /// containing those of the provided locales that are supported in date
4511         /// and time formatting without having to fall back to the runtime's default
4512         /// locale.
4513         ///
4514         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/supportedLocalesOf)
4515         #[wasm_bindgen(static_method_of = DateTimeFormat, js_namespace = Intl, js_name = supportedLocalesOf)]
supported_locales_of(locales: &Array, options: &Object) -> Array4516         pub fn supported_locales_of(locales: &Array, options: &Object) -> Array;
4517     }
4518 
4519     // Intl.NumberFormat
4520     #[wasm_bindgen]
4521     extern "C" {
4522         /// The `Intl.NumberFormat` object is a constructor for objects
4523         /// that enable language sensitive number formatting.
4524         ///
4525         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat)
4526         #[wasm_bindgen(extends = Object, js_namespace = Intl, typescript_type = "Intl.NumberFormat")]
4527         #[derive(Clone, Debug)]
4528         pub type NumberFormat;
4529 
4530         /// The `Intl.NumberFormat` object is a constructor for objects
4531         /// that enable language sensitive number formatting.
4532         ///
4533         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat)
4534         #[wasm_bindgen(constructor, js_namespace = Intl)]
new(locales: &Array, options: &Object) -> NumberFormat4535         pub fn new(locales: &Array, options: &Object) -> NumberFormat;
4536 
4537         /// The Intl.NumberFormat.prototype.format property returns a getter function that
4538         /// formats a number according to the locale and formatting options of this
4539         /// NumberFormat object.
4540         ///
4541         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/format)
4542         #[wasm_bindgen(method, getter, js_class = "Intl.NumberFormat")]
format(this: &NumberFormat) -> Function4543         pub fn format(this: &NumberFormat) -> Function;
4544 
4545         /// The `Intl.Numberformat.prototype.formatToParts()` method allows locale-aware
4546         /// formatting of strings produced by NumberTimeFormat formatters.
4547         ///
4548         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/formatToParts)
4549         #[wasm_bindgen(method, js_class = "Intl.NumberFormat", js_name = formatToParts)]
format_to_parts(this: &NumberFormat, number: f64) -> Array4550         pub fn format_to_parts(this: &NumberFormat, number: f64) -> Array;
4551 
4552         /// The `Intl.NumberFormat.prototype.resolvedOptions()` method returns a new
4553         /// object with properties reflecting the locale and number formatting
4554         /// options computed during initialization of this NumberFormat object.
4555         ///
4556         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/resolvedOptions)
4557         #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
resolved_options(this: &NumberFormat) -> Object4558         pub fn resolved_options(this: &NumberFormat) -> Object;
4559 
4560         /// The `Intl.NumberFormat.supportedLocalesOf()` method returns an array
4561         /// containing those of the provided locales that are supported in number
4562         /// formatting without having to fall back to the runtime's default locale.
4563         ///
4564         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/supportedLocalesOf)
4565         #[wasm_bindgen(static_method_of = NumberFormat, js_namespace = Intl, js_name = supportedLocalesOf)]
supported_locales_of(locales: &Array, options: &Object) -> Array4566         pub fn supported_locales_of(locales: &Array, options: &Object) -> Array;
4567     }
4568 
4569     // Intl.PluralRules
4570     #[wasm_bindgen]
4571     extern "C" {
4572         /// The `Intl.PluralRules` object is a constructor for objects
4573         /// that enable plural sensitive formatting and plural language rules.
4574         ///
4575         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules)
4576         #[wasm_bindgen(extends = Object, js_namespace = Intl, typescript_type = "Intl.PluralRules")]
4577         #[derive(Clone, Debug)]
4578         pub type PluralRules;
4579 
4580         /// The `Intl.PluralRules` object is a constructor for objects
4581         /// that enable plural sensitive formatting and plural language rules.
4582         ///
4583         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules)
4584         #[wasm_bindgen(constructor, js_namespace = Intl)]
new(locales: &Array, options: &Object) -> PluralRules4585         pub fn new(locales: &Array, options: &Object) -> PluralRules;
4586 
4587         /// The `Intl.PluralRules.prototype.resolvedOptions()` method returns a new
4588         /// object with properties reflecting the locale and plural formatting
4589         /// options computed during initialization of this PluralRules object.
4590         ///
4591         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules/resolvedOptions)
4592         #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
resolved_options(this: &PluralRules) -> Object4593         pub fn resolved_options(this: &PluralRules) -> Object;
4594 
4595         /// The `Intl.PluralRules.prototype.select()` method returns a String indicating
4596         /// which plural rule to use for locale-aware formatting.
4597         ///
4598         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules/select)
4599         #[wasm_bindgen(method, js_namespace = Intl)]
select(this: &PluralRules, number: f64) -> JsString4600         pub fn select(this: &PluralRules, number: f64) -> JsString;
4601 
4602         /// The `Intl.PluralRules.supportedLocalesOf()` method returns an array
4603         /// containing those of the provided locales that are supported in plural
4604         /// formatting without having to fall back to the runtime's default locale.
4605         ///
4606         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules/supportedLocalesOf)
4607         #[wasm_bindgen(static_method_of = PluralRules, js_namespace = Intl, js_name = supportedLocalesOf)]
supported_locales_of(locales: &Array, options: &Object) -> Array4608         pub fn supported_locales_of(locales: &Array, options: &Object) -> Array;
4609     }
4610 }
4611 
4612 // Promise
4613 #[wasm_bindgen]
4614 extern "C" {
4615     /// The `Promise` object represents the eventual completion (or failure) of
4616     /// an asynchronous operation, and its resulting value.
4617     ///
4618     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
4619     #[must_use]
4620     #[wasm_bindgen(extends = Object, typescript_type = "Promise<any>")]
4621     #[derive(Clone, Debug)]
4622     pub type Promise;
4623 
4624     /// Creates a new `Promise` with the provided executor `cb`
4625     ///
4626     /// The `cb` is a function that is passed with the arguments `resolve` and
4627     /// `reject`. The `cb` function is executed immediately by the `Promise`
4628     /// implementation, passing `resolve` and `reject` functions (the executor
4629     /// is called before the `Promise` constructor even returns the created
4630     /// object). The `resolve` and `reject` functions, when called, resolve or
4631     /// reject the promise, respectively. The executor normally initiates
4632     /// some asynchronous work, and then, once that completes, either calls
4633     /// the `resolve` function to resolve the promise or else rejects it if an
4634     /// error occurred.
4635     ///
4636     /// If an error is thrown in the executor function, the promise is rejected.
4637     /// The return value of the executor is ignored.
4638     ///
4639     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
4640     #[wasm_bindgen(constructor)]
new(cb: &mut dyn FnMut(Function, Function)) -> Promise4641     pub fn new(cb: &mut dyn FnMut(Function, Function)) -> Promise;
4642 
4643     /// The `Promise.all(iterable)` method returns a single `Promise` that
4644     /// resolves when all of the promises in the iterable argument have resolved
4645     /// or when the iterable argument contains no promises. It rejects with the
4646     /// reason of the first promise that rejects.
4647     ///
4648     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all)
4649     #[wasm_bindgen(static_method_of = Promise)]
all(obj: &JsValue) -> Promise4650     pub fn all(obj: &JsValue) -> Promise;
4651 
4652     /// The `Promise.race(iterable)` method returns a promise that resolves or
4653     /// rejects as soon as one of the promises in the iterable resolves or
4654     /// rejects, with the value or reason from that promise.
4655     ///
4656     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/race)
4657     #[wasm_bindgen(static_method_of = Promise)]
race(obj: &JsValue) -> Promise4658     pub fn race(obj: &JsValue) -> Promise;
4659 
4660     /// The `Promise.reject(reason)` method returns a `Promise` object that is
4661     /// rejected with the given reason.
4662     ///
4663     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/reject)
4664     #[wasm_bindgen(static_method_of = Promise)]
reject(obj: &JsValue) -> Promise4665     pub fn reject(obj: &JsValue) -> Promise;
4666 
4667     /// The `Promise.resolve(value)` method returns a `Promise` object that is
4668     /// resolved with the given value. If the value is a promise, that promise
4669     /// is returned; if the value is a thenable (i.e. has a "then" method), the
4670     /// returned promise will "follow" that thenable, adopting its eventual
4671     /// state; otherwise the returned promise will be fulfilled with the value.
4672     ///
4673     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/resolve)
4674     #[wasm_bindgen(static_method_of = Promise)]
resolve(obj: &JsValue) -> Promise4675     pub fn resolve(obj: &JsValue) -> Promise;
4676 
4677     /// The `catch()` method returns a `Promise` and deals with rejected cases
4678     /// only.  It behaves the same as calling `Promise.prototype.then(undefined,
4679     /// onRejected)` (in fact, calling `obj.catch(onRejected)` internally calls
4680     /// `obj.then(undefined, onRejected)`).
4681     ///
4682     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/catch)
4683     #[wasm_bindgen(method)]
catch(this: &Promise, cb: &Closure<dyn FnMut(JsValue)>) -> Promise4684     pub fn catch(this: &Promise, cb: &Closure<dyn FnMut(JsValue)>) -> Promise;
4685 
4686     /// The `then()` method returns a `Promise`. It takes up to two arguments:
4687     /// callback functions for the success and failure cases of the `Promise`.
4688     ///
4689     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then)
4690     #[wasm_bindgen(method)]
then(this: &Promise, cb: &Closure<dyn FnMut(JsValue)>) -> Promise4691     pub fn then(this: &Promise, cb: &Closure<dyn FnMut(JsValue)>) -> Promise;
4692 
4693     /// Same as `then`, only with both arguments provided.
4694     #[wasm_bindgen(method, js_name = then)]
then2( this: &Promise, resolve: &Closure<dyn FnMut(JsValue)>, reject: &Closure<dyn FnMut(JsValue)>, ) -> Promise4695     pub fn then2(
4696         this: &Promise,
4697         resolve: &Closure<dyn FnMut(JsValue)>,
4698         reject: &Closure<dyn FnMut(JsValue)>,
4699     ) -> Promise;
4700 
4701     /// The `finally()` method returns a `Promise`. When the promise is settled,
4702     /// whether fulfilled or rejected, the specified callback function is
4703     /// executed. This provides a way for code that must be executed once the
4704     /// `Promise` has been dealt with to be run whether the promise was
4705     /// fulfilled successfully or rejected.
4706     ///
4707     /// This lets you avoid duplicating code in both the promise's `then()` and
4708     /// `catch()` handlers.
4709     ///
4710     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/finally)
4711     #[wasm_bindgen(method)]
finally(this: &Promise, cb: &Closure<dyn FnMut()>) -> Promise4712     pub fn finally(this: &Promise, cb: &Closure<dyn FnMut()>) -> Promise;
4713 }
4714 
4715 /// Returns a handle to the global scope object.
4716 ///
4717 /// This allows access to the global properties and global names by accessing
4718 /// the `Object` returned.
global() -> Object4719 pub fn global() -> Object {
4720     thread_local!(static GLOBAL: Object = get_global_object());
4721 
4722     return GLOBAL.with(|g| g.clone());
4723 
4724     fn get_global_object() -> Object {
4725         // This is a bit wonky, but we're basically using `#[wasm_bindgen]`
4726         // attributes to synthesize imports so we can access properties of the
4727         // form:
4728         //
4729         // * `globalThis.globalThis`
4730         // * `self.self`
4731         // * ... (etc)
4732         //
4733         // Accessing the global object is not an easy thing to do, and what we
4734         // basically want is `globalThis` but we can't rely on that existing
4735         // everywhere. In the meantime we've got the fallbacks mentioned in:
4736         //
4737         // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis
4738         //
4739         // Note that this is pretty heavy code-size wise but it at least gets
4740         // the job largely done for now and avoids the `Function` constructor at
4741         // the end which triggers CSP errors.
4742         #[wasm_bindgen]
4743         extern "C" {
4744             type Global;
4745 
4746             #[wasm_bindgen(getter, catch, static_method_of = Global, js_class = globalThis, js_name = globalThis)]
4747             fn get_global_this() -> Result<Object, JsValue>;
4748 
4749             #[wasm_bindgen(getter, catch, static_method_of = Global, js_class = self, js_name = self)]
4750             fn get_self() -> Result<Object, JsValue>;
4751 
4752             #[wasm_bindgen(getter, catch, static_method_of = Global, js_class = window, js_name = window)]
4753             fn get_window() -> Result<Object, JsValue>;
4754 
4755             #[wasm_bindgen(getter, catch, static_method_of = Global, js_class = global, js_name = global)]
4756             fn get_global() -> Result<Object, JsValue>;
4757         }
4758 
4759         // The order is important: in Firefox Extension Content Scripts `globalThis`
4760         // is a Sandbox (not Window), so `globalThis` must be checked after `window`.
4761         let static_object = Global::get_self()
4762             .or_else(|_| Global::get_window())
4763             .or_else(|_| Global::get_global_this())
4764             .or_else(|_| Global::get_global());
4765         if let Ok(obj) = static_object {
4766             if !obj.is_undefined() {
4767                 return obj;
4768             }
4769         }
4770 
4771         // According to StackOverflow you can access the global object via:
4772         //
4773         //      const global = Function('return this')();
4774         //
4775         // I think that's because the manufactured function isn't in "strict" mode.
4776         // It also turns out that non-strict functions will ignore `undefined`
4777         // values for `this` when using the `apply` function.
4778         //
4779         // As a result we use the equivalent of this snippet to get a handle to the
4780         // global object in a sort of roundabout way that should hopefully work in
4781         // all contexts like ESM, node, browsers, etc.
4782         let this = Function::new_no_args("return this")
4783             .call0(&JsValue::undefined())
4784             .ok();
4785 
4786         // Note that we avoid `unwrap()` on `call0` to avoid code size bloat, we
4787         // just handle the `Err` case as returning a different object.
4788         debug_assert!(this.is_some());
4789         match this {
4790             Some(this) => this.unchecked_into(),
4791             None => JsValue::undefined().unchecked_into(),
4792         }
4793     }
4794 }
4795 
4796 macro_rules! arrays {
4797     ($(#[doc = $ctor:literal] #[doc = $mdn:literal] $name:ident: $ty:ident,)*) => ($(
4798         #[wasm_bindgen]
4799         extern "C" {
4800             #[wasm_bindgen(extends = Object, typescript_type = $name)]
4801             #[derive(Clone, Debug)]
4802             pub type $name;
4803 
4804             /// The
4805             #[doc = $ctor]
4806             /// constructor creates a new array.
4807             ///
4808             /// [MDN documentation](
4809             #[doc = $mdn]
4810             /// )
4811             #[wasm_bindgen(constructor)]
4812             pub fn new(constructor_arg: &JsValue) -> $name;
4813 
4814             /// An
4815             #[doc = $ctor]
4816             /// which creates an array with an internal buffer large
4817             /// enough for `length` elements.
4818             ///
4819             /// [MDN documentation](
4820             #[doc = $mdn]
4821             /// )
4822             #[wasm_bindgen(constructor)]
4823             pub fn new_with_length(length: u32) -> $name;
4824 
4825             /// An
4826             #[doc = $ctor]
4827             /// which creates an array with the given buffer but is a
4828             /// view starting at `byte_offset`.
4829             ///
4830             /// [MDN documentation](
4831             #[doc = $mdn]
4832             /// )
4833             #[wasm_bindgen(constructor)]
4834             pub fn new_with_byte_offset(buffer: &JsValue, byte_offset: u32) -> $name;
4835 
4836             /// An
4837             #[doc = $ctor]
4838             /// which creates an array with the given buffer but is a
4839             /// view starting at `byte_offset` for `length` elements.
4840             ///
4841             /// [MDN documentation](
4842             #[doc = $mdn]
4843             /// )
4844             #[wasm_bindgen(constructor)]
4845             pub fn new_with_byte_offset_and_length(
4846                 buffer: &JsValue,
4847                 byte_offset: u32,
4848                 length: u32,
4849             ) -> $name;
4850 
4851             /// The `fill()` method fills all the elements of an array from a start index
4852             /// to an end index with a static value. The end index is not included.
4853             ///
4854             /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/fill)
4855             #[wasm_bindgen(method)]
4856             pub fn fill(this: &$name, value: $ty, start: u32, end: u32) -> $name;
4857 
4858             /// The buffer accessor property represents the `ArrayBuffer` referenced
4859             /// by a `TypedArray` at construction time.
4860             #[wasm_bindgen(getter, method)]
4861             pub fn buffer(this: &$name) -> ArrayBuffer;
4862 
4863             /// The `subarray()` method returns a new `TypedArray` on the same
4864             /// `ArrayBuffer` store and with the same element types as for this
4865             /// `TypedArray` object.
4866             #[wasm_bindgen(method)]
4867             pub fn subarray(this: &$name, begin: u32, end: u32) -> $name;
4868 
4869             /// The `slice()` method returns a shallow copy of a portion of a typed
4870             /// array into a new typed array object. This method has the same algorithm
4871             /// as `Array.prototype.slice()`.
4872             #[wasm_bindgen(method)]
4873             pub fn slice(this: &$name, begin: u32, end: u32) -> $name;
4874 
4875             /// The `forEach()` method executes a provided function once per array
4876             /// element. This method has the same algorithm as
4877             /// `Array.prototype.forEach()`. `TypedArray` is one of the typed array
4878             /// types here.
4879             #[wasm_bindgen(method, js_name = forEach)]
4880             pub fn for_each(this: &$name, callback: &mut dyn FnMut($ty, u32, $name));
4881 
4882             /// The length accessor property represents the length (in elements) of a
4883             /// typed array.
4884             #[wasm_bindgen(method, getter)]
4885             pub fn length(this: &$name) -> u32;
4886 
4887             /// The byteLength accessor property represents the length (in bytes) of a
4888             /// typed array.
4889             #[wasm_bindgen(method, getter, js_name = byteLength)]
4890             pub fn byte_length(this: &$name) -> u32;
4891 
4892             /// The byteOffset accessor property represents the offset (in bytes) of a
4893             /// typed array from the start of its `ArrayBuffer`.
4894             #[wasm_bindgen(method, getter, js_name = byteOffset)]
4895             pub fn byte_offset(this: &$name) -> u32;
4896 
4897             /// The `set()` method stores multiple values in the typed array, reading
4898             /// input values from a specified array.
4899             #[wasm_bindgen(method)]
4900             pub fn set(this: &$name, src: &JsValue, offset: u32);
4901 
4902             /// Gets the value at `idx`, equivalent to the javascript `my_var = arr[idx]`.
4903             #[wasm_bindgen(method, structural, indexing_getter)]
4904             pub fn get_index(this: &$name, idx: u32) -> $ty;
4905 
4906             /// Sets the value at `idx`, equivalent to the javascript `arr[idx] = value`.
4907             #[wasm_bindgen(method, structural, indexing_setter)]
4908             pub fn set_index(this: &$name, idx: u32, value: $ty);
4909         }
4910 
4911         impl $name {
4912             /// Creates a JS typed array which is a view into wasm's linear
4913             /// memory at the slice specified.
4914             ///
4915             /// This function returns a new typed array which is a view into
4916             /// wasm's memory. This view does not copy the underlying data.
4917             ///
4918             /// # Unsafety
4919             ///
4920             /// Views into WebAssembly memory are only valid so long as the
4921             /// backing buffer isn't resized in JS. Once this function is called
4922             /// any future calls to `Box::new` (or malloc of any form) may cause
4923             /// the returned value here to be invalidated. Use with caution!
4924             ///
4925             /// Additionally the returned object can be safely mutated but the
4926             /// input slice isn't guaranteed to be mutable.
4927             ///
4928             /// Finally, the returned object is disconnected from the input
4929             /// slice's lifetime, so there's no guarantee that the data is read
4930             /// at the right time.
4931             pub unsafe fn view(rust: &[$ty]) -> $name {
4932                 let buf = wasm_bindgen::memory();
4933                 let mem = buf.unchecked_ref::<WebAssembly::Memory>();
4934                 $name::new_with_byte_offset_and_length(
4935                     &mem.buffer(),
4936                     rust.as_ptr() as u32,
4937                     rust.len() as u32,
4938                 )
4939             }
4940 
4941             /// Creates a JS typed array which is a view into wasm's linear
4942             /// memory at the specified pointer with specified length.
4943             ///
4944             /// This function returns a new typed array which is a view into
4945             /// wasm's memory. This view does not copy the underlying data.
4946             ///
4947             /// # Unsafety
4948             ///
4949             /// Views into WebAssembly memory are only valid so long as the
4950             /// backing buffer isn't resized in JS. Once this function is called
4951             /// any future calls to `Box::new` (or malloc of any form) may cause
4952             /// the returned value here to be invalidated. Use with caution!
4953             ///
4954             /// Additionally the returned object can be safely mutated,
4955             /// the changes are guranteed to be reflected in the input array.
4956             pub unsafe fn view_mut_raw(ptr: *mut $ty, length: usize) -> $name {
4957                 let buf = wasm_bindgen::memory();
4958                 let mem = buf.unchecked_ref::<WebAssembly::Memory>();
4959                 $name::new_with_byte_offset_and_length(
4960                     &mem.buffer(),
4961                     ptr as u32,
4962                     length as u32
4963                 )
4964             }
4965 
4966             fn raw_copy_to(&self, dst: &mut [$ty]) {
4967                 let buf = wasm_bindgen::memory();
4968                 let mem = buf.unchecked_ref::<WebAssembly::Memory>();
4969                 let all_wasm_memory = $name::new(&mem.buffer());
4970                 let offset = dst.as_ptr() as usize / mem::size_of::<$ty>();
4971                 all_wasm_memory.set(self, offset as u32);
4972             }
4973 
4974             /// Copy the contents of this JS typed array into the destination
4975             /// Rust slice.
4976             ///
4977             /// This function will efficiently copy the memory from a typed
4978             /// array into this wasm module's own linear memory, initializing
4979             /// the memory destination provided.
4980             ///
4981             /// # Panics
4982             ///
4983             /// This function will panic if this typed array's length is
4984             /// different than the length of the provided `dst` array.
4985             pub fn copy_to(&self, dst: &mut [$ty]) {
4986                 assert_eq!(self.length() as usize, dst.len());
4987                 self.raw_copy_to(dst);
4988             }
4989 
4990             /// Copy the contents of the source Rust slice into this
4991             /// JS typed array.
4992             ///
4993             /// This function will efficiently copy the memory from within
4994             /// the wasm module's own linear memory to this typed array.
4995             ///
4996             /// # Panics
4997             ///
4998             /// This function will panic if this typed array's length is
4999             /// different than the length of the provided `src` array.
5000             pub fn copy_from(&self, src: &[$ty]) {
5001                 assert_eq!(self.length() as usize, src.len());
5002                 // This is safe because the `set` function copies from its TypedArray argument
5003                 unsafe { self.set(&$name::view(src), 0) }
5004             }
5005 
5006             /// Efficiently copies the contents of this JS typed array into a new Vec.
5007             pub fn to_vec(&self) -> Vec<$ty> {
5008                 let mut output = vec![$ty::default(); self.length() as usize];
5009                 self.raw_copy_to(&mut output);
5010                 output
5011             }
5012         }
5013 
5014         impl<'a> From<&'a [$ty]> for $name {
5015             #[inline]
5016             fn from(slice: &'a [$ty]) -> $name {
5017                 // This is safe because the `new` function makes a copy if its argument is a TypedArray
5018                 unsafe { $name::new(&$name::view(slice)) }
5019             }
5020         }
5021     )*);
5022 }
5023 
5024 arrays! {
5025     /// `Int8Array()`
5026     /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int8Array
5027     Int8Array: i8,
5028 
5029     /// `Int16Array()`
5030     /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int16Array
5031     Int16Array: i16,
5032 
5033     /// `Int32Array()`
5034     /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int32Array
5035     Int32Array: i32,
5036 
5037     /// `Uint8Array()`
5038     /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array
5039     Uint8Array: u8,
5040 
5041     /// `Uint8ClampedArray()`
5042     /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8ClampedArray
5043     Uint8ClampedArray: u8,
5044 
5045     /// `Uint16Array()`
5046     /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint16Array
5047     Uint16Array: u16,
5048 
5049     /// `Uint32Array()`
5050     /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint32Array
5051     Uint32Array: u32,
5052 
5053     /// `Float32Array()`
5054     /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float32Array
5055     Float32Array: f32,
5056 
5057     /// `Float64Array()`
5058     /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float64Array
5059     Float64Array: f64,
5060 }
5061