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::fmt;
22 use std::mem;
23 
24 use wasm_bindgen::prelude::*;
25 use wasm_bindgen::JsCast;
26 
27 // When adding new imports:
28 //
29 // * Keep imports in alphabetical order.
30 //
31 // * Rename imports with `js_name = ...` according to the note about `camelCase`
32 //   and `snake_case` in the module's documentation above.
33 //
34 // * Include the one sentence summary of the import from the MDN link in the
35 //   module's documentation above, and the MDN link itself.
36 //
37 // * If a function or method can throw an exception, make it catchable by adding
38 //   `#[wasm_bindgen(catch)]`.
39 //
40 // * Add a new `#[test]` into the appropriate file in the
41 //   `crates/js-sys/tests/wasm/` directory. If the imported function or method
42 //   can throw an exception, make sure to also add test coverage for that case.
43 //
44 // * Arguments that are `JsValue`s or imported JavaScript types should be taken
45 //   by reference.
46 
47 #[wasm_bindgen]
48 extern "C" {
49     /// The `decodeURI()` function decodes a Uniform Resource Identifier (URI)
50     /// previously created by `encodeURI` or by a similar routine.
51     ///
52     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURI)
53     #[wasm_bindgen(catch, js_name = decodeURI)]
decode_uri(encoded: &str) -> Result<JsString, JsValue>54     pub fn decode_uri(encoded: &str) -> Result<JsString, JsValue>;
55 
56     /// The `decodeURIComponent()` function decodes a Uniform Resource Identifier (URI) component
57     /// previously created by `encodeURIComponent` or by a similar routine.
58     ///
59     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent)
60     #[wasm_bindgen(catch, js_name = decodeURIComponent)]
decode_uri_component(encoded: &str) -> Result<JsString, JsValue>61     pub fn decode_uri_component(encoded: &str) -> Result<JsString, JsValue>;
62 
63     /// The `encodeURI()` function encodes a Uniform Resource Identifier (URI)
64     /// by replacing each instance of certain characters by one, two, three, or
65     /// four escape sequences representing the UTF-8 encoding of the character
66     /// (will only be four escape sequences for characters composed of two
67     /// "surrogate" characters).
68     ///
69     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI)
70     #[wasm_bindgen(js_name = encodeURI)]
encode_uri(decoded: &str) -> JsString71     pub fn encode_uri(decoded: &str) -> JsString;
72 
73     /// The `encodeURIComponent()` function encodes a Uniform Resource Identifier (URI) component
74     /// by replacing each instance of certain characters by one, two, three, or four escape sequences
75     /// representing the UTF-8 encoding of the character
76     /// (will only be four escape sequences for characters composed of two "surrogate" characters).
77     ///
78     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent)
79     #[wasm_bindgen(js_name = encodeURIComponent)]
encode_uri_component(decoded: &str) -> JsString80     pub fn encode_uri_component(decoded: &str) -> JsString;
81 
82     /// The `eval()` function evaluates JavaScript code represented as a string.
83     ///
84     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval)
85     #[wasm_bindgen(catch)]
eval(js_source_text: &str) -> Result<JsValue, JsValue>86     pub fn eval(js_source_text: &str) -> Result<JsValue, JsValue>;
87 
88     /// The global `isFinite()` function determines whether the passed value is a finite number.
89     /// If needed, the parameter is first converted to a number.
90     ///
91     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/isFinite)
92     #[wasm_bindgen(js_name = isFinite)]
is_finite(value: &JsValue) -> bool93     pub fn is_finite(value: &JsValue) -> bool;
94 
95     /// The `parseInt()` function parses a string argument and returns an integer
96     /// of the specified radix (the base in mathematical numeral systems), or NaN on error.
97     ///
98     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt)
99     #[wasm_bindgen(js_name = parseInt)]
parse_int(text: &str, radix: u8) -> f64100     pub fn parse_int(text: &str, radix: u8) -> f64;
101 
102     /// The `parseFloat()` function parses an argument and returns a floating point number,
103     /// or NaN on error.
104     ///
105     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseFloat)
106     #[wasm_bindgen(js_name = parseFloat)]
parse_float(text: &str) -> f64107     pub fn parse_float(text: &str) -> f64;
108 
109     /// The `escape()` function computes a new string in which certain characters have been
110     /// replaced by a hexadecimal escape sequence.
111     ///
112     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/escape)
113     #[wasm_bindgen]
escape(string: &str) -> JsString114     pub fn escape(string: &str) -> JsString;
115 
116     /// The `unescape()` function computes a new string in which hexadecimal escape
117     /// sequences are replaced with the character that it represents. The escape sequences might
118     /// be introduced by a function like `escape`. Usually, `decodeURI` or `decodeURIComponent`
119     /// are preferred over `unescape`.
120     ///
121     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/unescape)
122     #[wasm_bindgen]
unescape(string: &str) -> JsString123     pub fn unescape(string: &str) -> JsString;
124 }
125 
126 // Array
127 #[wasm_bindgen]
128 extern "C" {
129     #[wasm_bindgen(extends = Object, is_type_of = Array::is_array)]
130     #[derive(Clone, Debug, PartialEq, Eq)]
131     pub type Array;
132 
133     /// Creates a new empty array.
134     #[wasm_bindgen(constructor)]
new() -> Array135     pub fn new() -> Array;
136 
137     /// Creates a new array with the specified length (elements are initialized to `undefined`).
138     #[wasm_bindgen(constructor)]
new_with_length(len: u32) -> Array139     pub fn new_with_length(len: u32) -> Array;
140 
141     /// Retrieves the element at the index (returns `undefined` if the index is out of range).
142     #[wasm_bindgen(method, structural, indexing_getter)]
get(this: &Array, index: u32) -> JsValue143     pub fn get(this: &Array, index: u32) -> JsValue;
144 
145     /// Sets the element at the index (auto-enlarges the array if the index is out of range).
146     #[wasm_bindgen(method, structural, indexing_setter)]
set(this: &Array, index: u32, value: JsValue)147     pub fn set(this: &Array, index: u32, value: JsValue);
148 
149     /// Deletes the element at the index (does nothing if the index is out of range).
150     ///
151     /// The element at the index is set to `undefined`.
152     ///
153     /// This does not resize the array, the array will still be the same length.
154     #[wasm_bindgen(method, structural, indexing_deleter)]
delete(this: &Array, index: u32)155     pub fn delete(this: &Array, index: u32);
156 
157     /// The `Array.from()` method creates a new, shallow-copied `Array` instance
158     /// from an array-like or iterable object.
159     #[wasm_bindgen(static_method_of = Array)]
from(val: &JsValue) -> Array160     pub fn from(val: &JsValue) -> Array;
161 
162     /// The `copyWithin()` method shallow copies part of an array to another
163     /// location in the same array and returns it, without modifying its size.
164     ///
165     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin)
166     #[wasm_bindgen(method, js_name = copyWithin)]
copy_within(this: &Array, target: i32, start: i32, end: i32) -> Array167     pub fn copy_within(this: &Array, target: i32, start: i32, end: i32) -> Array;
168 
169     /// The `concat()` method is used to merge two or more arrays. This method
170     /// does not change the existing arrays, but instead returns a new array.
171     ///
172     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat)
173     #[wasm_bindgen(method)]
concat(this: &Array, array: &Array) -> Array174     pub fn concat(this: &Array, array: &Array) -> Array;
175 
176     /// The `every()` method tests whether all elements in the array pass the test
177     /// implemented by the provided function.
178     ///
179     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every)
180     #[wasm_bindgen(method)]
every(this: &Array, predicate: &mut dyn FnMut(JsValue, u32, Array) -> bool) -> bool181     pub fn every(this: &Array, predicate: &mut dyn FnMut(JsValue, u32, Array) -> bool) -> bool;
182 
183     /// The `fill()` method fills all the elements of an array from a start index
184     /// to an end index with a static value. The end index is not included.
185     ///
186     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fill)
187     #[wasm_bindgen(method)]
fill(this: &Array, value: &JsValue, start: u32, end: u32) -> Array188     pub fn fill(this: &Array, value: &JsValue, start: u32, end: u32) -> Array;
189 
190     /// The `filter()` method creates a new array with all elements that pass the
191     /// test implemented by the provided function.
192     ///
193     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter)
194     #[wasm_bindgen(method)]
filter(this: &Array, predicate: &mut dyn FnMut(JsValue, u32, Array) -> bool) -> Array195     pub fn filter(this: &Array, predicate: &mut dyn FnMut(JsValue, u32, Array) -> bool) -> Array;
196 
197     /// The `find()` method returns the value of the first element in the array that satisfies
198     ///  the provided testing function. Otherwise `undefined` is returned.
199     ///
200     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find)
201     #[wasm_bindgen(method)]
find(this: &Array, predicate: &mut dyn FnMut(JsValue, u32, Array) -> bool) -> JsValue202     pub fn find(this: &Array, predicate: &mut dyn FnMut(JsValue, u32, Array) -> bool) -> JsValue;
203 
204     /// The `findIndex()` method returns the index of the first element in the array that
205     /// satisfies the provided testing function. Otherwise -1 is returned.
206     ///
207     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex)
208     #[wasm_bindgen(method, js_name = findIndex)]
find_index(this: &Array, predicate: &mut dyn FnMut(JsValue, u32, Array) -> bool) -> i32209     pub fn find_index(this: &Array, predicate: &mut dyn FnMut(JsValue, u32, Array) -> bool) -> i32;
210 
211     /// The `flat()` method creates a new array with all sub-array elements concatenated into it
212     /// recursively up to the specified depth.
213     ///
214     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat)
215     #[wasm_bindgen(method)]
flat(this: &Array, depth: i32) -> Array216     pub fn flat(this: &Array, depth: i32) -> Array;
217 
218     /// The `flatMap()` method first maps each element using a mapping function, then flattens
219     /// the result into a new array.
220     ///
221     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap)
222     #[wasm_bindgen(method, js_name = flatMap)]
flat_map( this: &Array, callback: &mut dyn FnMut(JsValue, u32, Array) -> Vec<JsValue>, ) -> Array223     pub fn flat_map(
224         this: &Array,
225         callback: &mut dyn FnMut(JsValue, u32, Array) -> Vec<JsValue>,
226     ) -> Array;
227 
228     /// The `forEach()` method executes a provided function once for each array element.
229     ///
230     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach)
231     #[wasm_bindgen(method, js_name = forEach)]
for_each(this: &Array, callback: &mut dyn FnMut(JsValue, u32, Array))232     pub fn for_each(this: &Array, callback: &mut dyn FnMut(JsValue, u32, Array));
233 
234     /// The `includes()` method determines whether an array includes a certain
235     /// element, returning true or false as appropriate.
236     ///
237     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes)
238     #[wasm_bindgen(method)]
includes(this: &Array, value: &JsValue, from_index: i32) -> bool239     pub fn includes(this: &Array, value: &JsValue, from_index: i32) -> bool;
240 
241     /// The `indexOf()` method returns the first index at which a given element
242     /// can be found in the array, or -1 if it is not present.
243     ///
244     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf)
245     #[wasm_bindgen(method, js_name = indexOf)]
index_of(this: &Array, value: &JsValue, from_index: i32) -> i32246     pub fn index_of(this: &Array, value: &JsValue, from_index: i32) -> i32;
247 
248     /// The `Array.isArray()` method determines whether the passed value is an Array.
249     ///
250     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray)
251     #[wasm_bindgen(static_method_of = Array, js_name = isArray)]
is_array(value: &JsValue) -> bool252     pub fn is_array(value: &JsValue) -> bool;
253 
254     /// The `join()` method joins all elements of an array (or an array-like object)
255     /// into a string and returns this string.
256     ///
257     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join)
258     #[wasm_bindgen(method)]
join(this: &Array, delimiter: &str) -> JsString259     pub fn join(this: &Array, delimiter: &str) -> JsString;
260 
261     /// The `lastIndexOf()` method returns the last index at which a given element
262     /// can be found in the array, or -1 if it is not present. The array is
263     /// searched backwards, starting at fromIndex.
264     ///
265     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf)
266     #[wasm_bindgen(method, js_name = lastIndexOf)]
last_index_of(this: &Array, value: &JsValue, from_index: i32) -> i32267     pub fn last_index_of(this: &Array, value: &JsValue, from_index: i32) -> i32;
268 
269     /// The length property of an object which is an instance of type Array
270     /// sets or returns the number of elements in that array. The value is an
271     /// unsigned, 32-bit integer that is always numerically greater than the
272     /// highest index in the array.
273     ///
274     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/length)
275     #[wasm_bindgen(method, getter, structural)]
length(this: &Array) -> u32276     pub fn length(this: &Array) -> u32;
277 
278     /// `map()` calls a provided callback function once for each element in an array,
279     /// in order, and constructs a new array from the results. callback is invoked
280     /// only for indexes of the array which have assigned values, including undefined.
281     /// It is not called for missing elements of the array (that is, indexes that have
282     /// never been set, which have been deleted or which have never been assigned a value).
283     ///
284     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map)
285     #[wasm_bindgen(method)]
map(this: &Array, predicate: &mut dyn FnMut(JsValue, u32, Array) -> JsValue) -> Array286     pub fn map(this: &Array, predicate: &mut dyn FnMut(JsValue, u32, Array) -> JsValue) -> Array;
287 
288     /// The `Array.of()` method creates a new Array instance with a variable
289     /// number of arguments, regardless of number or type of the arguments.
290     ///
291     /// The difference between `Array.of()` and the `Array` constructor is in the
292     /// handling of integer arguments: `Array.of(7)` creates an array with a single
293     /// element, `7`, whereas `Array(7)` creates an empty array with a `length`
294     /// property of `7` (Note: this implies an array of 7 empty slots, not slots
295     /// with actual undefined values).
296     ///
297     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/of)
298     ///
299     /// # Notes
300     ///
301     /// There are a few bindings to `of` in `js-sys`: `of1`, `of2`, etc...
302     /// with different arities.
303     #[wasm_bindgen(static_method_of = Array, js_name = of)]
of1(a: &JsValue) -> Array304     pub fn of1(a: &JsValue) -> Array;
305 
306     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/of)
307     #[wasm_bindgen(static_method_of = Array, js_name = of)]
of2(a: &JsValue, b: &JsValue) -> Array308     pub fn of2(a: &JsValue, b: &JsValue) -> Array;
309 
310     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/of)
311     #[wasm_bindgen(static_method_of = Array, js_name = of)]
of3(a: &JsValue, b: &JsValue, c: &JsValue) -> Array312     pub fn of3(a: &JsValue, b: &JsValue, c: &JsValue) -> Array;
313 
314     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/of)
315     #[wasm_bindgen(static_method_of = Array, js_name = of)]
of4(a: &JsValue, b: &JsValue, c: &JsValue, d: &JsValue) -> Array316     pub fn of4(a: &JsValue, b: &JsValue, c: &JsValue, d: &JsValue) -> Array;
317 
318     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/of)
319     #[wasm_bindgen(static_method_of = Array, js_name = of)]
of5(a: &JsValue, b: &JsValue, c: &JsValue, d: &JsValue, e: &JsValue) -> Array320     pub fn of5(a: &JsValue, b: &JsValue, c: &JsValue, d: &JsValue, e: &JsValue) -> Array;
321 
322     /// The `pop()` method removes the last element from an array and returns that
323     /// element. This method changes the length of the array.
324     ///
325     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/pop)
326     #[wasm_bindgen(method)]
pop(this: &Array) -> JsValue327     pub fn pop(this: &Array) -> JsValue;
328 
329     /// The `push()` method adds one or more elements to the end of an array and
330     /// returns the new length of the array.
331     ///
332     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push)
333     #[wasm_bindgen(method)]
push(this: &Array, value: &JsValue) -> u32334     pub fn push(this: &Array, value: &JsValue) -> u32;
335 
336     /// The `reduce()` method applies a function against an accumulator and each element in
337     /// the array (from left to right) to reduce it to a single value.
338     ///
339     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce)
340     #[wasm_bindgen(method)]
reduce( this: &Array, predicate: &mut dyn FnMut(JsValue, JsValue, u32, Array) -> JsValue, initial_value: &JsValue, ) -> JsValue341     pub fn reduce(
342         this: &Array,
343         predicate: &mut dyn FnMut(JsValue, JsValue, u32, Array) -> JsValue,
344         initial_value: &JsValue,
345     ) -> JsValue;
346 
347     /// The `reduceRight()` method applies a function against an accumulator and each value
348     /// of the array (from right-to-left) to reduce it to a single value.
349     ///
350     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/ReduceRight)
351     #[wasm_bindgen(method, js_name = reduceRight)]
reduce_right( this: &Array, predicate: &mut dyn FnMut(JsValue, JsValue, u32, Array) -> JsValue, initial_value: &JsValue, ) -> JsValue352     pub fn reduce_right(
353         this: &Array,
354         predicate: &mut dyn FnMut(JsValue, JsValue, u32, Array) -> JsValue,
355         initial_value: &JsValue,
356     ) -> JsValue;
357 
358     /// The `reverse()` method reverses an array in place. The first array
359     /// element becomes the last, and the last array element becomes the first.
360     ///
361     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse)
362     #[wasm_bindgen(method)]
reverse(this: &Array) -> Array363     pub fn reverse(this: &Array) -> Array;
364 
365     /// The `shift()` method removes the first element from an array and returns
366     /// that removed element. This method changes the length of the array.
367     ///
368     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/shift)
369     #[wasm_bindgen(method)]
shift(this: &Array) -> JsValue370     pub fn shift(this: &Array) -> JsValue;
371 
372     /// The `slice()` method returns a shallow copy of a portion of an array into
373     /// a new array object selected from begin to end (end not included).
374     /// The original array will not be modified.
375     ///
376     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice)
377     #[wasm_bindgen(method)]
slice(this: &Array, start: u32, end: u32) -> Array378     pub fn slice(this: &Array, start: u32, end: u32) -> Array;
379 
380     /// The `some()` method tests whether at least one element in the array passes the test implemented
381     /// by the provided function.
382     /// Note: This method returns false for any condition put on an empty array.
383     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some)
384     #[wasm_bindgen(method)]
some(this: &Array, predicate: &mut dyn FnMut(JsValue) -> bool) -> bool385     pub fn some(this: &Array, predicate: &mut dyn FnMut(JsValue) -> bool) -> bool;
386 
387     /// The `sort()` method sorts the elements of an array in place and returns
388     /// the array. The sort is not necessarily stable. The default sort
389     /// order is according to string Unicode code points.
390     ///
391     /// The time and space complexity of the sort cannot be guaranteed as it
392     /// is implementation dependent.
393     ///
394     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort)
395     #[wasm_bindgen(method)]
sort(this: &Array) -> Array396     pub fn sort(this: &Array) -> Array;
397 
398     /// The `splice()` method changes the contents of an array by removing existing elements and/or
399     /// adding new elements.
400     ///
401     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice)
402     #[wasm_bindgen(method)]
splice(this: &Array, start: u32, delete_count: u32, item: &JsValue) -> Array403     pub fn splice(this: &Array, start: u32, delete_count: u32, item: &JsValue) -> Array;
404 
405     /// The `toLocaleString()` method returns a string representing the elements of the array.
406     /// The elements are converted to Strings using their toLocaleString methods and these
407     /// Strings are separated by a locale-specific String (such as a comma “,”).
408     ///
409     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toLocaleString)
410     #[wasm_bindgen(method, js_name = toLocaleString)]
to_locale_string(this: &Array, locales: &JsValue, options: &JsValue) -> JsString411     pub fn to_locale_string(this: &Array, locales: &JsValue, options: &JsValue) -> JsString;
412 
413     /// The `toString()` method returns a string representing the specified array
414     /// and its elements.
415     ///
416     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toString)
417     #[wasm_bindgen(method, js_name = toString)]
to_string(this: &Array) -> JsString418     pub fn to_string(this: &Array) -> JsString;
419 
420     /// The `unshift()` method adds one or more elements to the beginning of an
421     /// array and returns the new length of the array.
422     ///
423     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/unshift)
424     #[wasm_bindgen(method)]
unshift(this: &Array, value: &JsValue) -> u32425     pub fn unshift(this: &Array, value: &JsValue) -> u32;
426 }
427 
428 /// Iterator returned by `Array::iter`
429 #[derive(Debug, Clone)]
430 pub struct ArrayIter<'a> {
431     range: std::ops::Range<u32>,
432     array: &'a Array,
433 }
434 
435 impl<'a> std::iter::Iterator for ArrayIter<'a> {
436     type Item = JsValue;
437 
next(&mut self) -> Option<Self::Item>438     fn next(&mut self) -> Option<Self::Item> {
439         let index = self.range.next()?;
440         Some(self.array.get(index))
441     }
442 
443     #[inline]
size_hint(&self) -> (usize, Option<usize>)444     fn size_hint(&self) -> (usize, Option<usize>) {
445         self.range.size_hint()
446     }
447 }
448 
449 impl<'a> std::iter::DoubleEndedIterator for ArrayIter<'a> {
next_back(&mut self) -> Option<Self::Item>450     fn next_back(&mut self) -> Option<Self::Item> {
451         let index = self.range.next_back()?;
452         Some(self.array.get(index))
453     }
454 }
455 
456 impl<'a> std::iter::FusedIterator for ArrayIter<'a> {}
457 
458 impl<'a> std::iter::ExactSizeIterator for ArrayIter<'a> {}
459 
460 impl Array {
461     /// Returns an iterator over the values of the JS array.
iter(&self) -> ArrayIter<'_>462     pub fn iter(&self) -> ArrayIter<'_> {
463         ArrayIter {
464             range: 0..self.length(),
465             array: self,
466         }
467     }
468 
469     /// Converts the JS array into a new Vec.
to_vec(&self) -> Vec<JsValue>470     pub fn to_vec(&self) -> Vec<JsValue> {
471         let len = self.length();
472 
473         let mut output = Vec::with_capacity(len as usize);
474 
475         for i in 0..len {
476             output.push(self.get(i));
477         }
478 
479         output
480     }
481 }
482 
483 // TODO pre-initialize the Array with the correct length using TrustedLen
484 impl<A> std::iter::FromIterator<A> for Array
485 where
486     A: AsRef<JsValue>,
487 {
from_iter<T>(iter: T) -> Array where T: IntoIterator<Item = A>,488     fn from_iter<T>(iter: T) -> Array
489     where
490         T: IntoIterator<Item = A>,
491     {
492         let out = Array::new();
493 
494         for value in iter {
495             out.push(value.as_ref());
496         }
497 
498         out
499     }
500 }
501 
502 // ArrayBuffer
503 #[wasm_bindgen]
504 extern "C" {
505     #[wasm_bindgen(extends = Object)]
506     #[derive(Clone, Debug, PartialEq, Eq)]
507     pub type ArrayBuffer;
508 
509     /// The `ArrayBuffer` object is used to represent a generic,
510     /// fixed-length raw binary data buffer. You cannot directly
511     /// manipulate the contents of an `ArrayBuffer`; instead, you
512     /// create one of the typed array objects or a `DataView` object
513     /// which represents the buffer in a specific format, and use that
514     /// to read and write the contents of the buffer.
515     ///
516     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer)
517     #[wasm_bindgen(constructor)]
new(length: u32) -> ArrayBuffer518     pub fn new(length: u32) -> ArrayBuffer;
519 
520     /// The byteLength property of an object which is an instance of type ArrayBuffer
521     /// it's an accessor property whose set accessor function is undefined,
522     /// meaning that you can only read this property.
523     /// The value is established when the array is constructed and cannot be changed.
524     /// This property returns 0 if this ArrayBuffer has been detached.
525     ///
526     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/byteLength)
527     #[wasm_bindgen(method, getter, js_name = byteLength)]
byte_length(this: &ArrayBuffer) -> u32528     pub fn byte_length(this: &ArrayBuffer) -> u32;
529 
530     /// The `isView()` method returns true if arg is one of the `ArrayBuffer`
531     /// views, such as typed array objects or a DataView; false otherwise.
532     ///
533     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/isView)
534     #[wasm_bindgen(static_method_of = ArrayBuffer, js_name = isView)]
is_view(value: &JsValue) -> bool535     pub fn is_view(value: &JsValue) -> bool;
536 
537     /// The `slice()` method returns a new `ArrayBuffer` whose contents
538     /// are a copy of this `ArrayBuffer`'s bytes from begin, inclusive,
539     /// up to end, exclusive.
540     ///
541     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/slice)
542     #[wasm_bindgen(method)]
slice(this: &ArrayBuffer, begin: u32) -> ArrayBuffer543     pub fn slice(this: &ArrayBuffer, begin: u32) -> ArrayBuffer;
544 
545     /// Like `slice()` but with the `end` argument.
546     ///
547     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/slice)
548     #[wasm_bindgen(method, js_name = slice)]
slice_with_end(this: &ArrayBuffer, begin: u32, end: u32) -> ArrayBuffer549     pub fn slice_with_end(this: &ArrayBuffer, begin: u32, end: u32) -> ArrayBuffer;
550 }
551 
552 // SharedArrayBuffer
553 #[wasm_bindgen]
554 extern "C" {
555     #[wasm_bindgen(extends = Object)]
556     #[derive(Clone, Debug)]
557     pub type SharedArrayBuffer;
558 
559     /// The `SharedArrayBuffer` object is used to represent a generic,
560     /// fixed-length raw binary data buffer, similar to the `ArrayBuffer`
561     /// object, but in a way that they can be used to create views
562     /// on shared memory. Unlike an `ArrayBuffer`, a `SharedArrayBuffer`
563     /// cannot become detached.
564     ///
565     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer)
566     #[wasm_bindgen(constructor)]
new(length: u32) -> SharedArrayBuffer567     pub fn new(length: u32) -> SharedArrayBuffer;
568 
569     /// The byteLength accessor property represents the length of
570     /// an `SharedArrayBuffer` in bytes. This is established when
571     /// the `SharedArrayBuffer` is constructed and cannot be changed.
572     ///
573     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/byteLength)
574     #[wasm_bindgen(method, getter, js_name = byteLength)]
byte_length(this: &SharedArrayBuffer) -> u32575     pub fn byte_length(this: &SharedArrayBuffer) -> u32;
576 
577     /// The `slice()` method returns a new `SharedArrayBuffer` whose contents
578     /// are a copy of this `SharedArrayBuffer`'s bytes from begin, inclusive,
579     /// up to end, exclusive.
580     ///
581     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/slice)
582     #[wasm_bindgen(method)]
slice(this: &SharedArrayBuffer, begin: u32) -> SharedArrayBuffer583     pub fn slice(this: &SharedArrayBuffer, begin: u32) -> SharedArrayBuffer;
584 
585     /// Like `slice()` but with the `end` argument.
586     ///
587     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/slice)
588     #[wasm_bindgen(method, js_name = slice)]
slice_with_end(this: &SharedArrayBuffer, begin: u32, end: u32) -> SharedArrayBuffer589     pub fn slice_with_end(this: &SharedArrayBuffer, begin: u32, end: u32) -> SharedArrayBuffer;
590 }
591 
592 // Array Iterator
593 #[wasm_bindgen]
594 extern "C" {
595     /// The `keys()` method returns a new Array Iterator object that contains the
596     /// keys for each index in the array.
597     ///
598     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/keys)
599     #[wasm_bindgen(method)]
keys(this: &Array) -> Iterator600     pub fn keys(this: &Array) -> Iterator;
601 
602     /// The `entries()` method returns a new Array Iterator object that contains
603     /// the key/value pairs for each index in the array.
604     ///
605     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/entries)
606     #[wasm_bindgen(method)]
entries(this: &Array) -> Iterator607     pub fn entries(this: &Array) -> Iterator;
608 
609     /// The `values()` method returns a new Array Iterator object that
610     /// contains the values for each index in the array.
611     ///
612     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/values)
613     #[wasm_bindgen(method)]
values(this: &Array) -> Iterator614     pub fn values(this: &Array) -> Iterator;
615 }
616 
617 /// The `Atomics` object provides atomic operations as static methods.
618 /// They are used with `SharedArrayBuffer` objects.
619 ///
620 /// The Atomic operations are installed on an `Atomics` module. Unlike
621 /// the other global objects, `Atomics` is not a constructor. You cannot
622 /// use it with a new operator or invoke the `Atomics` object as a
623 /// function. All properties and methods of `Atomics` are static
624 /// (as is the case with the Math object, for example).
625 /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics)
626 #[allow(non_snake_case)]
627 pub mod Atomics {
628     use super::*;
629 
630     #[wasm_bindgen]
631     extern "C" {
632         /// The static `Atomics.add()` method adds a given value at a given
633         /// position in the array and returns the old value at that position.
634         /// This atomic operation guarantees that no other write happens
635         /// until the modified value is written back.
636         ///
637         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/add)
638         #[wasm_bindgen(js_namespace = Atomics, catch)]
add(typed_array: &JsValue, index: u32, value: i32) -> Result<i32, JsValue>639         pub fn add(typed_array: &JsValue, index: u32, value: i32) -> Result<i32, JsValue>;
640 
641         /// The static `Atomics.and()` method computes a bitwise AND with a given
642         /// value at a given position in the array, and returns the old value
643         /// at that position.
644         /// This atomic operation guarantees that no other write happens
645         /// until the modified value is written back.
646         ///
647         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/and)
648         #[wasm_bindgen(js_namespace = Atomics, catch)]
and(typed_array: &JsValue, index: u32, value: i32) -> Result<i32, JsValue>649         pub fn and(typed_array: &JsValue, index: u32, value: i32) -> Result<i32, JsValue>;
650 
651         /// The static `Atomics.compareExchange()` method exchanges a given
652         /// replacement value at a given position in the array, if a given expected
653         /// value equals the old value. It returns the old value at that position
654         /// whether it was equal to the expected value or not.
655         /// This atomic operation guarantees that no other write happens
656         /// until the modified value is written back.
657         ///
658         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/compareExchange)
659         #[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>660         pub fn compare_exchange(
661             typed_array: &JsValue,
662             index: u32,
663             expected_value: i32,
664             replacement_value: i32,
665         ) -> Result<i32, JsValue>;
666 
667         /// The static `Atomics.exchange()` method stores a given value at a given
668         /// position in the array and returns the old value at that position.
669         /// This atomic operation guarantees that no other write happens
670         /// until the modified value is written back.
671         ///
672         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/exchange)
673         #[wasm_bindgen(js_namespace = Atomics, catch)]
exchange(typed_array: &JsValue, index: u32, value: i32) -> Result<i32, JsValue>674         pub fn exchange(typed_array: &JsValue, index: u32, value: i32) -> Result<i32, JsValue>;
675 
676         /// The static `Atomics.isLockFree()` method is used to determine
677         /// whether to use locks or atomic operations. It returns true,
678         /// if the given size is one of the `BYTES_PER_ELEMENT` property
679         /// of integer `TypedArray` types.
680         ///
681         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/isLockFree)
682         #[wasm_bindgen(js_namespace = Atomics, js_name = isLockFree)]
is_lock_free(size: u32) -> bool683         pub fn is_lock_free(size: u32) -> bool;
684 
685         /// The static `Atomics.load()` method returns a value at a given
686         /// position in the array.
687         ///
688         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/load)
689         #[wasm_bindgen(js_namespace = Atomics, catch)]
load(typed_array: &JsValue, index: u32) -> Result<i32, JsValue>690         pub fn load(typed_array: &JsValue, index: u32) -> Result<i32, JsValue>;
691 
692         /// The static `Atomics.notify()` method notifies up some agents that
693         /// are sleeping in the wait queue.
694         /// Note: This operation works with a shared `Int32Array` only.
695         /// If `count` is not provided, notifies all the agents in the queue.
696         ///
697         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/notify)
698         #[wasm_bindgen(js_namespace = Atomics, catch)]
notify(typed_array: &Int32Array, index: u32) -> Result<u32, JsValue>699         pub fn notify(typed_array: &Int32Array, index: u32) -> Result<u32, JsValue>;
700 
701         /// Notifies up to `count` agents in the wait queue.
702         #[wasm_bindgen(js_namespace = Atomics, catch, js_name = notify)]
notify_with_count( typed_array: &Int32Array, index: u32, count: u32, ) -> Result<u32, JsValue>703         pub fn notify_with_count(
704             typed_array: &Int32Array,
705             index: u32,
706             count: u32,
707         ) -> Result<u32, JsValue>;
708 
709         /// The static `Atomics.or()` method computes a bitwise OR with a given value
710         /// at a given position in the array, and returns the old value at that position.
711         /// This atomic operation guarantees that no other write happens
712         /// until the modified value is written back.
713         ///
714         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/or)
715         #[wasm_bindgen(js_namespace = Atomics, catch)]
or(typed_array: &JsValue, index: u32, value: i32) -> Result<i32, JsValue>716         pub fn or(typed_array: &JsValue, index: u32, value: i32) -> Result<i32, JsValue>;
717 
718         /// The static `Atomics.store()` method stores a given value at the given
719         /// position in the array and returns that value.
720         ///
721         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/store)
722         #[wasm_bindgen(js_namespace = Atomics, catch)]
store(typed_array: &JsValue, index: u32, value: i32) -> Result<i32, JsValue>723         pub fn store(typed_array: &JsValue, index: u32, value: i32) -> Result<i32, JsValue>;
724 
725         /// The static `Atomics.sub()` method substracts a given value at a
726         /// given position in the array and returns the old value at that position.
727         /// This atomic operation guarantees that no other write happens
728         /// until the modified value is written back.
729         ///
730         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/sub)
731         #[wasm_bindgen(js_namespace = Atomics, catch)]
sub(typed_array: &JsValue, index: u32, value: i32) -> Result<i32, JsValue>732         pub fn sub(typed_array: &JsValue, index: u32, value: i32) -> Result<i32, JsValue>;
733 
734         /// The static `Atomics.wait()` method verifies that a given
735         /// position in an `Int32Array` still contains a given value
736         /// and if so sleeps, awaiting a wakeup or a timeout.
737         /// It returns a string which is either "ok", "not-equal", or "timed-out".
738         /// Note: This operation only works with a shared `Int32Array`
739         /// and may not be allowed on the main thread.
740         ///
741         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/wait)
742         #[wasm_bindgen(js_namespace = Atomics, catch)]
wait(typed_array: &Int32Array, index: u32, value: i32) -> Result<JsString, JsValue>743         pub fn wait(typed_array: &Int32Array, index: u32, value: i32) -> Result<JsString, JsValue>;
744 
745         /// Like `wait()`, but with timeout
746         ///
747         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/wait)
748         #[wasm_bindgen(js_namespace = Atomics, catch, js_name = wait)]
wait_with_timeout( typed_array: &Int32Array, index: u32, value: i32, timeout: f64, ) -> Result<JsString, JsValue>749         pub fn wait_with_timeout(
750             typed_array: &Int32Array,
751             index: u32,
752             value: i32,
753             timeout: f64,
754         ) -> Result<JsString, JsValue>;
755 
756         /// The static `Atomics.xor()` method computes a bitwise XOR
757         /// with a given value at a given position in the array,
758         /// and returns the old value at that position.
759         /// This atomic operation guarantees that no other write happens
760         /// until the modified value is written back.
761         ///
762         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/xor)
763         #[wasm_bindgen(js_namespace = Atomics, catch)]
xor(typed_array: &JsValue, index: u32, value: i32) -> Result<i32, JsValue>764         pub fn xor(typed_array: &JsValue, index: u32, value: i32) -> Result<i32, JsValue>;
765     }
766 }
767 
768 // Boolean
769 #[wasm_bindgen]
770 extern "C" {
771     #[wasm_bindgen(extends = Object, is_type_of = |v| v.as_bool().is_some())]
772     #[derive(Clone, PartialEq, Eq)]
773     pub type Boolean;
774 
775     /// The `Boolean()` constructor creates an object wrapper for a boolean value.
776     ///
777     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)
778     #[wasm_bindgen(constructor)]
779     #[deprecated(note = "recommended to use `Boolean::from` instead")]
new(value: &JsValue) -> Boolean780     pub fn new(value: &JsValue) -> Boolean;
781 
782     /// The `valueOf()` method returns the primitive value of a `Boolean` object.
783     ///
784     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean/valueOf)
785     #[wasm_bindgen(method, js_name = valueOf)]
value_of(this: &Boolean) -> bool786     pub fn value_of(this: &Boolean) -> bool;
787 }
788 
789 impl From<bool> for Boolean {
790     #[inline]
from(b: bool) -> Boolean791     fn from(b: bool) -> Boolean {
792         Boolean::unchecked_from_js(JsValue::from(b))
793     }
794 }
795 
796 impl From<Boolean> for bool {
797     #[inline]
from(b: Boolean) -> bool798     fn from(b: Boolean) -> bool {
799         b.value_of()
800     }
801 }
802 
803 impl PartialEq<bool> for Boolean {
804     #[inline]
eq(&self, other: &bool) -> bool805     fn eq(&self, other: &bool) -> bool {
806         self.value_of() == *other
807     }
808 }
809 
810 impl fmt::Debug for Boolean {
fmt(&self, f: &mut fmt::Formatter) -> fmt::Result811     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
812         self.value_of().fmt(f)
813     }
814 }
815 
816 // DataView
817 #[wasm_bindgen]
818 extern "C" {
819     #[wasm_bindgen(extends = Object)]
820     #[derive(Clone, Debug, PartialEq, Eq)]
821     pub type DataView;
822 
823     /// The `DataView` view provides a low-level interface for reading and
824     /// writing multiple number types in an `ArrayBuffer` irrespective of the
825     /// platform's endianness.
826     ///
827     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView)
828     #[wasm_bindgen(constructor)]
new(buffer: &ArrayBuffer, byteOffset: usize, byteLength: usize) -> DataView829     pub fn new(buffer: &ArrayBuffer, byteOffset: usize, byteLength: usize) -> DataView;
830 
831     /// The ArrayBuffer referenced by this view. Fixed at construction time and thus read only.
832     ///
833     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/buffer)
834     #[wasm_bindgen(method, getter, structural)]
buffer(this: &DataView) -> ArrayBuffer835     pub fn buffer(this: &DataView) -> ArrayBuffer;
836 
837     /// The length (in bytes) of this view from the start of its ArrayBuffer.
838     /// Fixed at construction time and thus read only.
839     ///
840     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/byteLength)
841     #[wasm_bindgen(method, getter, structural, js_name = byteLength)]
byte_length(this: &DataView) -> usize842     pub fn byte_length(this: &DataView) -> usize;
843 
844     /// The offset (in bytes) of this view from the start of its ArrayBuffer.
845     /// Fixed at construction time and thus read only.
846     ///
847     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/byteOffset)
848     #[wasm_bindgen(method, getter, structural, js_name = byteOffset)]
byte_offset(this: &DataView) -> usize849     pub fn byte_offset(this: &DataView) -> usize;
850 
851     /// The `getInt8()` method gets a signed 8-bit integer (byte) at the
852     /// specified byte offset from the start of the DataView.
853     ///
854     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getInt8)
855     #[wasm_bindgen(method, js_name = getInt8)]
get_int8(this: &DataView, byte_offset: usize) -> i8856     pub fn get_int8(this: &DataView, byte_offset: usize) -> i8;
857 
858     /// The `getUint8()` method gets a unsigned 8-bit integer (byte) at the specified
859     /// byte offset from the start of the DataView.
860     ///
861     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getUint8)
862     #[wasm_bindgen(method, js_name = getUint8)]
get_uint8(this: &DataView, byte_offset: usize) -> u8863     pub fn get_uint8(this: &DataView, byte_offset: usize) -> u8;
864 
865     /// The `getInt16()` method gets a signed 16-bit integer (short) at the specified
866     /// byte offset from the start of the DataView.
867     ///
868     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getInt16)
869     #[wasm_bindgen(method, js_name = getInt16)]
get_int16(this: &DataView, byte_offset: usize) -> i16870     pub fn get_int16(this: &DataView, byte_offset: usize) -> i16;
871 
872     /// The `getInt16()` method gets a signed 16-bit integer (short) at the specified
873     /// byte offset from the start of the DataView.
874     ///
875     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getInt16)
876     #[wasm_bindgen(method, js_name = getInt16)]
get_int16_endian(this: &DataView, byte_offset: usize, little_endian: bool) -> i16877     pub fn get_int16_endian(this: &DataView, byte_offset: usize, little_endian: bool) -> i16;
878 
879     /// The `getUint16()` method gets an unsigned 16-bit integer (unsigned short) at the specified
880     /// byte offset from the start of the view.
881     ///
882     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getUint16)
883     #[wasm_bindgen(method, js_name = getUint16)]
get_uint16(this: &DataView, byte_offset: usize) -> u16884     pub fn get_uint16(this: &DataView, byte_offset: usize) -> u16;
885 
886     /// The `getUint16()` method gets an unsigned 16-bit integer (unsigned short) at the specified
887     /// byte offset from the start of the view.
888     ///
889     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getUint16)
890     #[wasm_bindgen(method, js_name = getUint16)]
get_uint16_endian(this: &DataView, byte_offset: usize, little_endian: bool) -> u16891     pub fn get_uint16_endian(this: &DataView, byte_offset: usize, little_endian: bool) -> u16;
892 
893     /// The `getInt32()` method gets a signed 32-bit integer (long) at the specified
894     /// byte offset from the start of the DataView.
895     ///
896     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getInt32)
897     #[wasm_bindgen(method, js_name = getInt32)]
get_int32(this: &DataView, byte_offset: usize) -> i32898     pub fn get_int32(this: &DataView, byte_offset: usize) -> i32;
899 
900     /// The `getInt32()` method gets a signed 32-bit integer (long) at the specified
901     /// byte offset from the start of the DataView.
902     ///
903     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getInt32)
904     #[wasm_bindgen(method, js_name = getInt32)]
get_int32_endian(this: &DataView, byte_offset: usize, little_endian: bool) -> i32905     pub fn get_int32_endian(this: &DataView, byte_offset: usize, little_endian: bool) -> i32;
906 
907     /// The `getUint32()` method gets an unsigned 32-bit integer (unsigned long) at the specified
908     /// byte offset from the start of the view.
909     ///
910     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getUint32)
911     #[wasm_bindgen(method, js_name = getUint32)]
get_uint32(this: &DataView, byte_offset: usize) -> u32912     pub fn get_uint32(this: &DataView, byte_offset: usize) -> u32;
913 
914     /// The `getUint32()` method gets an unsigned 32-bit integer (unsigned long) at the specified
915     /// byte offset from the start of the view.
916     ///
917     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getUint32)
918     #[wasm_bindgen(method, js_name = getUint32)]
get_uint32_endian(this: &DataView, byte_offset: usize, little_endian: bool) -> u32919     pub fn get_uint32_endian(this: &DataView, byte_offset: usize, little_endian: bool) -> u32;
920 
921     /// The `getFloat32()` method gets a signed 32-bit float (float) at the specified
922     /// byte offset from the start of the DataView.
923     ///
924     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getFloat32)
925     #[wasm_bindgen(method, js_name = getFloat32)]
get_float32(this: &DataView, byte_offset: usize) -> f32926     pub fn get_float32(this: &DataView, byte_offset: usize) -> f32;
927 
928     /// The `getFloat32()` method gets a signed 32-bit float (float) at the specified
929     /// byte offset from the start of the DataView.
930     ///
931     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getFloat32)
932     #[wasm_bindgen(method, js_name = getFloat32)]
get_float32_endian(this: &DataView, byte_offset: usize, little_endian: bool) -> f32933     pub fn get_float32_endian(this: &DataView, byte_offset: usize, little_endian: bool) -> f32;
934 
935     /// The `getFloat64()` method gets a signed 64-bit float (double) at the specified
936     /// byte offset from the start of the DataView.
937     ///
938     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getFloat64)
939     #[wasm_bindgen(method, js_name = getFloat64)]
get_float64(this: &DataView, byte_offset: usize) -> f64940     pub fn get_float64(this: &DataView, byte_offset: usize) -> f64;
941 
942     /// The `getFloat64()` method gets a signed 64-bit float (double) at the specified
943     /// byte offset from the start of the DataView.
944     ///
945     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getFloat64)
946     #[wasm_bindgen(method, js_name = getFloat64)]
get_float64_endian(this: &DataView, byte_offset: usize, little_endian: bool) -> f64947     pub fn get_float64_endian(this: &DataView, byte_offset: usize, little_endian: bool) -> f64;
948 
949     /// The `setInt8()` method stores a signed 8-bit integer (byte) value at the
950     /// specified byte offset from the start of the DataView.
951     ///
952     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setInt8)
953     #[wasm_bindgen(method, js_name = setInt8)]
set_int8(this: &DataView, byte_offset: usize, value: i8)954     pub fn set_int8(this: &DataView, byte_offset: usize, value: i8);
955 
956     /// The `setUint8()` method stores an unsigned 8-bit integer (byte) value at the
957     /// specified byte offset from the start of the DataView.
958     ///
959     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setUint8)
960     #[wasm_bindgen(method, js_name = setUint8)]
set_uint8(this: &DataView, byte_offset: usize, value: u8)961     pub fn set_uint8(this: &DataView, byte_offset: usize, value: u8);
962 
963     /// The `setInt16()` method stores a signed 16-bit integer (short) value at the
964     /// specified byte offset from the start of the DataView.
965     ///
966     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setInt16)
967     #[wasm_bindgen(method, js_name = setInt16)]
set_int16(this: &DataView, byte_offset: usize, value: i16)968     pub fn set_int16(this: &DataView, byte_offset: usize, value: i16);
969 
970     /// The `setInt16()` method stores a signed 16-bit integer (short) value at the
971     /// specified byte offset from the start of the DataView.
972     ///
973     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setInt16)
974     #[wasm_bindgen(method, js_name = setInt16)]
set_int16_endian(this: &DataView, byte_offset: usize, value: i16, little_endian: bool)975     pub fn set_int16_endian(this: &DataView, byte_offset: usize, value: i16, little_endian: bool);
976 
977     /// The `setUint16()` method stores an unsigned 16-bit integer (unsigned short) value at the
978     /// specified byte offset from the start of the DataView.
979     ///
980     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setUint16)
981     #[wasm_bindgen(method, js_name = setUint16)]
set_uint16(this: &DataView, byte_offset: usize, value: u16)982     pub fn set_uint16(this: &DataView, byte_offset: usize, value: u16);
983 
984     /// The `setUint16()` method stores an unsigned 16-bit integer (unsigned short) value at the
985     /// specified byte offset from the start of the DataView.
986     ///
987     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setUint16)
988     #[wasm_bindgen(method, js_name = setUint16)]
set_uint16_endian(this: &DataView, byte_offset: usize, value: u16, little_endian: bool)989     pub fn set_uint16_endian(this: &DataView, byte_offset: usize, value: u16, little_endian: bool);
990 
991     /// The `setInt32()` method stores a signed 32-bit integer (long) value at the
992     /// specified byte offset from the start of the DataView.
993     ///
994     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setInt32)
995     #[wasm_bindgen(method, js_name = setInt32)]
set_int32(this: &DataView, byte_offset: usize, value: i32)996     pub fn set_int32(this: &DataView, byte_offset: usize, value: i32);
997 
998     /// The `setInt32()` method stores a signed 32-bit integer (long) value at the
999     /// specified byte offset from the start of the DataView.
1000     ///
1001     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setInt32)
1002     #[wasm_bindgen(method, js_name = setInt32)]
set_int32_endian(this: &DataView, byte_offset: usize, value: i32, little_endian: bool)1003     pub fn set_int32_endian(this: &DataView, byte_offset: usize, value: i32, little_endian: bool);
1004 
1005     /// The `setUint32()` method stores an unsigned 32-bit integer (unsigned long) value at the
1006     /// specified byte offset from the start of the DataView.
1007     ///
1008     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setUint32)
1009     #[wasm_bindgen(method, js_name = setUint32)]
set_uint32(this: &DataView, byte_offset: usize, value: u32)1010     pub fn set_uint32(this: &DataView, byte_offset: usize, value: u32);
1011 
1012     /// The `setUint32()` method stores an unsigned 32-bit integer (unsigned long) value at the
1013     /// specified byte offset from the start of the DataView.
1014     ///
1015     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setUint32)
1016     #[wasm_bindgen(method, js_name = setUint32)]
set_uint32_endian(this: &DataView, byte_offset: usize, value: u32, little_endian: bool)1017     pub fn set_uint32_endian(this: &DataView, byte_offset: usize, value: u32, little_endian: bool);
1018 
1019     /// The `setFloat32()` method stores a signed 32-bit float (float) value at the
1020     /// specified byte offset from the start of the DataView.
1021     ///
1022     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setFloat32)
1023     #[wasm_bindgen(method, js_name = setFloat32)]
set_float32(this: &DataView, byte_offset: usize, value: f32)1024     pub fn set_float32(this: &DataView, byte_offset: usize, value: f32);
1025 
1026     /// The `setFloat32()` method stores a signed 32-bit float (float) value at the
1027     /// specified byte offset from the start of the DataView.
1028     ///
1029     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setFloat32)
1030     #[wasm_bindgen(method, js_name = setFloat32)]
set_float32_endian(this: &DataView, byte_offset: usize, value: f32, little_endian: bool)1031     pub fn set_float32_endian(this: &DataView, byte_offset: usize, value: f32, little_endian: bool);
1032 
1033     /// The `setFloat64()` method stores a signed 64-bit float (double) value at the
1034     /// specified byte offset from the start of the DataView.
1035     ///
1036     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setFloat64)
1037     #[wasm_bindgen(method, js_name = setFloat64)]
set_float64(this: &DataView, byte_offset: usize, value: f64)1038     pub fn set_float64(this: &DataView, byte_offset: usize, value: f64);
1039 
1040     /// The `setFloat64()` method stores a signed 64-bit float (double) value at the
1041     /// specified byte offset from the start of the DataView.
1042     ///
1043     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setFloat64)
1044     #[wasm_bindgen(method, js_name = setFloat64)]
set_float64_endian(this: &DataView, byte_offset: usize, value: f64, little_endian: bool)1045     pub fn set_float64_endian(this: &DataView, byte_offset: usize, value: f64, little_endian: bool);
1046 }
1047 
1048 // Error
1049 #[wasm_bindgen]
1050 extern "C" {
1051     #[wasm_bindgen(extends = Object)]
1052     #[derive(Clone, Debug, PartialEq, Eq)]
1053     pub type Error;
1054 
1055     /// The Error constructor creates an error object.
1056     /// Instances of Error objects are thrown when runtime errors occur.
1057     /// The Error object can also be used as a base object for user-defined exceptions.
1058     /// See below for standard built-in error types.
1059     ///
1060     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error)
1061     #[wasm_bindgen(constructor)]
new(message: &str) -> Error1062     pub fn new(message: &str) -> Error;
1063 
1064     /// The message property is a human-readable description of the error.
1065     ///
1066     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/message)
1067     #[wasm_bindgen(method, getter, structural)]
message(this: &Error) -> JsString1068     pub fn message(this: &Error) -> JsString;
1069     #[wasm_bindgen(method, setter, structural)]
set_message(this: &Error, message: &str)1070     pub fn set_message(this: &Error, message: &str);
1071 
1072     /// The name property represents a name for the type of error. The initial value is "Error".
1073     ///
1074     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/name)
1075     #[wasm_bindgen(method, getter, structural)]
name(this: &Error) -> JsString1076     pub fn name(this: &Error) -> JsString;
1077     #[wasm_bindgen(method, setter, structural)]
set_name(this: &Error, name: &str)1078     pub fn set_name(this: &Error, name: &str);
1079 
1080     /// The `toString()` method returns a string representing the specified Error object
1081     ///
1082     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/toString)
1083     #[wasm_bindgen(method, js_name = toString)]
to_string(this: &Error) -> JsString1084     pub fn to_string(this: &Error) -> JsString;
1085 }
1086 
1087 // EvalError
1088 #[wasm_bindgen]
1089 extern "C" {
1090     #[wasm_bindgen(extends = Object, extends = Error)]
1091     #[derive(Clone, Debug, PartialEq, Eq)]
1092     pub type EvalError;
1093 
1094     /// The EvalError object indicates an error regarding the global eval() function. This
1095     /// exception is not thrown by JavaScript anymore, however the EvalError object remains for
1096     /// compatibility.
1097     ///
1098     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError)
1099     #[wasm_bindgen(constructor)]
new(message: &str) -> EvalError1100     pub fn new(message: &str) -> EvalError;
1101 }
1102 
1103 // Function
1104 #[wasm_bindgen]
1105 extern "C" {
1106     #[wasm_bindgen(extends = Object, is_type_of = JsValue::is_function)]
1107     #[derive(Clone, Debug, PartialEq, Eq)]
1108     pub type Function;
1109 
1110     /// The `Function` constructor creates a new `Function` object. Calling the
1111     /// constructor directly can create functions dynamically, but suffers from
1112     /// security and similar (but far less significant) performance issues
1113     /// similar to `eval`. However, unlike `eval`, the `Function` constructor
1114     /// allows executing code in the global scope, prompting better programming
1115     /// habits and allowing for more efficient code minification.
1116     ///
1117     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function)
1118     #[wasm_bindgen(constructor)]
new_with_args(args: &str, body: &str) -> Function1119     pub fn new_with_args(args: &str, body: &str) -> Function;
1120 
1121     /// The `Function` constructor creates a new `Function` object. Calling the
1122     /// constructor directly can create functions dynamically, but suffers from
1123     /// security and similar (but far less significant) performance issues
1124     /// similar to `eval`. However, unlike `eval`, the `Function` constructor
1125     /// allows executing code in the global scope, prompting better programming
1126     /// habits and allowing for more efficient code minification.
1127     ///
1128     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function)
1129     #[wasm_bindgen(constructor)]
new_no_args(body: &str) -> Function1130     pub fn new_no_args(body: &str) -> Function;
1131 
1132     /// The `apply()` method calls a function with a given this value, and arguments provided as an array
1133     /// (or an array-like object).
1134     ///
1135     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/apply)
1136     #[wasm_bindgen(method, catch)]
apply(this: &Function, context: &JsValue, args: &Array) -> Result<JsValue, JsValue>1137     pub fn apply(this: &Function, context: &JsValue, args: &Array) -> Result<JsValue, JsValue>;
1138 
1139     /// The `call()` method calls a function with a given this value and
1140     /// arguments provided individually.
1141     ///
1142     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
1143     #[wasm_bindgen(method, catch, js_name = call)]
call0(this: &Function, context: &JsValue) -> Result<JsValue, JsValue>1144     pub fn call0(this: &Function, context: &JsValue) -> Result<JsValue, JsValue>;
1145 
1146     /// The `call()` method calls a function with a given this value and
1147     /// arguments provided individually.
1148     ///
1149     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
1150     #[wasm_bindgen(method, catch, js_name = call)]
call1(this: &Function, context: &JsValue, arg1: &JsValue) -> Result<JsValue, JsValue>1151     pub fn call1(this: &Function, context: &JsValue, arg1: &JsValue) -> Result<JsValue, JsValue>;
1152 
1153     /// The `call()` method calls a function with a given this value and
1154     /// arguments provided individually.
1155     ///
1156     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
1157     #[wasm_bindgen(method, catch, js_name = call)]
call2( this: &Function, context: &JsValue, arg1: &JsValue, arg2: &JsValue, ) -> Result<JsValue, JsValue>1158     pub fn call2(
1159         this: &Function,
1160         context: &JsValue,
1161         arg1: &JsValue,
1162         arg2: &JsValue,
1163     ) -> Result<JsValue, JsValue>;
1164 
1165     /// The `call()` method calls a function with a given this value and
1166     /// arguments provided individually.
1167     ///
1168     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
1169     #[wasm_bindgen(method, catch, js_name = call)]
call3( this: &Function, context: &JsValue, arg1: &JsValue, arg2: &JsValue, arg3: &JsValue, ) -> Result<JsValue, JsValue>1170     pub fn call3(
1171         this: &Function,
1172         context: &JsValue,
1173         arg1: &JsValue,
1174         arg2: &JsValue,
1175         arg3: &JsValue,
1176     ) -> Result<JsValue, JsValue>;
1177 
1178     /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
1179     /// with a given sequence of arguments preceding any provided when the new function is called.
1180     ///
1181     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
1182     #[wasm_bindgen(method, js_name = bind)]
bind(this: &Function, context: &JsValue) -> Function1183     pub fn bind(this: &Function, context: &JsValue) -> Function;
1184 
1185     /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
1186     /// with a given sequence of arguments preceding any provided when the new function is called.
1187     ///
1188     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
1189     #[wasm_bindgen(method, js_name = bind)]
bind0(this: &Function, context: &JsValue) -> Function1190     pub fn bind0(this: &Function, context: &JsValue) -> Function;
1191 
1192     /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
1193     /// with a given sequence of arguments preceding any provided when the new function is called.
1194     ///
1195     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
1196     #[wasm_bindgen(method, js_name = bind)]
bind1(this: &Function, context: &JsValue, arg1: &JsValue) -> Function1197     pub fn bind1(this: &Function, context: &JsValue, arg1: &JsValue) -> Function;
1198 
1199     /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
1200     /// with a given sequence of arguments preceding any provided when the new function is called.
1201     ///
1202     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
1203     #[wasm_bindgen(method, js_name = bind)]
bind2(this: &Function, context: &JsValue, arg1: &JsValue, arg2: &JsValue) -> Function1204     pub fn bind2(this: &Function, context: &JsValue, arg1: &JsValue, arg2: &JsValue) -> Function;
1205 
1206     /// The `bind()` method creates a new function that, when called, has its this keyword set to the provided value,
1207     /// with a given sequence of arguments preceding any provided when the new function is called.
1208     ///
1209     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
1210     #[wasm_bindgen(method, js_name = bind)]
bind3( this: &Function, context: &JsValue, arg1: &JsValue, arg2: &JsValue, arg3: &JsValue, ) -> Function1211     pub fn bind3(
1212         this: &Function,
1213         context: &JsValue,
1214         arg1: &JsValue,
1215         arg2: &JsValue,
1216         arg3: &JsValue,
1217     ) -> Function;
1218 
1219     /// The length property indicates the number of arguments expected by the function.
1220     ///
1221     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/length)
1222     #[wasm_bindgen(method, getter, structural)]
length(this: &Function) -> u321223     pub fn length(this: &Function) -> u32;
1224 
1225     /// A Function object's read-only name property indicates the function's
1226     /// name as specified when it was created or "anonymous" for functions
1227     /// created anonymously.
1228     ///
1229     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name)
1230     #[wasm_bindgen(method, getter, structural)]
name(this: &Function) -> JsString1231     pub fn name(this: &Function) -> JsString;
1232 
1233     /// The `toString()` method returns a string representing the source code of the function.
1234     ///
1235     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/toString)
1236     #[wasm_bindgen(method, js_name = toString)]
to_string(this: &Function) -> JsString1237     pub fn to_string(this: &Function) -> JsString;
1238 }
1239 
1240 impl Function {
1241     /// Returns the `Function` value of this JS value if it's an instance of a
1242     /// function.
1243     ///
1244     /// If this JS value is not an instance of a function then this returns
1245     /// `None`.
1246     #[deprecated(note = "recommended to use dyn_ref instead which is now equivalent")]
try_from(val: &JsValue) -> Option<&Function>1247     pub fn try_from(val: &JsValue) -> Option<&Function> {
1248         val.dyn_ref()
1249     }
1250 }
1251 
1252 // Generator
1253 #[wasm_bindgen]
1254 extern "C" {
1255     #[wasm_bindgen(extends = Object)]
1256     #[derive(Clone, Debug, PartialEq, Eq)]
1257     pub type Generator;
1258 
1259     /// The `next()` method returns an object with two properties done and value.
1260     /// You can also provide a parameter to the next method to send a value to the generator.
1261     ///
1262     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/next)
1263     #[wasm_bindgen(method, structural, catch)]
next(this: &Generator, value: &JsValue) -> Result<JsValue, JsValue>1264     pub fn next(this: &Generator, value: &JsValue) -> Result<JsValue, JsValue>;
1265 
1266     /// The `return()` method returns the given value and finishes the generator.
1267     ///
1268     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/return)
1269     #[wasm_bindgen(method, structural, js_name = return)]
return_(this: &Generator, value: &JsValue) -> JsValue1270     pub fn return_(this: &Generator, value: &JsValue) -> JsValue;
1271 
1272     /// The `throw()` method resumes the execution of a generator by throwing an error into it
1273     /// and returns an object with two properties done and value.
1274     ///
1275     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/throw)
1276     #[wasm_bindgen(method, structural, catch)]
throw(this: &Generator, error: &Error) -> Result<JsValue, JsValue>1277     pub fn throw(this: &Generator, error: &Error) -> Result<JsValue, JsValue>;
1278 }
1279 
1280 // Map
1281 #[wasm_bindgen]
1282 extern "C" {
1283     #[wasm_bindgen(extends = Object)]
1284     #[derive(Clone, Debug, PartialEq, Eq)]
1285     pub type Map;
1286 
1287     /// The `clear()` method removes all elements from a Map object.
1288     ///
1289     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/clear)
1290     #[wasm_bindgen(method)]
clear(this: &Map)1291     pub fn clear(this: &Map);
1292 
1293     /// The `delete()` method removes the specified element from a Map object.
1294     ///
1295     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/delete)
1296     #[wasm_bindgen(method)]
delete(this: &Map, key: &JsValue) -> bool1297     pub fn delete(this: &Map, key: &JsValue) -> bool;
1298 
1299     /// The `forEach()` method executes a provided function once per each
1300     /// key/value pair in the Map object, in insertion order.
1301     ///
1302     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/forEach)
1303     #[wasm_bindgen(method, js_name = forEach)]
for_each(this: &Map, callback: &mut dyn FnMut(JsValue, JsValue))1304     pub fn for_each(this: &Map, callback: &mut dyn FnMut(JsValue, JsValue));
1305 
1306     /// The `get()` method returns a specified element from a Map object.
1307     ///
1308     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/get)
1309     #[wasm_bindgen(method)]
get(this: &Map, key: &JsValue) -> JsValue1310     pub fn get(this: &Map, key: &JsValue) -> JsValue;
1311 
1312     /// The `has()` method returns a boolean indicating whether an element with
1313     /// the specified key exists or not.
1314     ///
1315     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/has)
1316     #[wasm_bindgen(method)]
has(this: &Map, key: &JsValue) -> bool1317     pub fn has(this: &Map, key: &JsValue) -> bool;
1318 
1319     /// The Map object holds key-value pairs. Any value (both objects and
1320     /// primitive values) maybe used as either a key or a value.
1321     ///
1322     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map)
1323     #[wasm_bindgen(constructor)]
new() -> Map1324     pub fn new() -> Map;
1325 
1326     /// The `set()` method adds or updates an element with a specified key
1327     /// and value to a Map object.
1328     ///
1329     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/set)
1330     #[wasm_bindgen(method)]
set(this: &Map, key: &JsValue, value: &JsValue) -> Map1331     pub fn set(this: &Map, key: &JsValue, value: &JsValue) -> Map;
1332 
1333     /// The value of size is an integer representing how many entries
1334     /// the Map object has. A set accessor function for size is undefined;
1335     /// you can not change this property.
1336     ///
1337     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/size)
1338     #[wasm_bindgen(method, getter, structural)]
size(this: &Map) -> u321339     pub fn size(this: &Map) -> u32;
1340 }
1341 
1342 // Map Iterator
1343 #[wasm_bindgen]
1344 extern "C" {
1345     /// The `entries()` method returns a new Iterator object that contains
1346     /// the [key, value] pairs for each element in the Map object in
1347     /// insertion order.
1348     ///
1349     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/entries)
1350     #[wasm_bindgen(method)]
entries(this: &Map) -> Iterator1351     pub fn entries(this: &Map) -> Iterator;
1352 
1353     /// The `keys()` method returns a new Iterator object that contains the
1354     /// keys for each element in the Map object in insertion order.
1355     ///
1356     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/keys)
1357     #[wasm_bindgen(method)]
keys(this: &Map) -> Iterator1358     pub fn keys(this: &Map) -> Iterator;
1359 
1360     /// The `values()` method returns a new Iterator object that contains the
1361     /// values for each element in the Map object in insertion order.
1362     ///
1363     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/values)
1364     #[wasm_bindgen(method)]
values(this: &Map) -> Iterator1365     pub fn values(this: &Map) -> Iterator;
1366 }
1367 
1368 // Iterator
1369 #[wasm_bindgen]
1370 extern "C" {
1371     /// Any object that conforms to the JS iterator protocol. For example,
1372     /// something returned by `myArray[Symbol.iterator]()`.
1373     ///
1374     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols)
1375     #[derive(Clone, Debug)]
1376     #[wasm_bindgen(is_type_of = Iterator::looks_like_iterator)]
1377     pub type Iterator;
1378 
1379     /// The `next()` method always has to return an object with appropriate
1380     /// properties including done and value. If a non-object value gets returned
1381     /// (such as false or undefined), a TypeError ("iterator.next() returned a
1382     /// non-object value") will be thrown.
1383     #[wasm_bindgen(catch, method, structural)]
next(this: &Iterator) -> Result<IteratorNext, JsValue>1384     pub fn next(this: &Iterator) -> Result<IteratorNext, JsValue>;
1385 }
1386 
1387 impl Iterator {
looks_like_iterator(it: &JsValue) -> bool1388     fn looks_like_iterator(it: &JsValue) -> bool {
1389         #[wasm_bindgen]
1390         extern "C" {
1391             type MaybeIterator;
1392 
1393             #[wasm_bindgen(method, getter)]
1394             fn next(this: &MaybeIterator) -> JsValue;
1395         }
1396 
1397         if !it.is_object() {
1398             return false;
1399         }
1400 
1401         let it = it.unchecked_ref::<MaybeIterator>();
1402 
1403         it.next().is_function()
1404     }
1405 }
1406 
1407 // Async Iterator
1408 #[wasm_bindgen]
1409 extern "C" {
1410     /// Any object that conforms to the JS async iterator protocol. For example,
1411     /// something returned by `myObject[Symbol.asyncIterator]()`.
1412     ///
1413     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of)
1414     #[derive(Clone, Debug)]
1415     #[wasm_bindgen(is_type_of = Iterator::looks_like_iterator)]
1416     pub type AsyncIterator;
1417 
1418     /// The `next()` method always has to return a Promise which resolves to an object
1419     /// with appropriate properties including done and value. If a non-object value
1420     /// gets returned (such as false or undefined), a TypeError ("iterator.next()
1421     /// returned a non-object value") will be thrown.
1422     #[wasm_bindgen(catch, method, structural)]
next(this: &AsyncIterator) -> Result<Promise, JsValue>1423     pub fn next(this: &AsyncIterator) -> Result<Promise, JsValue>;
1424 }
1425 
1426 /// An iterator over the JS `Symbol.iterator` iteration protocol.
1427 ///
1428 /// Use the `IntoIterator for &js_sys::Iterator` implementation to create this.
1429 pub struct Iter<'a> {
1430     js: &'a Iterator,
1431     state: IterState,
1432 }
1433 
1434 /// An iterator over the JS `Symbol.iterator` iteration protocol.
1435 ///
1436 /// Use the `IntoIterator for js_sys::Iterator` implementation to create this.
1437 pub struct IntoIter {
1438     js: Iterator,
1439     state: IterState,
1440 }
1441 
1442 struct IterState {
1443     done: bool,
1444 }
1445 
1446 impl<'a> IntoIterator for &'a Iterator {
1447     type Item = Result<JsValue, JsValue>;
1448     type IntoIter = Iter<'a>;
1449 
into_iter(self) -> Iter<'a>1450     fn into_iter(self) -> Iter<'a> {
1451         Iter {
1452             js: self,
1453             state: IterState::new(),
1454         }
1455     }
1456 }
1457 
1458 impl<'a> std::iter::Iterator for Iter<'a> {
1459     type Item = Result<JsValue, JsValue>;
1460 
next(&mut self) -> Option<Self::Item>1461     fn next(&mut self) -> Option<Self::Item> {
1462         self.state.next(self.js)
1463     }
1464 }
1465 
1466 impl IntoIterator for Iterator {
1467     type Item = Result<JsValue, JsValue>;
1468     type IntoIter = IntoIter;
1469 
into_iter(self) -> IntoIter1470     fn into_iter(self) -> IntoIter {
1471         IntoIter {
1472             js: self,
1473             state: IterState::new(),
1474         }
1475     }
1476 }
1477 
1478 impl std::iter::Iterator for IntoIter {
1479     type Item = Result<JsValue, JsValue>;
1480 
next(&mut self) -> Option<Self::Item>1481     fn next(&mut self) -> Option<Self::Item> {
1482         self.state.next(&self.js)
1483     }
1484 }
1485 
1486 impl IterState {
new() -> IterState1487     fn new() -> IterState {
1488         IterState { done: false }
1489     }
1490 
next(&mut self, js: &Iterator) -> Option<Result<JsValue, JsValue>>1491     fn next(&mut self, js: &Iterator) -> Option<Result<JsValue, JsValue>> {
1492         if self.done {
1493             return None;
1494         }
1495         let next = match js.next() {
1496             Ok(val) => val,
1497             Err(e) => {
1498                 self.done = true;
1499                 return Some(Err(e));
1500             }
1501         };
1502         if next.done() {
1503             self.done = true;
1504             None
1505         } else {
1506             Some(Ok(next.value()))
1507         }
1508     }
1509 }
1510 
1511 /// Create an iterator over `val` using the JS iteration protocol and
1512 /// `Symbol.iterator`.
try_iter(val: &JsValue) -> Result<Option<IntoIter>, JsValue>1513 pub fn try_iter(val: &JsValue) -> Result<Option<IntoIter>, JsValue> {
1514     let iter_sym = Symbol::iterator();
1515     let iter_fn = Reflect::get(val, iter_sym.as_ref())?;
1516 
1517     let iter_fn: Function = match iter_fn.dyn_into() {
1518         Ok(iter_fn) => iter_fn,
1519         Err(_) => return Ok(None),
1520     };
1521 
1522     let it: Iterator = match iter_fn.call0(val)?.dyn_into() {
1523         Ok(it) => it,
1524         Err(_) => return Ok(None),
1525     };
1526 
1527     Ok(Some(it.into_iter()))
1528 }
1529 
1530 // IteratorNext
1531 #[wasm_bindgen]
1532 extern "C" {
1533     /// The result of calling `next()` on a JS iterator.
1534     ///
1535     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols)
1536     #[wasm_bindgen(extends = Object)]
1537     #[derive(Clone, Debug, PartialEq, Eq)]
1538     pub type IteratorNext;
1539 
1540     /// Has the value `true` if the iterator is past the end of the iterated
1541     /// sequence. In this case value optionally specifies the return value of
1542     /// the iterator.
1543     ///
1544     /// Has the value `false` if the iterator was able to produce the next value
1545     /// in the sequence. This is equivalent of not specifying the done property
1546     /// altogether.
1547     #[wasm_bindgen(method, getter, structural)]
done(this: &IteratorNext) -> bool1548     pub fn done(this: &IteratorNext) -> bool;
1549 
1550     /// Any JavaScript value returned by the iterator. Can be omitted when done
1551     /// is true.
1552     #[wasm_bindgen(method, getter, structural)]
value(this: &IteratorNext) -> JsValue1553     pub fn value(this: &IteratorNext) -> JsValue;
1554 }
1555 
1556 #[allow(non_snake_case)]
1557 pub mod Math {
1558     use super::*;
1559 
1560     // Math
1561     #[wasm_bindgen]
1562     extern "C" {
1563         /// The `Math.abs()` function returns the absolute value of a number, that is
1564         /// Math.abs(x) = |x|
1565         ///
1566         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/abs)
1567         #[wasm_bindgen(js_namespace = Math)]
abs(x: f64) -> f641568         pub fn abs(x: f64) -> f64;
1569 
1570         /// The `Math.acos()` function returns the arccosine (in radians) of a
1571         /// number, that is ∀x∊[-1;1]
1572         /// Math.acos(x) = arccos(x) = the unique y∊[0;π] such that cos(y)=x
1573         ///
1574         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/acos)
1575         #[wasm_bindgen(js_namespace = Math)]
acos(x: f64) -> f641576         pub fn acos(x: f64) -> f64;
1577 
1578         /// The `Math.acosh()` function returns the hyperbolic arc-cosine of a
1579         /// number, that is ∀x ≥ 1
1580         /// Math.acosh(x) = arcosh(x) = the unique y ≥ 0 such that cosh(y) = x
1581         ///
1582         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/acosh)
1583         #[wasm_bindgen(js_namespace = Math)]
acosh(x: f64) -> f641584         pub fn acosh(x: f64) -> f64;
1585 
1586         /// The `Math.asin()` function returns the arcsine (in radians) of a
1587         /// number, that is ∀x ∊ [-1;1]
1588         /// Math.asin(x) = arcsin(x) = the unique y∊[-π2;π2] such that sin(y) = x
1589         ///
1590         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/asin)
1591         #[wasm_bindgen(js_namespace = Math)]
asin(x: f64) -> f641592         pub fn asin(x: f64) -> f64;
1593 
1594         /// The `Math.asinh()` function returns the hyperbolic arcsine of a
1595         /// number, that is Math.asinh(x) = arsinh(x) = the unique y such that sinh(y) = x
1596         ///
1597         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/asinh)
1598         #[wasm_bindgen(js_namespace = Math)]
asinh(x: f64) -> f641599         pub fn asinh(x: f64) -> f64;
1600 
1601         /// The `Math.atan()` function returns the arctangent (in radians) of a
1602         /// number, that is Math.atan(x) = arctan(x) = the unique y ∊ [-π2;π2]such that
1603         /// tan(y) = x
1604         #[wasm_bindgen(js_namespace = Math)]
atan(x: f64) -> f641605         pub fn atan(x: f64) -> f64;
1606 
1607         /// The `Math.atan2()` function returns the arctangent of the quotient of
1608         /// its arguments.
1609         ///
1610         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atan2)
1611         #[wasm_bindgen(js_namespace = Math)]
atan2(y: f64, x: f64) -> f641612         pub fn atan2(y: f64, x: f64) -> f64;
1613 
1614         /// The `Math.atanh()` function returns the hyperbolic arctangent of a number,
1615         /// that is ∀x ∊ (-1,1), Math.atanh(x) = arctanh(x) = the unique y such that
1616         /// tanh(y) = x
1617         ///
1618         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atanh)
1619         #[wasm_bindgen(js_namespace = Math)]
atanh(x: f64) -> f641620         pub fn atanh(x: f64) -> f64;
1621 
1622         /// The `Math.cbrt() `function returns the cube root of a number, that is
1623         /// Math.cbrt(x) = ∛x = the unique y such that y^3 = x
1624         ///
1625         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cbrt)
1626         #[wasm_bindgen(js_namespace = Math)]
cbrt(x: f64) -> f641627         pub fn cbrt(x: f64) -> f64;
1628 
1629         /// The `Math.ceil()` function returns the smallest integer greater than
1630         /// or equal to a given number.
1631         ///
1632         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/ceil)
1633         #[wasm_bindgen(js_namespace = Math)]
ceil(x: f64) -> f641634         pub fn ceil(x: f64) -> f64;
1635 
1636         /// The `Math.clz32()` function returns the number of leading zero bits in
1637         /// the 32-bit binary representation of a number.
1638         ///
1639         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/clz32)
1640         #[wasm_bindgen(js_namespace = Math)]
clz32(x: i32) -> u321641         pub fn clz32(x: i32) -> u32;
1642 
1643         /// The `Math.cos()` static function returns the cosine of the specified angle,
1644         /// which must be specified in radians. This value is length(adjacent)/length(hypotenuse).
1645         ///
1646         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cos)
1647         #[wasm_bindgen(js_namespace = Math)]
cos(x: f64) -> f641648         pub fn cos(x: f64) -> f64;
1649 
1650         /// The `Math.cosh()` function returns the hyperbolic cosine of a number,
1651         /// that can be expressed using the constant e.
1652         ///
1653         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cosh)
1654         #[wasm_bindgen(js_namespace = Math)]
cosh(x: f64) -> f641655         pub fn cosh(x: f64) -> f64;
1656 
1657         /// The `Math.exp()` function returns e^x, where x is the argument, and e is Euler's number
1658         /// (also known as Napier's constant), the base of the natural logarithms.
1659         ///
1660         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/exp)
1661         #[wasm_bindgen(js_namespace = Math)]
exp(x: f64) -> f641662         pub fn exp(x: f64) -> f64;
1663 
1664         /// The `Math.expm1()` function returns e^x - 1, where x is the argument, and e the base of the
1665         /// natural logarithms.
1666         ///
1667         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/expm1)
1668         #[wasm_bindgen(js_namespace = Math)]
expm1(x: f64) -> f641669         pub fn expm1(x: f64) -> f64;
1670 
1671         /// The `Math.floor()` function returns the largest integer less than or
1672         /// equal to a given number.
1673         ///
1674         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/floor)
1675         #[wasm_bindgen(js_namespace = Math)]
floor(x: f64) -> f641676         pub fn floor(x: f64) -> f64;
1677 
1678         /// The `Math.fround()` function returns the nearest 32-bit single precision float representation
1679         /// of a Number.
1680         ///
1681         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/fround)
1682         #[wasm_bindgen(js_namespace = Math)]
fround(x: f64) -> f321683         pub fn fround(x: f64) -> f32;
1684 
1685         /// The `Math.hypot()` function returns the square root of the sum of squares of its arguments.
1686         ///
1687         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/hypot)
1688         #[wasm_bindgen(js_namespace = Math)]
hypot(x: f64, y: f64) -> f641689         pub fn hypot(x: f64, y: f64) -> f64;
1690 
1691         /// The `Math.imul()` function returns the result of the C-like 32-bit multiplication of the
1692         /// two parameters.
1693         ///
1694         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul)
1695         #[wasm_bindgen(js_namespace = Math)]
imul(x: i32, y: i32) -> i321696         pub fn imul(x: i32, y: i32) -> i32;
1697 
1698         /// The `Math.log()` function returns the natural logarithm (base e) of a number.
1699         /// The JavaScript `Math.log()` function is equivalent to ln(x) in mathematics.
1700         ///
1701         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log)
1702         #[wasm_bindgen(js_namespace = Math)]
log(x: f64) -> f641703         pub fn log(x: f64) -> f64;
1704 
1705         /// The `Math.log10()` function returns the base 10 logarithm of a number.
1706         ///
1707         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log10)
1708         #[wasm_bindgen(js_namespace = Math)]
log10(x: f64) -> f641709         pub fn log10(x: f64) -> f64;
1710 
1711         /// The `Math.log1p()` function returns the natural logarithm (base e) of 1 + a number.
1712         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log1p)
1713         #[wasm_bindgen(js_namespace = Math)]
log1p(x: f64) -> f641714         pub fn log1p(x: f64) -> f64;
1715 
1716         /// The `Math.log2()` function returns the base 2 logarithm of a number.
1717         ///
1718         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log2)
1719         #[wasm_bindgen(js_namespace = Math)]
log2(x: f64) -> f641720         pub fn log2(x: f64) -> f64;
1721 
1722         /// The `Math.max()` function returns the largest of two numbers.
1723         ///
1724         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/max)
1725         #[wasm_bindgen(js_namespace = Math)]
max(x: f64, y: f64) -> f641726         pub fn max(x: f64, y: f64) -> f64;
1727 
1728         /// The static function `Math.min()` returns the lowest-valued number passed into it.
1729         ///
1730         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/min)
1731         #[wasm_bindgen(js_namespace = Math)]
min(x: f64, y: f64) -> f641732         pub fn min(x: f64, y: f64) -> f64;
1733 
1734         /// The `Math.pow()` function returns the base to the exponent power, that is, base^exponent.
1735         ///
1736         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/pow)
1737         #[wasm_bindgen(js_namespace = Math)]
pow(base: f64, exponent: f64) -> f641738         pub fn pow(base: f64, exponent: f64) -> f64;
1739 
1740         /// The `Math.random()` function returns a floating-point, pseudo-random number
1741         /// in the range 0–1 (inclusive of 0, but not 1) with approximately uniform distribution
1742         /// over that range — which you can then scale to your desired range.
1743         /// The implementation selects the initial seed to the random number generation algorithm;
1744         /// it cannot be chosen or reset by the user.
1745         ///
1746         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random)
1747         #[wasm_bindgen(js_namespace = Math)]
random() -> f641748         pub fn random() -> f64;
1749 
1750         /// The `Math.round()` function returns the value of a number rounded to the nearest integer.
1751         ///
1752         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/round)
1753         #[wasm_bindgen(js_namespace = Math)]
round(x: f64) -> f641754         pub fn round(x: f64) -> f64;
1755 
1756         /// The `Math.sign()` function returns the sign of a number, indicating whether the number is
1757         /// positive, negative or zero.
1758         ///
1759         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sign)
1760         #[wasm_bindgen(js_namespace = Math)]
sign(x: f64) -> f641761         pub fn sign(x: f64) -> f64;
1762 
1763         /// The `Math.sin()` function returns the sine of a number.
1764         ///
1765         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sin)
1766         #[wasm_bindgen(js_namespace = Math)]
sin(x: f64) -> f641767         pub fn sin(x: f64) -> f64;
1768 
1769         /// The `Math.sinh()` function returns the hyperbolic sine of a number, that can be expressed
1770         /// using the constant e: Math.sinh(x) = (e^x - e^-x)/2
1771         ///
1772         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sinh)
1773         #[wasm_bindgen(js_namespace = Math)]
sinh(x: f64) -> f641774         pub fn sinh(x: f64) -> f64;
1775 
1776         /// The `Math.sqrt()` function returns the square root of a number, that is
1777         /// ∀x ≥ 0, Math.sqrt(x) = √x = the unique y ≥ 0 such that y^2 = x
1778         ///
1779         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sqrt)
1780         #[wasm_bindgen(js_namespace = Math)]
sqrt(x: f64) -> f641781         pub fn sqrt(x: f64) -> f64;
1782 
1783         /// The `Math.tan()` function returns the tangent of a number.
1784         ///
1785         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/tan)
1786         #[wasm_bindgen(js_namespace = Math)]
tan(x: f64) -> f641787         pub fn tan(x: f64) -> f64;
1788 
1789         /// The `Math.tanh()` function returns the hyperbolic tangent of a number, that is
1790         /// tanh x = sinh x / cosh x = (e^x - e^-x)/(e^x + e^-x) = (e^2x - 1)/(e^2x + 1)
1791         ///
1792         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/tanh)
1793         #[wasm_bindgen(js_namespace = Math)]
tanh(x: f64) -> f641794         pub fn tanh(x: f64) -> f64;
1795 
1796         /// The `Math.trunc()` function returns the integer part of a number by removing any fractional
1797         /// digits.
1798         ///
1799         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/trunc)
1800         #[wasm_bindgen(js_namespace = Math)]
trunc(x: f64) -> f641801         pub fn trunc(x: f64) -> f64;
1802     }
1803 }
1804 
1805 // Number.
1806 #[wasm_bindgen]
1807 extern "C" {
1808     #[wasm_bindgen(extends = Object, is_type_of = |v| v.as_f64().is_some())]
1809     #[derive(Clone)]
1810     pub type Number;
1811 
1812     /// The `Number.isFinite()` method determines whether the passed value is a finite number.
1813     ///
1814     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isFinite)
1815     #[wasm_bindgen(static_method_of = Number, js_name = isFinite)]
is_finite(value: &JsValue) -> bool1816     pub fn is_finite(value: &JsValue) -> bool;
1817 
1818     /// The `Number.isInteger()` method determines whether the passed value is an integer.
1819     ///
1820     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger)
1821     #[wasm_bindgen(static_method_of = Number, js_name = isInteger)]
is_integer(value: &JsValue) -> bool1822     pub fn is_integer(value: &JsValue) -> bool;
1823 
1824     /// The `Number.isNaN()` method determines whether the passed value is `NaN` and its type is Number.
1825     /// It is a more robust version of the original, global isNaN().
1826     ///
1827     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isNaN)
1828     #[wasm_bindgen(static_method_of = Number, js_name = isNaN)]
is_nan(value: &JsValue) -> bool1829     pub fn is_nan(value: &JsValue) -> bool;
1830 
1831     /// The `Number.isSafeInteger()` method determines whether the provided value is a number
1832     /// that is a safe integer.
1833     ///
1834     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger)
1835     #[wasm_bindgen(static_method_of = Number, js_name = isSafeInteger)]
is_safe_integer(value: &JsValue) -> bool1836     pub fn is_safe_integer(value: &JsValue) -> bool;
1837 
1838     /// The `Number` JavaScript object is a wrapper object allowing
1839     /// you to work with numerical values. A `Number` object is
1840     /// created using the `Number()` constructor.
1841     ///
1842     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)
1843     #[wasm_bindgen(constructor)]
1844     #[deprecated(note = "recommended to use `Number::from` instead")]
new(value: &JsValue) -> Number1845     pub fn new(value: &JsValue) -> Number;
1846 
1847     /// The `Number.parseInt()` method parses a string argument and returns an
1848     /// integer of the specified radix or base.
1849     ///
1850     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/parseInt)
1851     #[wasm_bindgen(static_method_of = Number, js_name = parseInt)]
parse_int(text: &str, radix: u8) -> f641852     pub fn parse_int(text: &str, radix: u8) -> f64;
1853 
1854     /// The `Number.parseFloat()` method parses a string argument and returns a
1855     /// floating point number.
1856     ///
1857     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/parseFloat)
1858     #[wasm_bindgen(static_method_of = Number, js_name = parseFloat)]
parse_float(text: &str) -> f641859     pub fn parse_float(text: &str) -> f64;
1860 
1861     /// The `toLocaleString()` method returns a string with a language sensitive
1862     /// representation of this number.
1863     ///
1864     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString)
1865     #[wasm_bindgen(method, js_name = toLocaleString)]
to_locale_string(this: &Number, locale: &str) -> JsString1866     pub fn to_locale_string(this: &Number, locale: &str) -> JsString;
1867 
1868     /// The `toPrecision()` method returns a string representing the Number
1869     /// object to the specified precision.
1870     ///
1871     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toPrecision)
1872     #[wasm_bindgen(catch, method, js_name = toPrecision)]
to_precision(this: &Number, precision: u8) -> Result<JsString, JsValue>1873     pub fn to_precision(this: &Number, precision: u8) -> Result<JsString, JsValue>;
1874 
1875     /// The `toFixed()` method returns a string representing the Number
1876     /// object using fixed-point notation.
1877     ///
1878     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed)
1879     #[wasm_bindgen(catch, method, js_name = toFixed)]
to_fixed(this: &Number, digits: u8) -> Result<JsString, JsValue>1880     pub fn to_fixed(this: &Number, digits: u8) -> Result<JsString, JsValue>;
1881 
1882     /// The `toExponential()` method returns a string representing the Number
1883     /// object in exponential notation.
1884     ///
1885     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toExponential)
1886     #[wasm_bindgen(catch, method, js_name = toExponential)]
to_exponential(this: &Number, fraction_digits: u8) -> Result<JsString, JsValue>1887     pub fn to_exponential(this: &Number, fraction_digits: u8) -> Result<JsString, JsValue>;
1888 
1889     /// The `toString()` method returns a string representing the
1890     /// specified Number object.
1891     ///
1892     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString)
1893     #[wasm_bindgen(catch, method, js_name = toString)]
to_string(this: &Number, radix: u8) -> Result<JsString, JsValue>1894     pub fn to_string(this: &Number, radix: u8) -> Result<JsString, JsValue>;
1895 
1896     /// The `valueOf()` method returns the wrapped primitive value of
1897     /// a Number object.
1898     ///
1899     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/valueOf)
1900     #[wasm_bindgen(method, js_name = valueOf)]
value_of(this: &Number) -> f641901     pub fn value_of(this: &Number) -> f64;
1902 }
1903 
1904 macro_rules! number_from {
1905     ($($x:ident)*) => ($(
1906         impl From<$x> for Number {
1907             #[inline]
1908             fn from(x: $x) -> Number {
1909                 Number::unchecked_from_js(JsValue::from(x))
1910             }
1911         }
1912 
1913         impl PartialEq<$x> for Number {
1914             #[inline]
1915             fn eq(&self, other: &$x) -> bool {
1916                 self.value_of() == f64::from(*other)
1917             }
1918         }
1919     )*)
1920 }
1921 number_from!(i8 u8 i16 u16 i32 u32 f32 f64);
1922 
1923 impl From<Number> for f64 {
1924     #[inline]
from(n: Number) -> f641925     fn from(n: Number) -> f64 {
1926         n.value_of()
1927     }
1928 }
1929 
1930 impl fmt::Debug for Number {
fmt(&self, f: &mut fmt::Formatter) -> fmt::Result1931     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1932         self.value_of().fmt(f)
1933     }
1934 }
1935 
1936 // Date.
1937 #[wasm_bindgen]
1938 extern "C" {
1939     #[wasm_bindgen(extends = Object)]
1940     #[derive(Clone, Debug, PartialEq, Eq)]
1941     pub type Date;
1942 
1943     /// The `getDate()` method returns the day of the month for the
1944     /// specified date according to local time.
1945     ///
1946     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getDate)
1947     #[wasm_bindgen(method, js_name = getDate)]
get_date(this: &Date) -> u321948     pub fn get_date(this: &Date) -> u32;
1949 
1950     /// The `getDay()` method returns the day of the week for the specified date according to local time,
1951     /// where 0 represents Sunday. For the day of the month see getDate().
1952     ///
1953     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getDay)
1954     #[wasm_bindgen(method, js_name = getDay)]
get_day(this: &Date) -> u321955     pub fn get_day(this: &Date) -> u32;
1956 
1957     /// The `getFullYear()` method returns the year of the specified date according to local time.
1958     ///
1959     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getFullYear)
1960     #[wasm_bindgen(method, js_name = getFullYear)]
get_full_year(this: &Date) -> u321961     pub fn get_full_year(this: &Date) -> u32;
1962 
1963     /// The `getHours()` method returns the hour for the specified date, according to local time.
1964     ///
1965     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getHours)
1966     #[wasm_bindgen(method, js_name = getHours)]
get_hours(this: &Date) -> u321967     pub fn get_hours(this: &Date) -> u32;
1968 
1969     /// The `getMilliseconds()` method returns the milliseconds in the specified date according to local time.
1970     ///
1971     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMilliseconds)
1972     #[wasm_bindgen(method, js_name = getMilliseconds)]
get_milliseconds(this: &Date) -> u321973     pub fn get_milliseconds(this: &Date) -> u32;
1974 
1975     /// The `getMinutes()` method returns the minutes in the specified date according to local time.
1976     ///
1977     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMinutes)
1978     #[wasm_bindgen(method, js_name = getMinutes)]
get_minutes(this: &Date) -> u321979     pub fn get_minutes(this: &Date) -> u32;
1980 
1981     /// The `getMonth()` method returns the month in the specified date according to local time,
1982     /// as a zero-based value (where zero indicates the first month of the year).
1983     ///
1984     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMonth)
1985     #[wasm_bindgen(method, js_name = getMonth)]
get_month(this: &Date) -> u321986     pub fn get_month(this: &Date) -> u32;
1987 
1988     /// The `getSeconds()` method returns the seconds in the specified date according to local time.
1989     ///
1990     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getSeconds)
1991     #[wasm_bindgen(method, js_name = getSeconds)]
get_seconds(this: &Date) -> u321992     pub fn get_seconds(this: &Date) -> u32;
1993 
1994     /// The `getTime()` method returns the numeric value corresponding to the time for the specified date
1995     /// according to universal time.
1996     ///
1997     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTime)
1998     #[wasm_bindgen(method, js_name = getTime)]
get_time(this: &Date) -> f641999     pub fn get_time(this: &Date) -> f64;
2000 
2001     /// The `getTimezoneOffset()` method returns the time zone difference, in minutes,
2002     /// from current locale (host system settings) to UTC.
2003     ///
2004     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset)
2005     #[wasm_bindgen(method, js_name = getTimezoneOffset)]
get_timezone_offset(this: &Date) -> f642006     pub fn get_timezone_offset(this: &Date) -> f64;
2007 
2008     /// The `getUTCDate()` method returns the day (date) of the month in the specified date
2009     /// according to universal time.
2010     ///
2011     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCDate)
2012     #[wasm_bindgen(method, js_name = getUTCDate)]
get_utc_date(this: &Date) -> u322013     pub fn get_utc_date(this: &Date) -> u32;
2014 
2015     /// The `getUTCDay()` method returns the day of the week in the specified date according to universal time,
2016     /// where 0 represents Sunday.
2017     ///
2018     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCDay)
2019     #[wasm_bindgen(method, js_name = getUTCDay)]
get_utc_day(this: &Date) -> u322020     pub fn get_utc_day(this: &Date) -> u32;
2021 
2022     /// The `getUTCFullYear()` method returns the year in the specified date according to universal time.
2023     ///
2024     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCFullYear)
2025     #[wasm_bindgen(method, js_name = getUTCFullYear)]
get_utc_full_year(this: &Date) -> u322026     pub fn get_utc_full_year(this: &Date) -> u32;
2027 
2028     /// The `getUTCHours()` method returns the hours in the specified date according to universal time.
2029     ///
2030     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCHours)
2031     #[wasm_bindgen(method, js_name = getUTCHours)]
get_utc_hours(this: &Date) -> u322032     pub fn get_utc_hours(this: &Date) -> u32;
2033 
2034     /// The `getUTCMilliseconds()` method returns the milliseconds in the specified date
2035     /// according to universal time.
2036     ///
2037     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMilliseconds)
2038     #[wasm_bindgen(method, js_name = getUTCMilliseconds)]
get_utc_milliseconds(this: &Date) -> u322039     pub fn get_utc_milliseconds(this: &Date) -> u32;
2040 
2041     /// The `getUTCMinutes()` method returns the minutes in the specified date according to universal time.
2042     ///
2043     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMinutes)
2044     #[wasm_bindgen(method, js_name = getUTCMinutes)]
get_utc_minutes(this: &Date) -> u322045     pub fn get_utc_minutes(this: &Date) -> u32;
2046 
2047     /// The `getUTCMonth()` returns the month of the specified date according to universal time,
2048     /// as a zero-based value (where zero indicates the first month of the year).
2049     ///
2050     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMonth)
2051     #[wasm_bindgen(method, js_name = getUTCMonth)]
get_utc_month(this: &Date) -> u322052     pub fn get_utc_month(this: &Date) -> u32;
2053 
2054     /// The `getUTCSeconds()` method returns the seconds in the specified date according to universal time.
2055     ///
2056     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCSeconds)
2057     #[wasm_bindgen(method, js_name = getUTCSeconds)]
get_utc_seconds(this: &Date) -> u322058     pub fn get_utc_seconds(this: &Date) -> u32;
2059 
2060     /// Creates a JavaScript `Date` instance that represents
2061     /// a single moment in time. `Date` objects are based on a time value that is
2062     /// the number of milliseconds since 1 January 1970 UTC.
2063     ///
2064     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
2065     #[wasm_bindgen(constructor)]
new(init: &JsValue) -> Date2066     pub fn new(init: &JsValue) -> Date;
2067 
2068     /// Creates a JavaScript `Date` instance that represents the current moment in
2069     /// time.
2070     ///
2071     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
2072     #[wasm_bindgen(constructor)]
new_0() -> Date2073     pub fn new_0() -> Date;
2074 
2075     /// Creates a JavaScript `Date` instance that represents
2076     /// a single moment in time. `Date` objects are based on a time value that is
2077     /// the number of milliseconds since 1 January 1970 UTC.
2078     ///
2079     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
2080     #[wasm_bindgen(constructor)]
new_with_year_month(year: u32, month: i32) -> Date2081     pub fn new_with_year_month(year: u32, month: i32) -> Date;
2082 
2083     /// Creates a JavaScript `Date` instance that represents
2084     /// a single moment in time. `Date` objects are based on a time value that is
2085     /// the number of milliseconds since 1 January 1970 UTC.
2086     ///
2087     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
2088     #[wasm_bindgen(constructor)]
new_with_year_month_day(year: u32, month: i32, day: i32) -> Date2089     pub fn new_with_year_month_day(year: u32, month: i32, day: i32) -> Date;
2090 
2091     /// Creates a JavaScript `Date` instance that represents
2092     /// a single moment in time. `Date` objects are based on a time value that is
2093     /// the number of milliseconds since 1 January 1970 UTC.
2094     ///
2095     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
2096     #[wasm_bindgen(constructor)]
new_with_year_month_day_hr(year: u32, month: i32, day: i32, hr: i32) -> Date2097     pub fn new_with_year_month_day_hr(year: u32, month: i32, day: i32, hr: i32) -> Date;
2098 
2099     /// Creates a JavaScript `Date` instance that represents
2100     /// a single moment in time. `Date` objects are based on a time value that is
2101     /// the number of milliseconds since 1 January 1970 UTC.
2102     ///
2103     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
2104     #[wasm_bindgen(constructor)]
new_with_year_month_day_hr_min( year: u32, month: i32, day: i32, hr: i32, min: i32, ) -> Date2105     pub fn new_with_year_month_day_hr_min(
2106         year: u32,
2107         month: i32,
2108         day: i32,
2109         hr: i32,
2110         min: i32,
2111     ) -> Date;
2112 
2113     /// Creates a JavaScript `Date` instance that represents
2114     /// a single moment in time. `Date` objects are based on a time value that is
2115     /// the number of milliseconds since 1 January 1970 UTC.
2116     ///
2117     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
2118     #[wasm_bindgen(constructor)]
new_with_year_month_day_hr_min_sec( year: u32, month: i32, day: i32, hr: i32, min: i32, sec: i32, ) -> Date2119     pub fn new_with_year_month_day_hr_min_sec(
2120         year: u32,
2121         month: i32,
2122         day: i32,
2123         hr: i32,
2124         min: i32,
2125         sec: i32,
2126     ) -> Date;
2127 
2128     /// Creates a JavaScript `Date` instance that represents
2129     /// a single moment in time. `Date` objects are based on a time value that is
2130     /// the number of milliseconds since 1 January 1970 UTC.
2131     ///
2132     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
2133     #[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, ) -> Date2134     pub fn new_with_year_month_day_hr_min_sec_milli(
2135         year: u32,
2136         month: i32,
2137         day: i32,
2138         hr: i32,
2139         min: i32,
2140         sec: i32,
2141         milli: i32,
2142     ) -> Date;
2143 
2144     /// The `Date.now()` method returns the number of milliseconds
2145     /// elapsed since January 1, 1970 00:00:00 UTC.
2146     ///
2147     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now)
2148     #[wasm_bindgen(static_method_of = Date)]
now() -> f642149     pub fn now() -> f64;
2150 
2151     /// The `Date.parse()` method parses a string representation of a date, and returns the number of milliseconds
2152     /// since January 1, 1970, 00:00:00 UTC or `NaN` if the string is unrecognized or, in some cases,
2153     /// contains illegal date values (e.g. 2015-02-31).
2154     ///
2155     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse)
2156     #[wasm_bindgen(static_method_of = Date)]
parse(date: &str) -> f642157     pub fn parse(date: &str) -> f64;
2158 
2159     /// The `setDate()` method sets the day of the Date object relative to the beginning of the currently set month.
2160     ///
2161     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setDate)
2162     #[wasm_bindgen(method, js_name = setDate)]
set_date(this: &Date, day: u32) -> f642163     pub fn set_date(this: &Date, day: u32) -> f64;
2164 
2165     /// The `setFullYear()` method sets the full year for a specified date according to local time.
2166     /// Returns new timestamp.
2167     ///
2168     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setFullYear)
2169     #[wasm_bindgen(method, js_name = setFullYear)]
set_full_year(this: &Date, year: u32) -> f642170     pub fn set_full_year(this: &Date, year: u32) -> f64;
2171 
2172     /// The `setFullYear()` method sets the full year for a specified date according to local time.
2173     /// Returns new timestamp.
2174     ///
2175     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setFullYear)
2176     #[wasm_bindgen(method, js_name = setFullYear)]
set_full_year_with_month(this: &Date, year: u32, month: i32) -> f642177     pub fn set_full_year_with_month(this: &Date, year: u32, month: i32) -> f64;
2178 
2179     /// The `setFullYear()` method sets the full year for a specified date according to local time.
2180     /// Returns new timestamp.
2181     ///
2182     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setFullYear)
2183     #[wasm_bindgen(method, js_name = setFullYear)]
set_full_year_with_month_date(this: &Date, year: u32, month: i32, date: i32) -> f642184     pub fn set_full_year_with_month_date(this: &Date, year: u32, month: i32, date: i32) -> f64;
2185 
2186     /// The `setHours()` method sets the hours for a specified date according to local time,
2187     /// and returns the number of milliseconds since January 1, 1970 00:00:00 UTC until the time represented
2188     /// by the updated Date instance.
2189     ///
2190     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setHours)
2191     #[wasm_bindgen(method, js_name = setHours)]
set_hours(this: &Date, hours: u32) -> f642192     pub fn set_hours(this: &Date, hours: u32) -> f64;
2193 
2194     /// The `setMilliseconds()` method sets the milliseconds for a specified date according to local time.
2195     ///
2196     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setMilliseconds)
2197     #[wasm_bindgen(method, js_name = setMilliseconds)]
set_milliseconds(this: &Date, milliseconds: u32) -> f642198     pub fn set_milliseconds(this: &Date, milliseconds: u32) -> f64;
2199 
2200     /// The `setMinutes()` method sets the minutes for a specified date according to local time.
2201     ///
2202     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setMinutes)
2203     #[wasm_bindgen(method, js_name = setMinutes)]
set_minutes(this: &Date, minutes: u32) -> f642204     pub fn set_minutes(this: &Date, minutes: u32) -> f64;
2205 
2206     /// The `setMonth()` method sets the month for a specified date according to the currently set year.
2207     ///
2208     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setMonth)
2209     #[wasm_bindgen(method, js_name = setMonth)]
set_month(this: &Date, month: u32) -> f642210     pub fn set_month(this: &Date, month: u32) -> f64;
2211 
2212     /// The `setSeconds()` method sets the seconds for a specified date according to local time.
2213     ///
2214     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setSeconds)
2215     #[wasm_bindgen(method, js_name = setSeconds)]
set_seconds(this: &Date, seconds: u32) -> f642216     pub fn set_seconds(this: &Date, seconds: u32) -> f64;
2217 
2218     /// The `setTime()` method sets the Date object to the time represented by a number of milliseconds
2219     /// since January 1, 1970, 00:00:00 UTC.
2220     ///
2221     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setTime)
2222     #[wasm_bindgen(method, js_name = setTime)]
set_time(this: &Date, time: f64) -> f642223     pub fn set_time(this: &Date, time: f64) -> f64;
2224 
2225     /// The `setUTCDate()` method sets the day of the month for a specified date
2226     /// according to universal time.
2227     ///
2228     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCDate)
2229     #[wasm_bindgen(method, js_name = setUTCDate)]
set_utc_date(this: &Date, day: u32) -> f642230     pub fn set_utc_date(this: &Date, day: u32) -> f64;
2231 
2232     /// The `setUTCFullYear()` method sets the full year for a specified date according to universal time.
2233     ///
2234     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCFullYear)
2235     #[wasm_bindgen(method, js_name = setUTCFullYear)]
set_utc_full_year(this: &Date, year: u32) -> f642236     pub fn set_utc_full_year(this: &Date, year: u32) -> f64;
2237 
2238     /// The `setUTCFullYear()` method sets the full year for a specified date according to universal time.
2239     ///
2240     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCFullYear)
2241     #[wasm_bindgen(method, js_name = setUTCFullYear)]
set_utc_full_year_with_month(this: &Date, year: u32, month: i32) -> f642242     pub fn set_utc_full_year_with_month(this: &Date, year: u32, month: i32) -> f64;
2243 
2244     /// The `setUTCFullYear()` method sets the full year for a specified date according to universal time.
2245     ///
2246     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCFullYear)
2247     #[wasm_bindgen(method, js_name = setUTCFullYear)]
set_utc_full_year_with_month_date(this: &Date, year: u32, month: i32, date: i32) -> f642248     pub fn set_utc_full_year_with_month_date(this: &Date, year: u32, month: i32, date: i32) -> f64;
2249 
2250     /// The `setUTCHours()` method sets the hour for a specified date according to universal time,
2251     /// and returns the number of milliseconds since  January 1, 1970 00:00:00 UTC until the time
2252     /// represented by the updated Date instance.
2253     ///
2254     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCHours)
2255     #[wasm_bindgen(method, js_name = setUTCHours)]
set_utc_hours(this: &Date, hours: u32) -> f642256     pub fn set_utc_hours(this: &Date, hours: u32) -> f64;
2257 
2258     /// The `setUTCMilliseconds()` method sets the milliseconds for a specified date
2259     /// according to universal time.
2260     ///
2261     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCMilliseconds)
2262     #[wasm_bindgen(method, js_name = setUTCMilliseconds)]
set_utc_milliseconds(this: &Date, milliseconds: u32) -> f642263     pub fn set_utc_milliseconds(this: &Date, milliseconds: u32) -> f64;
2264 
2265     /// The `setUTCMinutes()` method sets the minutes for a specified date according to universal time.
2266     ///
2267     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCMinutes)
2268     #[wasm_bindgen(method, js_name = setUTCMinutes)]
set_utc_minutes(this: &Date, minutes: u32) -> f642269     pub fn set_utc_minutes(this: &Date, minutes: u32) -> f64;
2270 
2271     /// The `setUTCMonth()` method sets the month for a specified date according to universal time.
2272     ///
2273     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCMonth)
2274     #[wasm_bindgen(method, js_name = setUTCMonth)]
set_utc_month(this: &Date, month: u32) -> f642275     pub fn set_utc_month(this: &Date, month: u32) -> f64;
2276 
2277     /// The `setUTCSeconds()` method sets the seconds for a specified date according to universal time.
2278     ///
2279     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCSeconds)
2280     #[wasm_bindgen(method, js_name = setUTCSeconds)]
set_utc_seconds(this: &Date, seconds: u32) -> f642281     pub fn set_utc_seconds(this: &Date, seconds: u32) -> f64;
2282 
2283     /// The `toDateString()` method returns the date portion of a Date object
2284     /// in human readable form in American English.
2285     ///
2286     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toDateString)
2287     #[wasm_bindgen(method, js_name = toDateString)]
to_date_string(this: &Date) -> JsString2288     pub fn to_date_string(this: &Date) -> JsString;
2289 
2290     /// The `toISOString()` method returns a string in simplified extended ISO format (ISO
2291     /// 8601), which is always 24 or 27 characters long (YYYY-MM-DDTHH:mm:ss.sssZ or
2292     /// ±YYYYYY-MM-DDTHH:mm:ss.sssZ, respectively). The timezone is always zero UTC offset,
2293     /// as denoted by the suffix "Z"
2294     ///
2295     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
2296     #[wasm_bindgen(method, js_name = toISOString)]
to_iso_string(this: &Date) -> JsString2297     pub fn to_iso_string(this: &Date) -> JsString;
2298 
2299     /// The `toJSON()` method returns a string representation of the Date object.
2300     ///
2301     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toJSON)
2302     #[wasm_bindgen(method, js_name = toJSON)]
to_json(this: &Date) -> JsString2303     pub fn to_json(this: &Date) -> JsString;
2304 
2305     /// The `toLocaleDateString()` method returns a string with a language sensitive
2306     /// representation of the date portion of this date. The new locales and options
2307     /// arguments let applications specify the language whose formatting conventions
2308     /// should be used and allow to customize the behavior of the function.
2309     /// In older implementations, which ignore the locales and options arguments,
2310     /// the locale used and the form of the string
2311     /// returned are entirely implementation dependent.
2312     ///
2313     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString)
2314     #[wasm_bindgen(method, js_name = toLocaleDateString)]
to_locale_date_string(this: &Date, locale: &str, options: &JsValue) -> JsString2315     pub fn to_locale_date_string(this: &Date, locale: &str, options: &JsValue) -> JsString;
2316 
2317     /// The `toLocaleString()` method returns a string with a language sensitive
2318     /// representation of this date. The new locales and options arguments
2319     /// let applications specify the language whose formatting conventions
2320     /// should be used and customize the behavior of the function.
2321     /// In older implementations, which ignore the locales
2322     /// and options arguments, the locale used and the form of the string
2323     /// returned are entirely implementation dependent.
2324     ///
2325     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString)
2326     #[wasm_bindgen(method, js_name = toLocaleString)]
to_locale_string(this: &Date, locale: &str, options: &JsValue) -> JsString2327     pub fn to_locale_string(this: &Date, locale: &str, options: &JsValue) -> JsString;
2328 
2329     /// The `toLocaleTimeString()` method returns a string with a language sensitive
2330     /// representation of the time portion of this date. The new locales and options
2331     /// arguments let applications specify the language whose formatting conventions should be
2332     /// used and customize the behavior of the function. In older implementations, which ignore
2333     /// the locales and options arguments, the locale used and the form of the string
2334     /// returned are entirely implementation dependent.
2335     ///
2336     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleTimeString)
2337     #[wasm_bindgen(method, js_name = toLocaleTimeString)]
to_locale_time_string(this: &Date, locale: &str) -> JsString2338     pub fn to_locale_time_string(this: &Date, locale: &str) -> JsString;
2339 
2340     /// The `toString()` method returns a string representing
2341     /// the specified Date object.
2342     ///
2343     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toString)
2344     #[wasm_bindgen(method, js_name = toString)]
to_string(this: &Date) -> JsString2345     pub fn to_string(this: &Date) -> JsString;
2346 
2347     /// The `toTimeString()` method returns the time portion of a Date object in human
2348     /// readable form in American English.
2349     ///
2350     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toTimeString)
2351     #[wasm_bindgen(method, js_name = toTimeString)]
to_time_string(this: &Date) -> JsString2352     pub fn to_time_string(this: &Date) -> JsString;
2353 
2354     /// The `toUTCString()` method converts a date to a string,
2355     /// using the UTC time zone.
2356     ///
2357     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toUTCString)
2358     #[wasm_bindgen(method, js_name = toUTCString)]
to_utc_string(this: &Date) -> JsString2359     pub fn to_utc_string(this: &Date) -> JsString;
2360 
2361     /// The `Date.UTC()` method accepts the same parameters as the
2362     /// longest form of the constructor, and returns the number of
2363     /// milliseconds in a `Date` object since January 1, 1970,
2364     /// 00:00:00, universal time.
2365     ///
2366     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/UTC)
2367     #[wasm_bindgen(static_method_of = Date, js_name = UTC)]
utc(year: f64, month: f64) -> f642368     pub fn utc(year: f64, month: f64) -> f64;
2369 
2370     /// The `valueOf()` method  returns the primitive value of
2371     /// a Date object.
2372     ///
2373     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/valueOf)
2374     #[wasm_bindgen(method, js_name = valueOf)]
value_of(this: &Date) -> f642375     pub fn value_of(this: &Date) -> f64;
2376 }
2377 
2378 // Object.
2379 #[wasm_bindgen]
2380 extern "C" {
2381     #[derive(Clone, Debug)]
2382     pub type Object;
2383 
2384     /// The `Object.assign()` method is used to copy the values of all enumerable
2385     /// own properties from one or more source objects to a target object. It
2386     /// will return the target object.
2387     ///
2388     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign)
2389     #[wasm_bindgen(static_method_of = Object)]
assign(target: &Object, source: &Object) -> Object2390     pub fn assign(target: &Object, source: &Object) -> Object;
2391 
2392     /// The `Object.assign()` method is used to copy the values of all enumerable
2393     /// own properties from one or more source objects to a target object. It
2394     /// will return the target object.
2395     ///
2396     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign)
2397     #[wasm_bindgen(static_method_of = Object, js_name = assign)]
assign2(target: &Object, source1: &Object, source2: &Object) -> Object2398     pub fn assign2(target: &Object, source1: &Object, source2: &Object) -> Object;
2399 
2400     /// The `Object.assign()` method is used to copy the values of all enumerable
2401     /// own properties from one or more source objects to a target object. It
2402     /// will return the target object.
2403     ///
2404     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign)
2405     #[wasm_bindgen(static_method_of = Object, js_name = assign)]
assign3(target: &Object, source1: &Object, source2: &Object, source3: &Object) -> Object2406     pub fn assign3(target: &Object, source1: &Object, source2: &Object, source3: &Object)
2407         -> Object;
2408 
2409     /// The constructor property returns a reference to the `Object` constructor
2410     /// function that created the instance object.
2411     ///
2412     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/constructor)
2413     #[wasm_bindgen(method, getter)]
constructor(this: &Object) -> Function2414     pub fn constructor(this: &Object) -> Function;
2415 
2416     /// The `Object.create()` method creates a new object, using an existing
2417     /// object to provide the newly created object's prototype.
2418     ///
2419     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create)
2420     #[wasm_bindgen(static_method_of = Object)]
create(prototype: &Object) -> Object2421     pub fn create(prototype: &Object) -> Object;
2422 
2423     /// The static method `Object.defineProperty()` defines a new
2424     /// property directly on an object, or modifies an existing
2425     /// property on an object, and returns the object.
2426     ///
2427     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty)
2428     #[wasm_bindgen(static_method_of = Object, js_name = defineProperty)]
define_property(obj: &Object, prop: &JsValue, descriptor: &Object) -> Object2429     pub fn define_property(obj: &Object, prop: &JsValue, descriptor: &Object) -> Object;
2430 
2431     /// The `Object.defineProperties()` method defines new or modifies
2432     /// existing properties directly on an object, returning the
2433     /// object.
2434     ///
2435     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperties)
2436     #[wasm_bindgen(static_method_of = Object, js_name = defineProperties)]
define_properties(obj: &Object, props: &Object) -> Object2437     pub fn define_properties(obj: &Object, props: &Object) -> Object;
2438 
2439     /// The `Object.entries()` method returns an array of a given
2440     /// object's own enumerable property [key, value] pairs, in the
2441     /// same order as that provided by a for...in loop (the difference
2442     /// being that a for-in loop enumerates properties in the
2443     /// prototype chain as well).
2444     ///
2445     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries)
2446     #[wasm_bindgen(static_method_of = Object)]
entries(object: &Object) -> Array2447     pub fn entries(object: &Object) -> Array;
2448 
2449     /// The `Object.freeze()` method freezes an object: that is, prevents new
2450     /// properties from being added to it; prevents existing properties from
2451     /// being removed; and prevents existing properties, or their enumerability,
2452     /// configurability, or writability, from being changed, it also prevents
2453     /// the prototype from being changed. The method returns the passed object.
2454     ///
2455     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze)
2456     #[wasm_bindgen(static_method_of = Object)]
freeze(value: &Object) -> Object2457     pub fn freeze(value: &Object) -> Object;
2458 
2459     /// The `Object.fromEntries()` method transforms a list of key-value pairs
2460     /// into an object.
2461     ///
2462     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/fromEntries)
2463     #[wasm_bindgen(static_method_of = Object, catch, js_name = fromEntries)]
from_entries(iterable: &JsValue) -> Result<Object, JsValue>2464     pub fn from_entries(iterable: &JsValue) -> Result<Object, JsValue>;
2465 
2466     /// The `Object.getOwnPropertyDescriptor()` method returns a
2467     /// property descriptor for an own property (that is, one directly
2468     /// present on an object and not in the object's prototype chain)
2469     /// of a given object.
2470     ///
2471     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor)
2472     #[wasm_bindgen(static_method_of = Object, js_name = getOwnPropertyDescriptor)]
get_own_property_descriptor(obj: &Object, prop: &JsValue) -> JsValue2473     pub fn get_own_property_descriptor(obj: &Object, prop: &JsValue) -> JsValue;
2474 
2475     /// The `Object.getOwnPropertyDescriptors()` method returns all own
2476     /// property descriptors of a given object.
2477     ///
2478     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptors)
2479     #[wasm_bindgen(static_method_of = Object, js_name = getOwnPropertyDescriptors)]
get_own_property_descriptors(obj: &Object) -> JsValue2480     pub fn get_own_property_descriptors(obj: &Object) -> JsValue;
2481 
2482     /// The `Object.getOwnPropertyNames()` method returns an array of
2483     /// all properties (including non-enumerable properties except for
2484     /// those which use Symbol) found directly upon a given object.
2485     ///
2486     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames)
2487     #[wasm_bindgen(static_method_of = Object, js_name = getOwnPropertyNames)]
get_own_property_names(obj: &Object) -> Array2488     pub fn get_own_property_names(obj: &Object) -> Array;
2489 
2490     /// The `Object.getOwnPropertySymbols()` method returns an array of
2491     /// all symbol properties found directly upon a given object.
2492     ///
2493     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertySymbols)
2494     #[wasm_bindgen(static_method_of = Object, js_name = getOwnPropertySymbols)]
get_own_property_symbols(obj: &Object) -> Array2495     pub fn get_own_property_symbols(obj: &Object) -> Array;
2496 
2497     /// The `Object.getPrototypeOf()` method returns the prototype
2498     /// (i.e. the value of the internal [[Prototype]] property) of the
2499     /// specified object.
2500     ///
2501     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getPrototypeOf)
2502     #[wasm_bindgen(static_method_of = Object, js_name = getPrototypeOf)]
get_prototype_of(obj: &JsValue) -> Object2503     pub fn get_prototype_of(obj: &JsValue) -> Object;
2504 
2505     /// The `hasOwnProperty()` method returns a boolean indicating whether the
2506     /// object has the specified property as its own property (as opposed to
2507     /// inheriting it).
2508     ///
2509     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty)
2510     #[wasm_bindgen(method, js_name = hasOwnProperty)]
has_own_property(this: &Object, property: &JsValue) -> bool2511     pub fn has_own_property(this: &Object, property: &JsValue) -> bool;
2512 
2513     /// The `Object.is()` method determines whether two values are the same value.
2514     ///
2515     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is)
2516     #[wasm_bindgen(static_method_of = Object)]
is(value_1: &JsValue, value_2: &JsValue) -> bool2517     pub fn is(value_1: &JsValue, value_2: &JsValue) -> bool;
2518 
2519     /// The `Object.isExtensible()` method determines if an object is extensible
2520     /// (whether it can have new properties added to it).
2521     ///
2522     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isExtensible)
2523     #[wasm_bindgen(static_method_of = Object, js_name = isExtensible)]
is_extensible(object: &Object) -> bool2524     pub fn is_extensible(object: &Object) -> bool;
2525 
2526     /// The `Object.isFrozen()` determines if an object is frozen.
2527     ///
2528     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isFrozen)
2529     #[wasm_bindgen(static_method_of = Object, js_name = isFrozen)]
is_frozen(object: &Object) -> bool2530     pub fn is_frozen(object: &Object) -> bool;
2531 
2532     /// The `Object.isSealed()` method determines if an object is sealed.
2533     ///
2534     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isSealed)
2535     #[wasm_bindgen(static_method_of = Object, js_name = isSealed)]
is_sealed(object: &Object) -> bool2536     pub fn is_sealed(object: &Object) -> bool;
2537 
2538     /// The `isPrototypeOf()` method checks if an object exists in another
2539     /// object's prototype chain.
2540     ///
2541     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isPrototypeOf)
2542     #[wasm_bindgen(method, js_name = isPrototypeOf)]
is_prototype_of(this: &Object, value: &JsValue) -> bool2543     pub fn is_prototype_of(this: &Object, value: &JsValue) -> bool;
2544 
2545     /// The `Object.keys()` method returns an array of a given object's property
2546     /// names, in the same order as we get with a normal loop.
2547     ///
2548     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys)
2549     #[wasm_bindgen(static_method_of = Object)]
keys(object: &Object) -> Array2550     pub fn keys(object: &Object) -> Array;
2551 
2552     /// The [`Object`] constructor creates an object wrapper.
2553     ///
2554     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)
2555     #[wasm_bindgen(constructor)]
new() -> Object2556     pub fn new() -> Object;
2557 
2558     /// The `Object.preventExtensions()` method prevents new properties from
2559     /// ever being added to an object (i.e. prevents future extensions to the
2560     /// object).
2561     ///
2562     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/preventExtensions)
2563     #[wasm_bindgen(static_method_of = Object, js_name = preventExtensions)]
prevent_extensions(object: &Object)2564     pub fn prevent_extensions(object: &Object);
2565 
2566     /// The `propertyIsEnumerable()` method returns a Boolean indicating
2567     /// whether the specified property is enumerable.
2568     ///
2569     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/propertyIsEnumerable)
2570     #[wasm_bindgen(method, js_name = propertyIsEnumerable)]
property_is_enumerable(this: &Object, property: &JsValue) -> bool2571     pub fn property_is_enumerable(this: &Object, property: &JsValue) -> bool;
2572 
2573     /// The `Object.seal()` method seals an object, preventing new properties
2574     /// from being added to it and marking all existing properties as
2575     /// non-configurable.  Values of present properties can still be changed as
2576     /// long as they are writable.
2577     ///
2578     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/seal)
2579     #[wasm_bindgen(static_method_of = Object)]
seal(value: &Object) -> Object2580     pub fn seal(value: &Object) -> Object;
2581 
2582     /// The `Object.setPrototypeOf()` method sets the prototype (i.e., the
2583     /// internal `[[Prototype]]` property) of a specified object to another
2584     /// object or `null`.
2585     ///
2586     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/setPrototypeOf)
2587     #[wasm_bindgen(static_method_of = Object, js_name = setPrototypeOf)]
set_prototype_of(object: &Object, prototype: &Object) -> Object2588     pub fn set_prototype_of(object: &Object, prototype: &Object) -> Object;
2589 
2590     /// The `toLocaleString()` method returns a string representing the object.
2591     /// This method is meant to be overridden by derived objects for
2592     /// locale-specific purposes.
2593     ///
2594     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toLocaleString)
2595     #[wasm_bindgen(method, js_name = toLocaleString)]
to_locale_string(this: &Object) -> JsString2596     pub fn to_locale_string(this: &Object) -> JsString;
2597 
2598     /// The `toString()` method returns a string representing the object.
2599     ///
2600     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString)
2601     #[wasm_bindgen(method, js_name = toString)]
to_string(this: &Object) -> JsString2602     pub fn to_string(this: &Object) -> JsString;
2603 
2604     /// The `valueOf()` method returns the primitive value of the
2605     /// specified object.
2606     ///
2607     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/valueOf)
2608     #[wasm_bindgen(method, js_name = valueOf)]
value_of(this: &Object) -> Object2609     pub fn value_of(this: &Object) -> Object;
2610 
2611     /// The `Object.values()` method returns an array of a given object's own
2612     /// enumerable property values, in the same order as that provided by a
2613     /// `for...in` loop (the difference being that a for-in loop enumerates
2614     /// properties in the prototype chain as well).
2615     ///
2616     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/values)
2617     #[wasm_bindgen(static_method_of = Object)]
values(object: &Object) -> Array2618     pub fn values(object: &Object) -> Array;
2619 }
2620 
2621 impl Object {
2622     /// Returns the `Object` value of this JS value if it's an instance of an
2623     /// object.
2624     ///
2625     /// If this JS value is not an instance of an object then this returns
2626     /// `None`.
try_from(val: &JsValue) -> Option<&Object>2627     pub fn try_from(val: &JsValue) -> Option<&Object> {
2628         if val.is_object() {
2629             Some(val.unchecked_ref())
2630         } else {
2631             None
2632         }
2633     }
2634 }
2635 
2636 impl PartialEq for Object {
2637     #[inline]
eq(&self, other: &Object) -> bool2638     fn eq(&self, other: &Object) -> bool {
2639         Object::is(self.as_ref(), other.as_ref())
2640     }
2641 }
2642 
2643 impl Eq for Object {}
2644 
2645 // Proxy
2646 #[wasm_bindgen]
2647 extern "C" {
2648     #[derive(Clone, Debug)]
2649     pub type Proxy;
2650 
2651     /// The [`Proxy`] object is used to define custom behavior for fundamental
2652     /// operations (e.g. property lookup, assignment, enumeration, function
2653     /// invocation, etc).
2654     ///
2655     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy)
2656     #[wasm_bindgen(constructor)]
new(target: &JsValue, handler: &Object) -> Proxy2657     pub fn new(target: &JsValue, handler: &Object) -> Proxy;
2658 
2659     /// The `Proxy.revocable()` method is used to create a revocable [`Proxy`]
2660     /// object.
2661     ///
2662     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/revocable)
2663     #[wasm_bindgen(static_method_of = Proxy)]
revocable(target: &JsValue, handler: &Object) -> Object2664     pub fn revocable(target: &JsValue, handler: &Object) -> Object;
2665 }
2666 
2667 // RangeError
2668 #[wasm_bindgen]
2669 extern "C" {
2670     /// The `RangeError` object indicates an error when a value is not in the set
2671     /// or range of allowed values.
2672     ///
2673     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError)
2674     #[wasm_bindgen(extends = Error, extends = Object)]
2675     #[derive(Clone, Debug, PartialEq, Eq)]
2676     pub type RangeError;
2677 
2678     /// The `RangeError` object indicates an error when a value is not in the set
2679     /// or range of allowed values.
2680     ///
2681     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError)
2682     #[wasm_bindgen(constructor)]
new(message: &str) -> RangeError2683     pub fn new(message: &str) -> RangeError;
2684 }
2685 
2686 // ReferenceError
2687 #[wasm_bindgen]
2688 extern "C" {
2689     /// The `ReferenceError` object represents an error when a non-existent
2690     /// variable is referenced.
2691     ///
2692     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError)
2693     #[wasm_bindgen(extends = Error, extends = Object)]
2694     #[derive(Clone, Debug, PartialEq, Eq)]
2695     pub type ReferenceError;
2696 
2697     /// The `ReferenceError` object represents an error when a non-existent
2698     /// variable is referenced.
2699     ///
2700     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError)
2701     #[wasm_bindgen(constructor)]
new(message: &str) -> ReferenceError2702     pub fn new(message: &str) -> ReferenceError;
2703 }
2704 
2705 #[allow(non_snake_case)]
2706 pub mod Reflect {
2707     use super::*;
2708 
2709     // Reflect
2710     #[wasm_bindgen]
2711     extern "C" {
2712         /// The static `Reflect.apply()` method calls a target function with
2713         /// arguments as specified.
2714         ///
2715         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/apply)
2716         #[wasm_bindgen(js_namespace = Reflect, catch)]
apply( target: &Function, this_argument: &JsValue, arguments_list: &Array, ) -> Result<JsValue, JsValue>2717         pub fn apply(
2718             target: &Function,
2719             this_argument: &JsValue,
2720             arguments_list: &Array,
2721         ) -> Result<JsValue, JsValue>;
2722 
2723         /// The static `Reflect.construct()` method acts like the new operator, but
2724         /// as a function.  It is equivalent to calling `new target(...args)`. It
2725         /// gives also the added option to specify a different prototype.
2726         ///
2727         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/construct)
2728         #[wasm_bindgen(js_namespace = Reflect, catch)]
construct(target: &Function, arguments_list: &Array) -> Result<JsValue, JsValue>2729         pub fn construct(target: &Function, arguments_list: &Array) -> Result<JsValue, JsValue>;
2730 
2731         /// The static `Reflect.construct()` method acts like the new operator, but
2732         /// as a function.  It is equivalent to calling `new target(...args)`. It
2733         /// gives also the added option to specify a different prototype.
2734         ///
2735         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/construct)
2736         #[wasm_bindgen(js_namespace = Reflect, js_name = construct, catch)]
construct_with_new_target( target: &Function, arguments_list: &Array, new_target: &Function, ) -> Result<JsValue, JsValue>2737         pub fn construct_with_new_target(
2738             target: &Function,
2739             arguments_list: &Array,
2740             new_target: &Function,
2741         ) -> Result<JsValue, JsValue>;
2742 
2743         /// The static `Reflect.defineProperty()` method is like
2744         /// `Object.defineProperty()` but returns a `Boolean`.
2745         ///
2746         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/defineProperty)
2747         #[wasm_bindgen(js_namespace = Reflect, js_name = defineProperty, catch)]
define_property( target: &Object, property_key: &JsValue, attributes: &Object, ) -> Result<bool, JsValue>2748         pub fn define_property(
2749             target: &Object,
2750             property_key: &JsValue,
2751             attributes: &Object,
2752         ) -> Result<bool, JsValue>;
2753 
2754         /// The static `Reflect.deleteProperty()` method allows to delete
2755         /// properties.  It is like the `delete` operator as a function.
2756         ///
2757         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/deleteProperty)
2758         #[wasm_bindgen(js_namespace = Reflect, js_name = deleteProperty, catch)]
delete_property(target: &Object, key: &JsValue) -> Result<bool, JsValue>2759         pub fn delete_property(target: &Object, key: &JsValue) -> Result<bool, JsValue>;
2760 
2761         /// The static `Reflect.get()` method works like getting a property from
2762         /// an object (`target[propertyKey]`) as a function.
2763         ///
2764         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/get)
2765         #[wasm_bindgen(js_namespace = Reflect, catch)]
get(target: &JsValue, key: &JsValue) -> Result<JsValue, JsValue>2766         pub fn get(target: &JsValue, key: &JsValue) -> Result<JsValue, JsValue>;
2767 
2768         /// The same as [`get`](fn.get.html)
2769         /// except the key is an `f64`, which is slightly faster.
2770         #[wasm_bindgen(js_namespace = Reflect, js_name = "get", catch)]
get_f64(target: &JsValue, key: f64) -> Result<JsValue, JsValue>2771         pub fn get_f64(target: &JsValue, key: f64) -> Result<JsValue, JsValue>;
2772 
2773         /// The same as [`get`](fn.get.html)
2774         /// except the key is a `u32`, which is slightly faster.
2775         #[wasm_bindgen(js_namespace = Reflect, js_name = "get", catch)]
get_u32(target: &JsValue, key: u32) -> Result<JsValue, JsValue>2776         pub fn get_u32(target: &JsValue, key: u32) -> Result<JsValue, JsValue>;
2777 
2778         /// The static `Reflect.getOwnPropertyDescriptor()` method is similar to
2779         /// `Object.getOwnPropertyDescriptor()`. It returns a property descriptor
2780         /// of the given property if it exists on the object, `undefined` otherwise.
2781         ///
2782         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/getOwnPropertyDescriptor)
2783         #[wasm_bindgen(js_namespace = Reflect, js_name = getOwnPropertyDescriptor, catch)]
get_own_property_descriptor( target: &Object, property_key: &JsValue, ) -> Result<JsValue, JsValue>2784         pub fn get_own_property_descriptor(
2785             target: &Object,
2786             property_key: &JsValue,
2787         ) -> Result<JsValue, JsValue>;
2788 
2789         /// The static `Reflect.getPrototypeOf()` method is almost the same
2790         /// method as `Object.getPrototypeOf()`. It returns the prototype
2791         /// (i.e. the value of the internal `[[Prototype]]` property) of
2792         /// the specified object.
2793         ///
2794         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/getPrototypeOf)
2795         #[wasm_bindgen(js_namespace = Reflect, js_name = getPrototypeOf, catch)]
get_prototype_of(target: &JsValue) -> Result<Object, JsValue>2796         pub fn get_prototype_of(target: &JsValue) -> Result<Object, JsValue>;
2797 
2798         /// The static `Reflect.has()` method works like the in operator as a
2799         /// function.
2800         ///
2801         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/has)
2802         #[wasm_bindgen(js_namespace = Reflect, catch)]
has(target: &JsValue, property_key: &JsValue) -> Result<bool, JsValue>2803         pub fn has(target: &JsValue, property_key: &JsValue) -> Result<bool, JsValue>;
2804 
2805         /// The static `Reflect.isExtensible()` method determines if an object is
2806         /// extensible (whether it can have new properties added to it). It is
2807         /// similar to `Object.isExtensible()`, but with some differences.
2808         ///
2809         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/isExtensible)
2810         #[wasm_bindgen(js_namespace = Reflect, js_name = isExtensible, catch)]
is_extensible(target: &Object) -> Result<bool, JsValue>2811         pub fn is_extensible(target: &Object) -> Result<bool, JsValue>;
2812 
2813         /// The static `Reflect.ownKeys()` method returns an array of the
2814         /// target object's own property keys.
2815         ///
2816         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/ownKeys)
2817         #[wasm_bindgen(js_namespace = Reflect, js_name = ownKeys, catch)]
own_keys(target: &JsValue) -> Result<Array, JsValue>2818         pub fn own_keys(target: &JsValue) -> Result<Array, JsValue>;
2819 
2820         /// The static `Reflect.preventExtensions()` method prevents new
2821         /// properties from ever being added to an object (i.e. prevents
2822         /// future extensions to the object). It is similar to
2823         /// `Object.preventExtensions()`, but with some differences.
2824         ///
2825         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/preventExtensions)
2826         #[wasm_bindgen(js_namespace = Reflect, js_name = preventExtensions, catch)]
prevent_extensions(target: &Object) -> Result<bool, JsValue>2827         pub fn prevent_extensions(target: &Object) -> Result<bool, JsValue>;
2828 
2829         /// The static `Reflect.set()` method works like setting a
2830         /// property on an object.
2831         ///
2832         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/set)
2833         #[wasm_bindgen(js_namespace = Reflect, catch)]
set( target: &JsValue, property_key: &JsValue, value: &JsValue, ) -> Result<bool, JsValue>2834         pub fn set(
2835             target: &JsValue,
2836             property_key: &JsValue,
2837             value: &JsValue,
2838         ) -> Result<bool, JsValue>;
2839 
2840         /// The same as [`set`](fn.set.html)
2841         /// except the key is an `f64`, which is slightly faster.
2842         #[wasm_bindgen(js_namespace = Reflect, js_name = "set", catch)]
set_f64( target: &JsValue, property_key: f64, value: &JsValue, ) -> Result<bool, JsValue>2843         pub fn set_f64(
2844             target: &JsValue,
2845             property_key: f64,
2846             value: &JsValue,
2847         ) -> Result<bool, JsValue>;
2848 
2849         /// The same as [`set`](fn.set.html)
2850         /// except the key is a `u32`, which is slightly faster.
2851         #[wasm_bindgen(js_namespace = Reflect, js_name = "set", catch)]
set_u32( target: &JsValue, property_key: u32, value: &JsValue, ) -> Result<bool, JsValue>2852         pub fn set_u32(
2853             target: &JsValue,
2854             property_key: u32,
2855             value: &JsValue,
2856         ) -> Result<bool, JsValue>;
2857 
2858         /// The static `Reflect.set()` method works like setting a
2859         /// property on an object.
2860         ///
2861         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/set)
2862         #[wasm_bindgen(js_namespace = Reflect, js_name = set, catch)]
set_with_receiver( target: &JsValue, property_key: &JsValue, value: &JsValue, receiver: &JsValue, ) -> Result<bool, JsValue>2863         pub fn set_with_receiver(
2864             target: &JsValue,
2865             property_key: &JsValue,
2866             value: &JsValue,
2867             receiver: &JsValue,
2868         ) -> Result<bool, JsValue>;
2869 
2870         /// The static `Reflect.setPrototypeOf()` method is the same
2871         /// method as `Object.setPrototypeOf()`. It sets the prototype
2872         /// (i.e., the internal `[[Prototype]]` property) of a specified
2873         /// object to another object or to null.
2874         ///
2875         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/setPrototypeOf)
2876         #[wasm_bindgen(js_namespace = Reflect, js_name = setPrototypeOf, catch)]
set_prototype_of(target: &Object, prototype: &JsValue) -> Result<bool, JsValue>2877         pub fn set_prototype_of(target: &Object, prototype: &JsValue) -> Result<bool, JsValue>;
2878     }
2879 }
2880 
2881 // RegExp
2882 #[wasm_bindgen]
2883 extern "C" {
2884     #[wasm_bindgen(extends = Object)]
2885     #[derive(Clone, Debug, PartialEq, Eq)]
2886     pub type RegExp;
2887 
2888     /// The `exec()` method executes a search for a match in a specified
2889     /// string. Returns a result array, or null.
2890     ///
2891     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec)
2892     #[wasm_bindgen(method)]
exec(this: &RegExp, text: &str) -> Option<Array>2893     pub fn exec(this: &RegExp, text: &str) -> Option<Array>;
2894 
2895     /// The flags property returns a string consisting of the flags of
2896     /// the current regular expression object.
2897     ///
2898     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/flags)
2899     #[wasm_bindgen(method, getter)]
flags(this: &RegExp) -> JsString2900     pub fn flags(this: &RegExp) -> JsString;
2901 
2902     /// The global property indicates whether or not the "g" flag is
2903     /// used with the regular expression. global is a read-only
2904     /// property of an individual regular expression instance.
2905     ///
2906     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/global)
2907     #[wasm_bindgen(method, getter)]
global(this: &RegExp) -> bool2908     pub fn global(this: &RegExp) -> bool;
2909 
2910     /// The ignoreCase property indicates whether or not the "i" flag
2911     /// is used with the regular expression. ignoreCase is a read-only
2912     /// property of an individual regular expression instance.
2913     ///
2914     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/ignoreCase)
2915     #[wasm_bindgen(method, getter, js_name = ignoreCase)]
ignore_case(this: &RegExp) -> bool2916     pub fn ignore_case(this: &RegExp) -> bool;
2917 
2918     /// The non-standard input property is a static property of
2919     /// regular expressions that contains the string against which a
2920     /// regular expression is matched. RegExp.$_ is an alias for this
2921     /// property.
2922     ///
2923     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/input)
2924     #[wasm_bindgen(static_method_of = RegExp, getter)]
input() -> JsString2925     pub fn input() -> JsString;
2926 
2927     /// The lastIndex is a read/write integer property of regular expression
2928     /// instances that specifies the index at which to start the next match.
2929     ///
2930     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastIndex)
2931     #[wasm_bindgen(structural, getter = lastIndex, method)]
last_index(this: &RegExp) -> u322932     pub fn last_index(this: &RegExp) -> u32;
2933 
2934     /// The lastIndex is a read/write integer property of regular expression
2935     /// instances that specifies the index at which to start the next match.
2936     ///
2937     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastIndex)
2938     #[wasm_bindgen(structural, setter = lastIndex, method)]
set_last_index(this: &RegExp, index: u32)2939     pub fn set_last_index(this: &RegExp, index: u32);
2940 
2941     /// The non-standard lastMatch property is a static and read-only
2942     /// property of regular expressions that contains the last matched
2943     /// characters. `RegExp.$&` is an alias for this property.
2944     ///
2945     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastMatch)
2946     #[wasm_bindgen(static_method_of = RegExp, getter, js_name = lastMatch)]
last_match() -> JsString2947     pub fn last_match() -> JsString;
2948 
2949     /// The non-standard lastParen property is a static and read-only
2950     /// property of regular expressions that contains the last
2951     /// parenthesized substring match, if any. `RegExp.$+` is an alias
2952     /// for this property.
2953     ///
2954     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastParen)
2955     #[wasm_bindgen(static_method_of = RegExp, getter, js_name = lastParen)]
last_paren() -> JsString2956     pub fn last_paren() -> JsString;
2957 
2958     /// The non-standard leftContext property is a static and
2959     /// read-only property of regular expressions that contains the
2960     /// substring preceding the most recent match. `RegExp.$`` is an
2961     /// alias for this property.
2962     ///
2963     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/leftContext)
2964     #[wasm_bindgen(static_method_of = RegExp, getter, js_name = leftContext)]
left_context() -> JsString2965     pub fn left_context() -> JsString;
2966 
2967     /// The multiline property indicates whether or not the "m" flag
2968     /// is used with the regular expression. multiline is a read-only
2969     /// property of an individual regular expression instance.
2970     ///
2971     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/multiline)
2972     #[wasm_bindgen(method, getter)]
multiline(this: &RegExp) -> bool2973     pub fn multiline(this: &RegExp) -> bool;
2974 
2975     /// The non-standard $1, $2, $3, $4, $5, $6, $7, $8, $9 properties
2976     /// are static and read-only properties of regular expressions
2977     /// that contain parenthesized substring matches.
2978     ///
2979     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/n)
2980     #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$1")]
n1() -> JsString2981     pub fn n1() -> JsString;
2982     #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$2")]
n2() -> JsString2983     pub fn n2() -> JsString;
2984     #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$3")]
n3() -> JsString2985     pub fn n3() -> JsString;
2986     #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$4")]
n4() -> JsString2987     pub fn n4() -> JsString;
2988     #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$5")]
n5() -> JsString2989     pub fn n5() -> JsString;
2990     #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$6")]
n6() -> JsString2991     pub fn n6() -> JsString;
2992     #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$7")]
n7() -> JsString2993     pub fn n7() -> JsString;
2994     #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$8")]
n8() -> JsString2995     pub fn n8() -> JsString;
2996     #[wasm_bindgen(static_method_of = RegExp, getter, js_name = "$9")]
n9() -> JsString2997     pub fn n9() -> JsString;
2998 
2999     /// The `RegExp` constructor creates a regular expression object for matching text with a pattern.
3000     ///
3001     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp)
3002     #[wasm_bindgen(constructor)]
new(pattern: &str, flags: &str) -> RegExp3003     pub fn new(pattern: &str, flags: &str) -> RegExp;
3004     #[wasm_bindgen(constructor)]
new_regexp(pattern: &RegExp, flags: &str) -> RegExp3005     pub fn new_regexp(pattern: &RegExp, flags: &str) -> RegExp;
3006 
3007     /// The non-standard rightContext property is a static and
3008     /// read-only property of regular expressions that contains the
3009     /// substring following 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/rightContext)
3013     #[wasm_bindgen(static_method_of = RegExp, getter, js_name = rightContext)]
right_context() -> JsString3014     pub fn right_context() -> JsString;
3015 
3016     /// The source property returns a String containing the source
3017     /// text of the regexp object, and it doesn't contain the two
3018     /// forward slashes on both sides and any flags.
3019     ///
3020     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/source)
3021     #[wasm_bindgen(method, getter)]
source(this: &RegExp) -> JsString3022     pub fn source(this: &RegExp) -> JsString;
3023 
3024     /// The sticky property reflects whether or not the search is
3025     /// sticky (searches in strings only from the index indicated by
3026     /// the lastIndex property of this regular expression). sticky is
3027     /// a read-only property of an individual regular expression
3028     /// object.
3029     ///
3030     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/sticky)
3031     #[wasm_bindgen(method, getter)]
sticky(this: &RegExp) -> bool3032     pub fn sticky(this: &RegExp) -> bool;
3033 
3034     /// The `test()` method executes a search for a match between a
3035     /// regular expression and a specified string. Returns true or
3036     /// false.
3037     ///
3038     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test)
3039     #[wasm_bindgen(method)]
test(this: &RegExp, text: &str) -> bool3040     pub fn test(this: &RegExp, text: &str) -> bool;
3041 
3042     /// The `toString()` method returns a string representing the
3043     /// regular expression.
3044     ///
3045     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/toString)
3046     #[wasm_bindgen(method, js_name = toString)]
to_string(this: &RegExp) -> JsString3047     pub fn to_string(this: &RegExp) -> JsString;
3048 
3049     /// The unicode property indicates whether or not the "u" flag is
3050     /// used with a regular expression. unicode is a read-only
3051     /// property of an individual regular expression instance.
3052     ///
3053     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/unicode)
3054     #[wasm_bindgen(method, getter)]
unicode(this: &RegExp) -> bool3055     pub fn unicode(this: &RegExp) -> bool;
3056 }
3057 
3058 // Set
3059 #[wasm_bindgen]
3060 extern "C" {
3061     #[wasm_bindgen(extends = Object)]
3062     #[derive(Clone, Debug, PartialEq, Eq)]
3063     pub type Set;
3064 
3065     /// The `add()` method appends a new element with a specified value to the
3066     /// end of a [`Set`] object.
3067     ///
3068     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/add)
3069     #[wasm_bindgen(method)]
add(this: &Set, value: &JsValue) -> Set3070     pub fn add(this: &Set, value: &JsValue) -> Set;
3071 
3072     /// The `clear()` method removes all elements from a [`Set`] object.
3073     ///
3074     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/clear)
3075     #[wasm_bindgen(method)]
clear(this: &Set)3076     pub fn clear(this: &Set);
3077 
3078     /// The `delete()` method removes the specified element from a [`Set`]
3079     /// object.
3080     ///
3081     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/delete)
3082     #[wasm_bindgen(method)]
delete(this: &Set, value: &JsValue) -> bool3083     pub fn delete(this: &Set, value: &JsValue) -> bool;
3084 
3085     /// The `forEach()` method executes a provided function once for each value
3086     /// in the Set object, in insertion order.
3087     ///
3088     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/forEach)
3089     #[wasm_bindgen(method, js_name = forEach)]
for_each(this: &Set, callback: &mut dyn FnMut(JsValue, JsValue, Set))3090     pub fn for_each(this: &Set, callback: &mut dyn FnMut(JsValue, JsValue, Set));
3091 
3092     /// The `has()` method returns a boolean indicating whether an element with
3093     /// the specified value exists in a [`Set`] object or not.
3094     ///
3095     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/has)
3096     #[wasm_bindgen(method)]
has(this: &Set, value: &JsValue) -> bool3097     pub fn has(this: &Set, value: &JsValue) -> bool;
3098 
3099     /// The [`Set`] object lets you store unique values of any type, whether
3100     /// primitive values or object references.
3101     ///
3102     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set)
3103     #[wasm_bindgen(constructor)]
new(init: &JsValue) -> Set3104     pub fn new(init: &JsValue) -> Set;
3105 
3106     /// The size accessor property returns the number of elements in a [`Set`]
3107     /// object.
3108     ///
3109     /// [MDN documentation](https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Set/size)
3110     #[wasm_bindgen(method, getter, structural)]
size(this: &Set) -> u323111     pub fn size(this: &Set) -> u32;
3112 }
3113 
3114 // SetIterator
3115 #[wasm_bindgen]
3116 extern "C" {
3117     /// The `entries()` method returns a new Iterator object that contains an
3118     /// array of [value, value] for each element in the Set object, in insertion
3119     /// order. For Set objects there is no key like in Map objects. However, to
3120     /// keep the API similar to the Map object, each entry has the same value
3121     /// for its key and value here, so that an array [value, value] is returned.
3122     ///
3123     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/entries)
3124     #[wasm_bindgen(method)]
entries(set: &Set) -> Iterator3125     pub fn entries(set: &Set) -> Iterator;
3126 
3127     /// The `keys()` method is an alias for this method (for similarity with
3128     /// Map objects); it behaves exactly the same and returns values
3129     /// of Set elements.
3130     ///
3131     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/values)
3132     #[wasm_bindgen(method)]
keys(set: &Set) -> Iterator3133     pub fn keys(set: &Set) -> Iterator;
3134 
3135     /// The `values()` method returns a new Iterator object that contains the
3136     /// values for each element in the Set object in insertion order.
3137     ///
3138     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/values)
3139     #[wasm_bindgen(method)]
values(set: &Set) -> Iterator3140     pub fn values(set: &Set) -> Iterator;
3141 }
3142 
3143 // SyntaxError
3144 #[wasm_bindgen]
3145 extern "C" {
3146     /// A `SyntaxError` is thrown when the JavaScript engine encounters tokens or
3147     /// token order that does not conform to the syntax of the language when
3148     /// parsing code.
3149     ///
3150     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError)
3151     #[wasm_bindgen(extends = Error, extends = Object)]
3152     #[derive(Clone, Debug, PartialEq, Eq)]
3153     pub type SyntaxError;
3154 
3155     /// A `SyntaxError` is thrown when the JavaScript engine encounters tokens or
3156     /// token order that does not conform to the syntax of the language when
3157     /// parsing code.
3158     ///
3159     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError)
3160     #[wasm_bindgen(constructor)]
new(message: &str) -> SyntaxError3161     pub fn new(message: &str) -> SyntaxError;
3162 }
3163 
3164 // TypeError
3165 #[wasm_bindgen]
3166 extern "C" {
3167     /// The `TypeError` object represents an error when a value is not of the
3168     /// expected type.
3169     ///
3170     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError)
3171     #[wasm_bindgen(extends = Error, extends = Object)]
3172     #[derive(Clone, Debug, PartialEq, Eq)]
3173     pub type TypeError;
3174 
3175     /// The `TypeError` object represents an error when a value is not of the
3176     /// expected type.
3177     ///
3178     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError)
3179     #[wasm_bindgen(constructor)]
new(message: &str) -> TypeError3180     pub fn new(message: &str) -> TypeError;
3181 }
3182 
3183 // URIError
3184 #[wasm_bindgen]
3185 extern "C" {
3186     /// The `URIError` object represents an error when a global URI handling
3187     /// function was used in a wrong way.
3188     ///
3189     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError)
3190     #[wasm_bindgen(extends = Error, extends = Object, js_name = URIError)]
3191     #[derive(Clone, Debug, PartialEq, Eq)]
3192     pub type UriError;
3193 
3194     /// The `URIError` object represents an error when a global URI handling
3195     /// function was used in a wrong way.
3196     ///
3197     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError)
3198     #[wasm_bindgen(constructor, js_class = "URIError")]
new(message: &str) -> UriError3199     pub fn new(message: &str) -> UriError;
3200 }
3201 
3202 // WeakMap
3203 #[wasm_bindgen]
3204 extern "C" {
3205     #[wasm_bindgen(extends = Object)]
3206     #[derive(Clone, Debug, PartialEq, Eq)]
3207     pub type WeakMap;
3208 
3209     /// The [`WeakMap`] object is a collection of key/value pairs in which the
3210     /// keys are weakly referenced.  The keys must be objects and the values can
3211     /// be arbitrary values.
3212     ///
3213     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap)
3214     #[wasm_bindgen(constructor)]
new() -> WeakMap3215     pub fn new() -> WeakMap;
3216 
3217     /// The `set()` method sets the value for the key in the [`WeakMap`] object.
3218     /// Returns the [`WeakMap`] object.
3219     ///
3220     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/set)
3221     #[wasm_bindgen(method, js_class = "WeakMap")]
set(this: &WeakMap, key: &Object, value: &JsValue) -> WeakMap3222     pub fn set(this: &WeakMap, key: &Object, value: &JsValue) -> WeakMap;
3223 
3224     /// The `get()` method returns a specified by key element
3225     /// from a [`WeakMap`] object.
3226     ///
3227     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/get)
3228     #[wasm_bindgen(method)]
get(this: &WeakMap, key: &Object) -> JsValue3229     pub fn get(this: &WeakMap, key: &Object) -> JsValue;
3230 
3231     /// The `has()` method returns a boolean indicating whether an element with
3232     /// the specified key exists in the [`WeakMap`] object or not.
3233     ///
3234     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/has)
3235     #[wasm_bindgen(method)]
has(this: &WeakMap, key: &Object) -> bool3236     pub fn has(this: &WeakMap, key: &Object) -> bool;
3237 
3238     /// The `delete()` method removes the specified element from a [`WeakMap`]
3239     /// object.
3240     ///
3241     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/delete)
3242     #[wasm_bindgen(method)]
delete(this: &WeakMap, key: &Object) -> bool3243     pub fn delete(this: &WeakMap, key: &Object) -> bool;
3244 }
3245 
3246 // WeakSet
3247 #[wasm_bindgen]
3248 extern "C" {
3249     #[wasm_bindgen(extends = Object)]
3250     #[derive(Clone, Debug, PartialEq, Eq)]
3251     pub type WeakSet;
3252 
3253     /// The `WeakSet` object lets you store weakly held objects in a collection.
3254     ///
3255     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet)
3256     #[wasm_bindgen(constructor)]
new() -> WeakSet3257     pub fn new() -> WeakSet;
3258 
3259     /// The `has()` method returns a boolean indicating whether an object exists
3260     /// in a WeakSet or not.
3261     ///
3262     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet/has)
3263     #[wasm_bindgen(method)]
has(this: &WeakSet, value: &Object) -> bool3264     pub fn has(this: &WeakSet, value: &Object) -> bool;
3265 
3266     /// The `add()` method appends a new object to the end of a WeakSet object.
3267     ///
3268     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet/add)
3269     #[wasm_bindgen(method)]
add(this: &WeakSet, value: &Object) -> WeakSet3270     pub fn add(this: &WeakSet, value: &Object) -> WeakSet;
3271 
3272     /// The `delete()` method removes the specified element from a WeakSet
3273     /// object.
3274     ///
3275     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet/delete)
3276     #[wasm_bindgen(method)]
delete(this: &WeakSet, value: &Object) -> bool3277     pub fn delete(this: &WeakSet, value: &Object) -> bool;
3278 }
3279 
3280 #[allow(non_snake_case)]
3281 pub mod WebAssembly {
3282     use super::*;
3283 
3284     // WebAssembly
3285     #[wasm_bindgen]
3286     extern "C" {
3287         /// The `WebAssembly.compile()` function compiles a `WebAssembly.Module`
3288         /// from WebAssembly binary code.  This function is useful if it is
3289         /// necessary to a compile a module before it can be instantiated
3290         /// (otherwise, the `WebAssembly.instantiate()` function should be used).
3291         ///
3292         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/compile)
3293         #[wasm_bindgen(js_namespace = WebAssembly)]
compile(buffer_source: &JsValue) -> Promise3294         pub fn compile(buffer_source: &JsValue) -> Promise;
3295 
3296         /// The `WebAssembly.instantiate()` function allows you to compile and
3297         /// instantiate WebAssembly code.
3298         ///
3299         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiate)
3300         #[wasm_bindgen(js_namespace = WebAssembly, js_name = instantiate)]
instantiate_buffer(buffer: &[u8], imports: &Object) -> Promise3301         pub fn instantiate_buffer(buffer: &[u8], imports: &Object) -> Promise;
3302 
3303         /// The `WebAssembly.instantiate()` function allows you to compile and
3304         /// instantiate WebAssembly code.
3305         ///
3306         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiate)
3307         #[wasm_bindgen(js_namespace = WebAssembly, js_name = instantiate)]
instantiate_module(module: &Module, imports: &Object) -> Promise3308         pub fn instantiate_module(module: &Module, imports: &Object) -> Promise;
3309 
3310         /// The `WebAssembly.instantiateStreaming()` function compiles and
3311         /// instantiates a WebAssembly module directly from a streamed
3312         /// underlying source. This is the most efficient, optimized way to load
3313         /// wasm code.
3314         ///
3315         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiateStreaming)
3316         #[wasm_bindgen(js_namespace = WebAssembly, js_name = instantiateStreaming)]
instantiate_streaming(response: &Promise, imports: &Object) -> Promise3317         pub fn instantiate_streaming(response: &Promise, imports: &Object) -> Promise;
3318 
3319         /// The `WebAssembly.validate()` function validates a given typed
3320         /// array of WebAssembly binary code, returning whether the bytes
3321         /// form a valid wasm module (`true`) or not (`false`).
3322         ///
3323         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/validate)
3324         #[wasm_bindgen(js_namespace = WebAssembly, catch)]
validate(buffer_source: &JsValue) -> Result<bool, JsValue>3325         pub fn validate(buffer_source: &JsValue) -> Result<bool, JsValue>;
3326     }
3327 
3328     // WebAssembly.CompileError
3329     #[wasm_bindgen]
3330     extern "C" {
3331         /// The `WebAssembly.CompileError()` constructor creates a new
3332         /// WebAssembly `CompileError` object, which indicates an error during
3333         /// WebAssembly decoding or validation.
3334         ///
3335         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/CompileError)
3336         #[wasm_bindgen(extends = Error, js_namespace = WebAssembly)]
3337         #[derive(Clone, Debug, PartialEq, Eq)]
3338         pub type CompileError;
3339 
3340         /// The `WebAssembly.CompileError()` constructor creates a new
3341         /// WebAssembly `CompileError` object, which indicates an error during
3342         /// WebAssembly decoding or validation.
3343         ///
3344         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/CompileError)
3345         #[wasm_bindgen(constructor, js_namespace = WebAssembly)]
new(message: &str) -> CompileError3346         pub fn new(message: &str) -> CompileError;
3347     }
3348 
3349     // WebAssembly.Instance
3350     #[wasm_bindgen]
3351     extern "C" {
3352         /// A `WebAssembly.Instance` object is a stateful, executable instance
3353         /// of a `WebAssembly.Module`. Instance objects contain all the exported
3354         /// WebAssembly functions that allow calling into WebAssembly code from
3355         /// JavaScript.
3356         ///
3357         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance)
3358         #[wasm_bindgen(extends = Object, js_namespace = WebAssembly)]
3359         #[derive(Clone, Debug, PartialEq, Eq)]
3360         pub type Instance;
3361 
3362         /// The `WebAssembly.Instance()` constructor function can be called to
3363         /// synchronously instantiate a given `WebAssembly.Module`
3364         /// object. However, the primary way to get an `Instance` is through the
3365         /// asynchronous `WebAssembly.instantiateStreaming()` function.
3366         ///
3367         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance)
3368         #[wasm_bindgen(catch, constructor, js_namespace = WebAssembly)]
new(module: &Module, imports: &Object) -> Result<Instance, JsValue>3369         pub fn new(module: &Module, imports: &Object) -> Result<Instance, JsValue>;
3370 
3371         /// The `exports` readonly property of the `WebAssembly.Instance` object
3372         /// prototype returns an object containing as its members all the
3373         /// functions exported from the WebAssembly module instance, to allow
3374         /// them to be accessed and used by JavaScript.
3375         ///
3376         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance/exports)
3377         #[wasm_bindgen(getter, method, js_namespace = WebAssembly)]
exports(this: &Instance) -> Object3378         pub fn exports(this: &Instance) -> Object;
3379     }
3380 
3381     // WebAssembly.LinkError
3382     #[wasm_bindgen]
3383     extern "C" {
3384         /// The `WebAssembly.LinkError()` constructor creates a new WebAssembly
3385         /// LinkError object, which indicates an error during module
3386         /// instantiation (besides traps from the start function).
3387         ///
3388         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/LinkError)
3389         #[wasm_bindgen(extends = Error, js_namespace = WebAssembly)]
3390         #[derive(Clone, Debug, PartialEq, Eq)]
3391         pub type LinkError;
3392 
3393         /// The `WebAssembly.LinkError()` constructor creates a new WebAssembly
3394         /// LinkError object, which indicates an error during module
3395         /// instantiation (besides traps from the start function).
3396         ///
3397         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/LinkError)
3398         #[wasm_bindgen(constructor, js_namespace = WebAssembly)]
new(message: &str) -> LinkError3399         pub fn new(message: &str) -> LinkError;
3400     }
3401 
3402     // WebAssembly.RuntimeError
3403     #[wasm_bindgen]
3404     extern "C" {
3405         /// The `WebAssembly.RuntimeError()` constructor creates a new WebAssembly
3406         /// `RuntimeError` object — the type that is thrown whenever WebAssembly
3407         /// specifies a trap.
3408         ///
3409         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/RuntimeError)
3410         #[wasm_bindgen(extends = Error, js_namespace = WebAssembly)]
3411         #[derive(Clone, Debug, PartialEq, Eq)]
3412         pub type RuntimeError;
3413 
3414         /// The `WebAssembly.RuntimeError()` constructor creates a new WebAssembly
3415         /// `RuntimeError` object — the type that is thrown whenever WebAssembly
3416         /// specifies a trap.
3417         ///
3418         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/RuntimeError)
3419         #[wasm_bindgen(constructor, js_namespace = WebAssembly)]
new(message: &str) -> RuntimeError3420         pub fn new(message: &str) -> RuntimeError;
3421     }
3422 
3423     // WebAssembly.Module
3424     #[wasm_bindgen]
3425     extern "C" {
3426         /// A `WebAssembly.Module` object contains stateless WebAssembly code
3427         /// that has already been compiled by the browser and can be
3428         /// efficiently shared with Workers, and instantiated multiple times.
3429         ///
3430         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module)
3431         #[wasm_bindgen(js_namespace = WebAssembly, extends = Object)]
3432         #[derive(Clone, Debug, PartialEq, Eq)]
3433         pub type Module;
3434 
3435         /// A `WebAssembly.Module` object contains stateless WebAssembly code
3436         /// that has already been compiled by the browser and can be
3437         /// efficiently shared with Workers, and instantiated multiple times.
3438         ///
3439         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module)
3440         #[wasm_bindgen(constructor, js_namespace = WebAssembly, catch)]
new(buffer_source: &JsValue) -> Result<Module, JsValue>3441         pub fn new(buffer_source: &JsValue) -> Result<Module, JsValue>;
3442 
3443         /// The `WebAssembly.customSections()` function returns a copy of the
3444         /// contents of all custom sections in the given module with the given
3445         /// string name.
3446         ///
3447         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module/customSections)
3448         #[wasm_bindgen(static_method_of = Module, js_namespace = WebAssembly, js_name = customSections)]
custom_sections(module: &Module, sectionName: &str) -> Array3449         pub fn custom_sections(module: &Module, sectionName: &str) -> Array;
3450 
3451         /// The `WebAssembly.exports()` function returns an array containing
3452         /// descriptions of all the declared exports of the given `Module`.
3453         ///
3454         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module/exports)
3455         #[wasm_bindgen(static_method_of = Module, js_namespace = WebAssembly)]
exports(module: &Module) -> Array3456         pub fn exports(module: &Module) -> Array;
3457 
3458         /// The `WebAssembly.imports()` function returns an array containing
3459         /// descriptions of all the declared imports of the given `Module`.
3460         ///
3461         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module/imports)
3462         #[wasm_bindgen(static_method_of = Module, js_namespace = WebAssembly)]
imports(module: &Module) -> Array3463         pub fn imports(module: &Module) -> Array;
3464     }
3465 
3466     // WebAssembly.Table
3467     #[wasm_bindgen]
3468     extern "C" {
3469         /// The `WebAssembly.Table()` constructor creates a new `Table` object
3470         /// of the given size and element type.
3471         ///
3472         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table)
3473         #[wasm_bindgen(js_namespace = WebAssembly, extends = Object)]
3474         #[derive(Clone, Debug, PartialEq, Eq)]
3475         pub type Table;
3476 
3477         /// The `WebAssembly.Table()` constructor creates a new `Table` object
3478         /// of the given size and element type.
3479         ///
3480         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table)
3481         #[wasm_bindgen(constructor, js_namespace = WebAssembly, catch)]
new(table_descriptor: &Object) -> Result<Table, JsValue>3482         pub fn new(table_descriptor: &Object) -> Result<Table, JsValue>;
3483 
3484         /// The length prototype property of the `WebAssembly.Table` object
3485         /// returns the length of the table, i.e. the number of elements in the
3486         /// table.
3487         ///
3488         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/length)
3489         #[wasm_bindgen(method, getter, js_namespace = WebAssembly)]
length(this: &Table) -> u323490         pub fn length(this: &Table) -> u32;
3491 
3492         /// The `get()` prototype method of the `WebAssembly.Table()` object
3493         /// retrieves a function reference stored at a given index.
3494         ///
3495         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/get)
3496         #[wasm_bindgen(method, catch, js_namespace = WebAssembly)]
get(this: &Table, index: u32) -> Result<Function, JsValue>3497         pub fn get(this: &Table, index: u32) -> Result<Function, JsValue>;
3498 
3499         /// The `grow()` prototype method of the `WebAssembly.Table` object
3500         /// increases the size of the `Table` instance by a specified number of
3501         /// elements.
3502         ///
3503         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/grow)
3504         #[wasm_bindgen(method, catch, js_namespace = WebAssembly)]
grow(this: &Table, additional_capacity: u32) -> Result<u32, JsValue>3505         pub fn grow(this: &Table, additional_capacity: u32) -> Result<u32, JsValue>;
3506 
3507         /// The `set()` prototype method of the `WebAssembly.Table` object mutates a
3508         /// reference stored at a given index to a different value.
3509         ///
3510         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/set)
3511         #[wasm_bindgen(method, catch, js_namespace = WebAssembly)]
set(this: &Table, index: u32, function: &Function) -> Result<(), JsValue>3512         pub fn set(this: &Table, index: u32, function: &Function) -> Result<(), JsValue>;
3513     }
3514 
3515     // WebAssembly.Memory
3516     #[wasm_bindgen]
3517     extern "C" {
3518         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory)
3519         #[wasm_bindgen(js_namespace = WebAssembly, extends = Object)]
3520         #[derive(Clone, Debug, PartialEq, Eq)]
3521         pub type Memory;
3522 
3523         /// The `WebAssembly.Memory()` constructor creates a new `Memory` object
3524         /// which is a resizable `ArrayBuffer` that holds the raw bytes of
3525         /// memory accessed by a WebAssembly `Instance`.
3526         ///
3527         /// A memory created by JavaScript or in WebAssembly code will be
3528         /// accessible and mutable from both JavaScript and WebAssembly.
3529         ///
3530         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory)
3531         #[wasm_bindgen(constructor, js_namespace = WebAssembly, catch)]
new(descriptor: &Object) -> Result<Memory, JsValue>3532         pub fn new(descriptor: &Object) -> Result<Memory, JsValue>;
3533 
3534         /// An accessor property that returns the buffer contained in the
3535         /// memory.
3536         ///
3537         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory/buffer)
3538         #[wasm_bindgen(method, getter, js_namespace = WebAssembly)]
buffer(this: &Memory) -> JsValue3539         pub fn buffer(this: &Memory) -> JsValue;
3540 
3541         /// The `grow()` protoype method of the `Memory` object increases the
3542         /// size of the memory instance by a specified number of WebAssembly
3543         /// pages.
3544         ///
3545         /// Takes the number of pages to grow (64KiB in size) and returns the
3546         /// previous size of memory, in pages.
3547         ///
3548         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory/grow)
3549         #[wasm_bindgen(method, js_namespace = WebAssembly)]
grow(this: &Memory, pages: u32) -> u323550         pub fn grow(this: &Memory, pages: u32) -> u32;
3551     }
3552 }
3553 
3554 /// The `JSON` object contains methods for parsing [JavaScript Object
3555 /// Notation (JSON)](https://json.org/) and converting values to JSON. It
3556 /// can't be called or constructed, and aside from its two method
3557 /// properties, it has no interesting functionality of its own.
3558 #[allow(non_snake_case)]
3559 pub mod JSON {
3560     use super::*;
3561 
3562     // JSON
3563     #[wasm_bindgen]
3564     extern "C" {
3565         /// The `JSON.parse()` method parses a JSON string, constructing the
3566         /// JavaScript value or object described by the string.
3567         ///
3568         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse)
3569         #[wasm_bindgen(catch, js_namespace = JSON)]
parse(text: &str) -> Result<JsValue, JsValue>3570         pub fn parse(text: &str) -> Result<JsValue, JsValue>;
3571 
3572         /// The `JSON.stringify()` method converts a JavaScript value to a JSON string.
3573         ///
3574         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)
3575         #[wasm_bindgen(catch, js_namespace = JSON)]
stringify(obj: &JsValue) -> Result<JsString, JsValue>3576         pub fn stringify(obj: &JsValue) -> Result<JsString, JsValue>;
3577 
3578         /// The `JSON.stringify()` method converts a JavaScript value to a JSON string.
3579         ///
3580         /// The `replacer` argument is a function that alters the behavior of the stringification
3581         /// process, or an array of String and Number objects that serve as a whitelist
3582         /// for selecting/filtering the properties of the value object to be included
3583         /// in the JSON string. If this value is null or not provided, all properties
3584         /// of the object are included in the resulting JSON string.
3585         ///
3586         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)
3587         #[wasm_bindgen(catch, js_namespace = JSON, js_name = stringify)]
stringify_with_replacer( obj: &JsValue, replacer: &JsValue, ) -> Result<JsString, JsValue>3588         pub fn stringify_with_replacer(
3589             obj: &JsValue,
3590             replacer: &JsValue,
3591         ) -> Result<JsString, JsValue>;
3592 
3593         /// The `JSON.stringify()` method converts a JavaScript value to a JSON string.
3594         ///
3595         /// The `replacer` argument is a function that alters the behavior of the stringification
3596         /// process, or an array of String and Number objects that serve as a whitelist
3597         /// for selecting/filtering the properties of the value object to be included
3598         /// in the JSON string. If this value is null or not provided, all properties
3599         /// of the object are included in the resulting JSON string.
3600         ///
3601         /// The `space` argument is a String or Number object that's used to insert white space into
3602         /// the output JSON string for readability purposes. If this is a Number, it
3603         /// indicates the number of space characters to use as white space; this number
3604         /// is capped at 10 (if it is greater, the value is just 10). Values less than
3605         /// 1 indicate that no space should be used. If this is a String, the string
3606         /// (or the first 10 characters of the string, if it's longer than that) is
3607         /// used as white space. If this parameter is not provided (or is null), no
3608         /// white space is used.
3609         ///
3610         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)
3611         #[wasm_bindgen(catch, js_namespace = JSON, js_name = stringify)]
stringify_with_replacer_and_space( obj: &JsValue, replacer: &JsValue, space: &JsValue, ) -> Result<JsString, JsValue>3612         pub fn stringify_with_replacer_and_space(
3613             obj: &JsValue,
3614             replacer: &JsValue,
3615             space: &JsValue,
3616         ) -> Result<JsString, JsValue>;
3617 
3618     }
3619 }
3620 
3621 // JsString
3622 #[wasm_bindgen]
3623 extern "C" {
3624     #[wasm_bindgen(js_name = String, extends = Object, is_type_of = JsValue::is_string)]
3625     #[derive(Clone, PartialEq, Eq)]
3626     pub type JsString;
3627 
3628     /// The length property of a String object indicates the length of a string,
3629     /// in UTF-16 code units.
3630     ///
3631     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length)
3632     #[wasm_bindgen(method, getter, structural)]
length(this: &JsString) -> u323633     pub fn length(this: &JsString) -> u32;
3634 
3635     /// The String object's `charAt()` method returns a new string consisting of
3636     /// the single UTF-16 code unit located at the specified offset into the
3637     /// string.
3638     ///
3639     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charAt)
3640     #[wasm_bindgen(method, js_class = "String", js_name = charAt)]
char_at(this: &JsString, index: u32) -> JsString3641     pub fn char_at(this: &JsString, index: u32) -> JsString;
3642 
3643     /// The `charCodeAt()` method returns an integer between 0 and 65535
3644     /// representing the UTF-16 code unit at the given index (the UTF-16 code
3645     /// unit matches the Unicode code point for code points representable in a
3646     /// single UTF-16 code unit, but might also be the first code unit of a
3647     /// surrogate pair for code points not representable in a single UTF-16 code
3648     /// unit, e.g. Unicode code points > 0x10000).  If you want the entire code
3649     /// point value, use `codePointAt()`.
3650     ///
3651     /// Returns `NaN` if index is out of range.
3652     ///
3653     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charCodeAt)
3654     #[wasm_bindgen(method, js_class = "String", js_name = charCodeAt)]
char_code_at(this: &JsString, index: u32) -> f643655     pub fn char_code_at(this: &JsString, index: u32) -> f64;
3656 
3657     /// The `codePointAt()` method returns a non-negative integer that is the
3658     /// Unicode code point value.
3659     ///
3660     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt)
3661     #[wasm_bindgen(method, js_class = "String", js_name = codePointAt)]
code_point_at(this: &JsString, pos: u32) -> JsValue3662     pub fn code_point_at(this: &JsString, pos: u32) -> JsValue;
3663 
3664     /// The `concat()` method concatenates the string arguments to the calling
3665     /// string and returns a new string.
3666     ///
3667     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/concat)
3668     #[wasm_bindgen(method, js_class = "String")]
concat(this: &JsString, string_2: &JsValue) -> JsString3669     pub fn concat(this: &JsString, string_2: &JsValue) -> JsString;
3670 
3671     /// The `endsWith()` method determines whether a string ends with the characters of a
3672     /// specified string, returning true or false as appropriate.
3673     ///
3674     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith)
3675     #[wasm_bindgen(method, js_class = "String", js_name = endsWith)]
ends_with(this: &JsString, search_string: &str, length: i32) -> bool3676     pub fn ends_with(this: &JsString, search_string: &str, length: i32) -> bool;
3677 
3678     /// The static `String.fromCharCode()` method returns a string created from
3679     /// the specified sequence of UTF-16 code units.
3680     ///
3681     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
3682     ///
3683     /// # Notes
3684     ///
3685     /// There are a few bindings to `from_char_code` in `js-sys`: `from_char_code1`, `from_char_code2`, etc...
3686     /// with different arities.
3687     ///
3688     /// Additionally, this function accepts `u16` for character codes, but
3689     /// fixing others requires a breaking change release
3690     /// (see https://github.com/rustwasm/wasm-bindgen/issues/1460 for details).
3691     #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode, variadic)]
from_char_code(char_codes: &[u16]) -> JsString3692     pub fn from_char_code(char_codes: &[u16]) -> JsString;
3693 
3694     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
3695     #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)]
from_char_code1(a: u32) -> JsString3696     pub fn from_char_code1(a: u32) -> JsString;
3697 
3698     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
3699     #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)]
from_char_code2(a: u32, b: u32) -> JsString3700     pub fn from_char_code2(a: u32, b: u32) -> JsString;
3701 
3702     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
3703     #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)]
from_char_code3(a: u32, b: u32, c: u32) -> JsString3704     pub fn from_char_code3(a: u32, b: u32, c: u32) -> JsString;
3705 
3706     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
3707     #[wasm_bindgen(static_method_of = JsString, js_class = "String", js_name = fromCharCode)]
from_char_code4(a: u32, b: u32, c: u32, d: u32) -> JsString3708     pub fn from_char_code4(a: u32, b: u32, c: u32, d: u32) -> JsString;
3709 
3710     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)
3711     #[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) -> JsString3712     pub fn from_char_code5(a: u32, b: u32, c: u32, d: u32, e: u32) -> JsString;
3713 
3714     /// The static `String.fromCodePoint()` method returns a string created by
3715     /// using the specified sequence of code points.
3716     ///
3717     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)
3718     ///
3719     /// # Exceptions
3720     ///
3721     /// A RangeError is thrown if an invalid Unicode code point is given
3722     ///
3723     /// # Notes
3724     ///
3725     /// There are a few bindings to `from_code_point` in `js-sys`: `from_code_point1`, `from_code_point2`, etc...
3726     /// with different arities.
3727     #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = fromCodePoint, variadic)]
from_code_point(code_points: &[u32]) -> Result<JsString, JsValue>3728     pub fn from_code_point(code_points: &[u32]) -> Result<JsString, JsValue>;
3729 
3730     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)
3731     #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = fromCodePoint)]
from_code_point1(a: u32) -> Result<JsString, JsValue>3732     pub fn from_code_point1(a: u32) -> Result<JsString, JsValue>;
3733 
3734     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)
3735     #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = fromCodePoint)]
from_code_point2(a: u32, b: u32) -> Result<JsString, JsValue>3736     pub fn from_code_point2(a: u32, b: u32) -> Result<JsString, JsValue>;
3737 
3738     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)
3739     #[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>3740     pub fn from_code_point3(a: u32, b: u32, c: u32) -> Result<JsString, JsValue>;
3741 
3742     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)
3743     #[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>3744     pub fn from_code_point4(a: u32, b: u32, c: u32, d: u32) -> Result<JsString, JsValue>;
3745 
3746     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)
3747     #[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>3748     pub fn from_code_point5(a: u32, b: u32, c: u32, d: u32, e: u32) -> Result<JsString, JsValue>;
3749 
3750     /// The `includes()` method determines whether one string may be found
3751     /// within another string, returning true or false as appropriate.
3752     ///
3753     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes)
3754     #[wasm_bindgen(method, js_class = "String")]
includes(this: &JsString, search_string: &str, position: i32) -> bool3755     pub fn includes(this: &JsString, search_string: &str, position: i32) -> bool;
3756 
3757     /// The `indexOf()` method returns the index within the calling String
3758     /// object of the first occurrence of the specified value, starting the
3759     /// search at fromIndex.  Returns -1 if the value is not found.
3760     ///
3761     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf)
3762     #[wasm_bindgen(method, js_class = "String", js_name = indexOf)]
index_of(this: &JsString, search_value: &str, from_index: i32) -> i323763     pub fn index_of(this: &JsString, search_value: &str, from_index: i32) -> i32;
3764 
3765     /// The `lastIndexOf()` method returns the index within the calling String
3766     /// object of the last occurrence of the specified value, searching
3767     /// backwards from fromIndex.  Returns -1 if the value is not found.
3768     ///
3769     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/lastIndexOf)
3770     #[wasm_bindgen(method, js_class = "String", js_name = lastIndexOf)]
last_index_of(this: &JsString, search_value: &str, from_index: i32) -> i323771     pub fn last_index_of(this: &JsString, search_value: &str, from_index: i32) -> i32;
3772 
3773     /// The `localeCompare()` method returns a number indicating whether
3774     /// a reference string comes before or after or is the same as
3775     /// the given string in sort order.
3776     ///
3777     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare)
3778     #[wasm_bindgen(method, js_class = "String", js_name = localeCompare)]
locale_compare( this: &JsString, compare_string: &str, locales: &Array, options: &Object, ) -> i323779     pub fn locale_compare(
3780         this: &JsString,
3781         compare_string: &str,
3782         locales: &Array,
3783         options: &Object,
3784     ) -> i32;
3785 
3786     /// The `match()` method retrieves the matches when matching a string against a regular expression.
3787     ///
3788     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match)
3789     #[wasm_bindgen(method, js_class = "String", js_name = match)]
match_(this: &JsString, pattern: &RegExp) -> Option<Object>3790     pub fn match_(this: &JsString, pattern: &RegExp) -> Option<Object>;
3791 
3792     /// The `normalize()` method returns the Unicode Normalization Form
3793     /// of a given string (if the value isn't a string, it will be converted to one first).
3794     ///
3795     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize)
3796     #[wasm_bindgen(method, js_class = "String")]
normalize(this: &JsString, form: &str) -> JsString3797     pub fn normalize(this: &JsString, form: &str) -> JsString;
3798 
3799     /// The `padEnd()` method pads the current string with a given string
3800     /// (repeated, if needed) so that the resulting string reaches a given
3801     /// length. The padding is applied from the end (right) of the current
3802     /// string.
3803     ///
3804     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padEnd)
3805     #[wasm_bindgen(method, js_class = "String", js_name = padEnd)]
pad_end(this: &JsString, target_length: u32, pad_string: &str) -> JsString3806     pub fn pad_end(this: &JsString, target_length: u32, pad_string: &str) -> JsString;
3807 
3808     /// The `padStart()` method pads the current string with another string
3809     /// (repeated, if needed) so that the resulting string reaches the given
3810     /// length. The padding is applied from the start (left) of the current
3811     /// string.
3812     ///
3813     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padStart)
3814     #[wasm_bindgen(method, js_class = "String", js_name = padStart)]
pad_start(this: &JsString, target_length: u32, pad_string: &str) -> JsString3815     pub fn pad_start(this: &JsString, target_length: u32, pad_string: &str) -> JsString;
3816 
3817     /// The `repeat()` method constructs and returns a new string which contains the specified
3818     /// number of copies of the string on which it was called, concatenated together.
3819     ///
3820     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat)
3821     #[wasm_bindgen(method, js_class = "String")]
repeat(this: &JsString, count: i32) -> JsString3822     pub fn repeat(this: &JsString, count: i32) -> JsString;
3823 
3824     /// The `replace()` method returns a new string with some or all matches of a pattern
3825     /// replaced by a replacement. The pattern can be a string or a RegExp, and
3826     /// the replacement can be a string or a function to be called for each match.
3827     ///
3828     /// Note: The original string will remain unchanged.
3829     ///
3830     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace)
3831     #[wasm_bindgen(method, js_class = "String")]
replace(this: &JsString, pattern: &str, replacement: &str) -> JsString3832     pub fn replace(this: &JsString, pattern: &str, replacement: &str) -> JsString;
3833 
3834     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace)
3835     #[wasm_bindgen(method, js_class = "String", js_name = replace)]
replace_with_function( this: &JsString, pattern: &str, replacement: &Function, ) -> JsString3836     pub fn replace_with_function(
3837         this: &JsString,
3838         pattern: &str,
3839         replacement: &Function,
3840     ) -> JsString;
3841 
3842     #[wasm_bindgen(method, js_class = "String", js_name = replace)]
replace_by_pattern(this: &JsString, pattern: &RegExp, replacement: &str) -> JsString3843     pub fn replace_by_pattern(this: &JsString, pattern: &RegExp, replacement: &str) -> JsString;
3844 
3845     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace)
3846     #[wasm_bindgen(method, js_class = "String", js_name = replace)]
replace_by_pattern_with_function( this: &JsString, pattern: &RegExp, replacement: &Function, ) -> JsString3847     pub fn replace_by_pattern_with_function(
3848         this: &JsString,
3849         pattern: &RegExp,
3850         replacement: &Function,
3851     ) -> JsString;
3852 
3853     /// The `search()` method executes a search for a match between
3854     /// a regular expression and this String object.
3855     ///
3856     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/search)
3857     #[wasm_bindgen(method, js_class = "String")]
search(this: &JsString, pattern: &RegExp) -> i323858     pub fn search(this: &JsString, pattern: &RegExp) -> i32;
3859 
3860     /// The `slice()` method extracts a section of a string and returns it as a
3861     /// new string, without modifying the original string.
3862     ///
3863     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice)
3864     #[wasm_bindgen(method, js_class = "String")]
slice(this: &JsString, start: u32, end: u32) -> JsString3865     pub fn slice(this: &JsString, start: u32, end: u32) -> JsString;
3866 
3867     /// The `split()` method splits a String object into an array of strings by separating the string
3868     /// into substrings, using a specified separator string to determine where to make each split.
3869     ///
3870     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split)
3871     #[wasm_bindgen(method, js_class = "String")]
split(this: &JsString, separator: &str) -> Array3872     pub fn split(this: &JsString, separator: &str) -> Array;
3873 
3874     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split)
3875     #[wasm_bindgen(method, js_class = "String", js_name = split)]
split_limit(this: &JsString, separator: &str, limit: u32) -> Array3876     pub fn split_limit(this: &JsString, separator: &str, limit: u32) -> Array;
3877 
3878     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split)
3879     #[wasm_bindgen(method, js_class = "String", js_name = split)]
split_by_pattern(this: &JsString, pattern: &RegExp) -> Array3880     pub fn split_by_pattern(this: &JsString, pattern: &RegExp) -> Array;
3881 
3882     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split)
3883     #[wasm_bindgen(method, js_class = "String", js_name = split)]
split_by_pattern_limit(this: &JsString, pattern: &RegExp, limit: u32) -> Array3884     pub fn split_by_pattern_limit(this: &JsString, pattern: &RegExp, limit: u32) -> Array;
3885 
3886     /// The `startsWith()` method determines whether a string begins with the
3887     /// characters of a specified string, returning true or false as
3888     /// appropriate.
3889     ///
3890     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith)
3891     #[wasm_bindgen(method, js_class = "String", js_name = startsWith)]
starts_with(this: &JsString, search_string: &str, position: u32) -> bool3892     pub fn starts_with(this: &JsString, search_string: &str, position: u32) -> bool;
3893 
3894     /// The `substring()` method returns the part of the string between the
3895     /// start and end indexes, or to the end of the string.
3896     ///
3897     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring)
3898     #[wasm_bindgen(method, js_class = "String")]
substring(this: &JsString, index_start: u32, index_end: u32) -> JsString3899     pub fn substring(this: &JsString, index_start: u32, index_end: u32) -> JsString;
3900 
3901     /// The `substr()` method returns the part of a string between
3902     /// the start index and a number of characters after it.
3903     ///
3904     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr)
3905     #[wasm_bindgen(method, js_class = "String")]
substr(this: &JsString, start: i32, length: i32) -> JsString3906     pub fn substr(this: &JsString, start: i32, length: i32) -> JsString;
3907 
3908     /// The `toLocaleLowerCase()` method returns the calling string value converted to lower case,
3909     /// according to any locale-specific case mappings.
3910     ///
3911     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase)
3912     #[wasm_bindgen(method, js_class = "String", js_name = toLocaleLowerCase)]
to_locale_lower_case(this: &JsString, locale: Option<&str>) -> JsString3913     pub fn to_locale_lower_case(this: &JsString, locale: Option<&str>) -> JsString;
3914 
3915     /// The `toLocaleUpperCase()` method returns the calling string value converted to upper case,
3916     /// according to any locale-specific case mappings.
3917     ///
3918     /// [MDN documentation](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleUpperCase)
3919     #[wasm_bindgen(method, js_class = "String", js_name = toLocaleUpperCase)]
to_locale_upper_case(this: &JsString, locale: Option<&str>) -> JsString3920     pub fn to_locale_upper_case(this: &JsString, locale: Option<&str>) -> JsString;
3921 
3922     /// The `toLowerCase()` method returns the calling string value
3923     /// converted to lower case.
3924     ///
3925     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLowerCase)
3926     #[wasm_bindgen(method, js_class = "String", js_name = toLowerCase)]
to_lower_case(this: &JsString) -> JsString3927     pub fn to_lower_case(this: &JsString) -> JsString;
3928 
3929     /// The `toString()` method returns a string representing the specified
3930     /// object.
3931     ///
3932     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toString)
3933     #[wasm_bindgen(method, js_class = "String", js_name = toString)]
to_string(this: &JsString) -> JsString3934     pub fn to_string(this: &JsString) -> JsString;
3935 
3936     /// The `toUpperCase()` method returns the calling string value converted to
3937     /// uppercase (the value will be converted to a string if it isn't one).
3938     ///
3939     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase)
3940     #[wasm_bindgen(method, js_class = "String", js_name = toUpperCase)]
to_upper_case(this: &JsString) -> JsString3941     pub fn to_upper_case(this: &JsString) -> JsString;
3942 
3943     /// The `trim()` method removes whitespace from both ends of a string.
3944     /// Whitespace in this context is all the whitespace characters (space, tab,
3945     /// no-break space, etc.) and all the line terminator characters (LF, CR,
3946     /// etc.).
3947     ///
3948     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trim)
3949     #[wasm_bindgen(method, js_class = "String")]
trim(this: &JsString) -> JsString3950     pub fn trim(this: &JsString) -> JsString;
3951 
3952     /// The `trimEnd()` method removes whitespace from the end of a string.
3953     /// `trimRight()` is an alias of this method.
3954     ///
3955     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimEnd)
3956     #[wasm_bindgen(method, js_class = "String", js_name = trimEnd)]
trim_end(this: &JsString) -> JsString3957     pub fn trim_end(this: &JsString) -> JsString;
3958 
3959     /// The `trimEnd()` method removes whitespace from the end of a string.
3960     /// `trimRight()` is an alias of this method.
3961     ///
3962     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimEnd)
3963     #[wasm_bindgen(method, js_class = "String", js_name = trimRight)]
trim_right(this: &JsString) -> JsString3964     pub fn trim_right(this: &JsString) -> JsString;
3965 
3966     /// The `trimStart()` method removes whitespace from the beginning of a
3967     /// string. `trimLeft()` is an alias of this method.
3968     ///
3969     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimStart)
3970     #[wasm_bindgen(method, js_class = "String", js_name = trimStart)]
trim_start(this: &JsString) -> JsString3971     pub fn trim_start(this: &JsString) -> JsString;
3972 
3973     /// The `trimStart()` method removes whitespace from the beginning of a
3974     /// string. `trimLeft()` is an alias of this method.
3975     ///
3976     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimStart)
3977     #[wasm_bindgen(method, js_class = "String", js_name = trimLeft)]
trim_left(this: &JsString) -> JsString3978     pub fn trim_left(this: &JsString) -> JsString;
3979 
3980     /// The `valueOf()` method returns the primitive value of a `String` object.
3981     ///
3982     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/valueOf)
3983     #[wasm_bindgen(method, js_class = "String", js_name = valueOf)]
value_of(this: &JsString) -> JsString3984     pub fn value_of(this: &JsString) -> JsString;
3985 
3986     /// The static `raw()` method is a tag function of template literals,
3987     /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
3988     ///
3989     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
3990     #[wasm_bindgen(catch, variadic, static_method_of = JsString, js_class = "String")]
raw(call_site: &Object, substitutions: &Array) -> Result<JsString, JsValue>3991     pub fn raw(call_site: &Object, substitutions: &Array) -> Result<JsString, JsValue>;
3992 
3993     /// The static `raw()` method is a tag function of template literals,
3994     /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
3995     ///
3996     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
3997     #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = raw)]
raw_0(call_site: &Object) -> Result<JsString, JsValue>3998     pub fn raw_0(call_site: &Object) -> Result<JsString, JsValue>;
3999 
4000     /// The static `raw()` method is a tag function of template literals,
4001     /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
4002     ///
4003     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
4004     #[wasm_bindgen(catch, static_method_of = JsString, js_class = "String", js_name = raw)]
raw_1(call_site: &Object, substitutions_1: &str) -> Result<JsString, JsValue>4005     pub fn raw_1(call_site: &Object, substitutions_1: &str) -> Result<JsString, JsValue>;
4006 
4007     /// The static `raw()` method is a tag function of template literals,
4008     /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
4009     ///
4010     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
4011     #[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>4012     pub fn raw_2(
4013         call_site: &Object,
4014         substitutions_1: &str,
4015         substitutions_2: &str,
4016     ) -> Result<JsString, JsValue>;
4017 
4018     /// The static `raw()` method is a tag function of template literals,
4019     /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
4020     ///
4021     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
4022     #[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>4023     pub fn raw_3(
4024         call_site: &Object,
4025         substitutions_1: &str,
4026         substitutions_2: &str,
4027         substitutions_3: &str,
4028     ) -> Result<JsString, JsValue>;
4029 
4030     /// The static `raw()` method is a tag function of template literals,
4031     /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
4032     ///
4033     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
4034     #[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>4035     pub fn raw_4(
4036         call_site: &Object,
4037         substitutions_1: &str,
4038         substitutions_2: &str,
4039         substitutions_3: &str,
4040         substitutions_4: &str,
4041     ) -> Result<JsString, JsValue>;
4042 
4043     /// The static `raw()` method is a tag function of template literals,
4044     /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
4045     ///
4046     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
4047     #[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>4048     pub fn raw_5(
4049         call_site: &Object,
4050         substitutions_1: &str,
4051         substitutions_2: &str,
4052         substitutions_3: &str,
4053         substitutions_4: &str,
4054         substitutions_5: &str,
4055     ) -> Result<JsString, JsValue>;
4056 
4057     /// The static `raw()` method is a tag function of template literals,
4058     /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
4059     ///
4060     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
4061     #[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>4062     pub fn raw_6(
4063         call_site: &Object,
4064         substitutions_1: &str,
4065         substitutions_2: &str,
4066         substitutions_3: &str,
4067         substitutions_4: &str,
4068         substitutions_5: &str,
4069         substitutions_6: &str,
4070     ) -> Result<JsString, JsValue>;
4071 
4072     /// The static `raw()` method is a tag function of template literals,
4073     /// similar to the `r` prefix in Python or the `@` prefix in C# for string literals.
4074     ///
4075     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
4076     #[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>4077     pub fn raw_7(
4078         call_site: &Object,
4079         substitutions_1: &str,
4080         substitutions_2: &str,
4081         substitutions_3: &str,
4082         substitutions_4: &str,
4083         substitutions_5: &str,
4084         substitutions_6: &str,
4085         substitutions_7: &str,
4086     ) -> Result<JsString, JsValue>;
4087 }
4088 
4089 impl JsString {
4090     /// Returns the `JsString` value of this JS value if it's an instance of a
4091     /// string.
4092     ///
4093     /// If this JS value is not an instance of a string then this returns
4094     /// `None`.
4095     #[deprecated(note = "recommended to use dyn_ref instead which is now equivalent")]
try_from(val: &JsValue) -> Option<&JsString>4096     pub fn try_from(val: &JsValue) -> Option<&JsString> {
4097         val.dyn_ref()
4098     }
4099 
4100     /// Returns whether this string is a valid UTF-16 string.
4101     ///
4102     /// This is useful for learning whether `String::from(..)` will return a
4103     /// lossless representation of the JS string. If this string contains
4104     /// unpaired surrogates then `String::from` will succeed but it will be a
4105     /// lossy representation of the JS string because unpaired surrogates will
4106     /// become replacement characters.
4107     ///
4108     /// If this function returns `false` then to get a lossless representation
4109     /// of the string you'll need to manually use the `iter` method (or the
4110     /// `char_code_at` accessor) to view the raw character codes.
4111     ///
4112     /// For more information, see the documentation on [JS strings vs Rust
4113     /// strings][docs]
4114     ///
4115     /// [docs]: https://rustwasm.github.io/docs/wasm-bindgen/reference/types/str.html
is_valid_utf16(&self) -> bool4116     pub fn is_valid_utf16(&self) -> bool {
4117         std::char::decode_utf16(self.iter()).all(|i| i.is_ok())
4118     }
4119 
4120     /// Returns an iterator over the `u16` character codes that make up this JS
4121     /// string.
4122     ///
4123     /// This method will call `char_code_at` for each code in this JS string,
4124     /// returning an iterator of the codes in sequence.
iter<'a>( &'a self, ) -> impl ExactSizeIterator<Item = u16> + DoubleEndedIterator<Item = u16> + 'a4125     pub fn iter<'a>(
4126         &'a self,
4127     ) -> impl ExactSizeIterator<Item = u16> + DoubleEndedIterator<Item = u16> + 'a {
4128         (0..self.length()).map(move |i| self.char_code_at(i) as u16)
4129     }
4130 
4131     /// If this string consists of a single Unicode code point, then this method
4132     /// converts it into a Rust `char` without doing any allocations.
4133     ///
4134     /// If this JS value is not a valid UTF-8 or consists of more than a single
4135     /// codepoint, then this returns `None`.
4136     ///
4137     /// Note that a single Unicode code point might be represented as more than
4138     /// one code unit on the JavaScript side. For example, a JavaScript string
4139     /// `"\uD801\uDC37"` is actually a single Unicode code point U+10437 which
4140     /// corresponds to a character '��'.
as_char(&self) -> Option<char>4141     pub fn as_char(&self) -> Option<char> {
4142         let len = self.length();
4143 
4144         if len == 0 || len > 2 {
4145             return None;
4146         }
4147 
4148         // This will be simplified when definitions are fixed:
4149         // https://github.com/rustwasm/wasm-bindgen/issues/1362
4150         let cp = self.code_point_at(0).as_f64().unwrap_throw() as u32;
4151 
4152         let c = std::char::from_u32(cp)?;
4153 
4154         if c.len_utf16() as u32 == len {
4155             Some(c)
4156         } else {
4157             None
4158         }
4159     }
4160 }
4161 
4162 impl PartialEq<str> for JsString {
eq(&self, other: &str) -> bool4163     fn eq(&self, other: &str) -> bool {
4164         String::from(self) == other
4165     }
4166 }
4167 
4168 impl<'a> PartialEq<&'a str> for JsString {
eq(&self, other: &&'a str) -> bool4169     fn eq(&self, other: &&'a str) -> bool {
4170         <JsString as PartialEq<str>>::eq(self, other)
4171     }
4172 }
4173 
4174 impl PartialEq<String> for JsString {
eq(&self, other: &String) -> bool4175     fn eq(&self, other: &String) -> bool {
4176         <JsString as PartialEq<str>>::eq(self, other)
4177     }
4178 }
4179 
4180 impl<'a> PartialEq<&'a String> for JsString {
eq(&self, other: &&'a String) -> bool4181     fn eq(&self, other: &&'a String) -> bool {
4182         <JsString as PartialEq<str>>::eq(self, other)
4183     }
4184 }
4185 
4186 impl<'a> From<&'a str> for JsString {
from(s: &'a str) -> Self4187     fn from(s: &'a str) -> Self {
4188         JsString::unchecked_from_js(JsValue::from_str(s))
4189     }
4190 }
4191 
4192 impl From<String> for JsString {
from(s: String) -> Self4193     fn from(s: String) -> Self {
4194         From::from(&*s)
4195     }
4196 }
4197 
4198 impl From<char> for JsString {
4199     #[inline]
from(c: char) -> Self4200     fn from(c: char) -> Self {
4201         JsString::from_code_point1(c as u32).unwrap_throw()
4202     }
4203 }
4204 
4205 impl<'a> From<&'a JsString> for String {
from(s: &'a JsString) -> Self4206     fn from(s: &'a JsString) -> Self {
4207         s.obj.as_string().unwrap_throw()
4208     }
4209 }
4210 
4211 impl From<JsString> for String {
from(s: JsString) -> Self4212     fn from(s: JsString) -> Self {
4213         From::from(&s)
4214     }
4215 }
4216 
4217 impl fmt::Debug for JsString {
fmt(&self, f: &mut fmt::Formatter) -> fmt::Result4218     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
4219         String::from(self).fmt(f)
4220     }
4221 }
4222 
4223 // Symbol
4224 #[wasm_bindgen]
4225 extern "C" {
4226     #[wasm_bindgen(is_type_of = JsValue::is_symbol)]
4227     #[derive(Clone, Debug)]
4228     pub type Symbol;
4229 
4230     /// The `Symbol.hasInstance` well-known symbol is used to determine
4231     /// if a constructor object recognizes an object as its instance.
4232     /// The `instanceof` operator's behavior can be customized by this symbol.
4233     ///
4234     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/hasInstance)
4235     #[wasm_bindgen(static_method_of = Symbol, getter, structural, js_name = hasInstance)]
has_instance() -> Symbol4236     pub fn has_instance() -> Symbol;
4237 
4238     /// The `Symbol.isConcatSpreadable` well-known symbol is used to configure
4239     /// if an object should be flattened to its array elements when using the
4240     /// `Array.prototype.concat()` method.
4241     ///
4242     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/isConcatSpreadable)
4243     #[wasm_bindgen(static_method_of = Symbol, getter, structural, js_name = isConcatSpreadable)]
is_concat_spreadable() -> Symbol4244     pub fn is_concat_spreadable() -> Symbol;
4245 
4246     /// The `Symbol.asyncIterator` well-known symbol specifies the default AsyncIterator for an object.
4247     /// If this property is set on an object, it is an async iterable and can be used in a `for await...of` loop.
4248     ///
4249     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/asyncIterator)
4250     #[wasm_bindgen(static_method_of = Symbol, getter, structural, js_name = asyncIterator)]
async_iterator() -> Symbol4251     pub fn async_iterator() -> Symbol;
4252 
4253     /// The `Symbol.iterator` well-known symbol specifies the default iterator
4254     /// for an object.  Used by `for...of`.
4255     ///
4256     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/iterator)
4257     #[wasm_bindgen(static_method_of = Symbol, getter, structural)]
iterator() -> Symbol4258     pub fn iterator() -> Symbol;
4259 
4260     /// The `Symbol.match` well-known symbol specifies the matching of a regular
4261     /// expression against a string. This function is called by the
4262     /// `String.prototype.match()` method.
4263     ///
4264     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/match)
4265     #[wasm_bindgen(static_method_of = Symbol, getter, structural, js_name = match)]
match_() -> Symbol4266     pub fn match_() -> Symbol;
4267 
4268     /// The `Symbol.replace` well-known symbol specifies the method that
4269     /// replaces matched substrings of a string.  This function is called by the
4270     /// `String.prototype.replace()` method.
4271     ///
4272     /// For more information, see `RegExp.prototype[@@replace]()` and
4273     /// `String.prototype.replace()`.
4274     ///
4275     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/replace)
4276     #[wasm_bindgen(static_method_of = Symbol, getter, structural)]
replace() -> Symbol4277     pub fn replace() -> Symbol;
4278 
4279     /// The `Symbol.search` well-known symbol specifies the method that returns
4280     /// the index within a string that matches the regular expression.  This
4281     /// function is called by the `String.prototype.search()` method.
4282     ///
4283     /// For more information, see `RegExp.prototype[@@search]()` and
4284     /// `String.prototype.search()`.
4285     ///
4286     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/search)
4287     #[wasm_bindgen(static_method_of = Symbol, getter, structural)]
search() -> Symbol4288     pub fn search() -> Symbol;
4289 
4290     /// The well-known symbol `Symbol.species` specifies a function-valued
4291     /// property that the constructor function uses to create derived objects.
4292     ///
4293     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/species)
4294     #[wasm_bindgen(static_method_of = Symbol, getter, structural)]
species() -> Symbol4295     pub fn species() -> Symbol;
4296 
4297     /// The `Symbol.split` well-known symbol specifies the method that splits a
4298     /// string at the indices that match a regular expression.  This function is
4299     /// called by the `String.prototype.split()` method.
4300     ///
4301     /// For more information, see `RegExp.prototype[@@split]()` and
4302     /// `String.prototype.split()`.
4303     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/split)
4304     #[wasm_bindgen(static_method_of = Symbol, getter, structural)]
split() -> Symbol4305     pub fn split() -> Symbol;
4306 
4307     /// The `Symbol.toPrimitive` is a symbol that specifies a function valued
4308     /// property that is called to convert an object to a corresponding
4309     /// primitive value.
4310     ///
4311     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toPrimitive)
4312     #[wasm_bindgen(static_method_of = Symbol, getter, structural, js_name = toPrimitive)]
to_primitive() -> Symbol4313     pub fn to_primitive() -> Symbol;
4314 
4315     /// The `Symbol.toStringTag` well-known symbol is a string valued property
4316     /// that is used in the creation of the default string description of an
4317     /// object.  It is accessed internally by the `Object.prototype.toString()`
4318     /// method.
4319     ///
4320     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toString)
4321     #[wasm_bindgen(static_method_of = Symbol, getter, structural, js_name = toStringTag)]
to_string_tag() -> Symbol4322     pub fn to_string_tag() -> Symbol;
4323 
4324     /// The `Symbol.for(key)` method searches for existing symbols in a runtime-wide symbol registry with
4325     /// the given key and returns it if found.
4326     /// Otherwise a new symbol gets created in the global symbol registry with this key.
4327     ///
4328     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/for)
4329     #[wasm_bindgen(static_method_of = Symbol, js_name = for)]
for_(key: &str) -> Symbol4330     pub fn for_(key: &str) -> Symbol;
4331 
4332     /// The `Symbol.keyFor(sym)` method retrieves a shared symbol key from the global symbol registry for the given symbol.
4333     ///
4334     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/keyFor)
4335     #[wasm_bindgen(static_method_of = Symbol, js_name = keyFor)]
key_for(sym: &Symbol) -> JsValue4336     pub fn key_for(sym: &Symbol) -> JsValue;
4337 
4338     /// The `toString()` method returns a string representing the specified Symbol object.
4339     ///
4340     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toString)
4341     #[wasm_bindgen(method, js_name = toString)]
to_string(this: &Symbol) -> JsString4342     pub fn to_string(this: &Symbol) -> JsString;
4343 
4344     /// The `Symbol.unscopables` well-known symbol is used to specify an object
4345     /// value of whose own and inherited property names are excluded from the
4346     /// with environment bindings of the associated object.
4347     ///
4348     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/unscopables)
4349     #[wasm_bindgen(static_method_of = Symbol, getter, structural)]
unscopables() -> Symbol4350     pub fn unscopables() -> Symbol;
4351 
4352     /// The `valueOf()` method returns the primitive value of a Symbol object.
4353     ///
4354     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/valueOf)
4355     #[wasm_bindgen(method, js_name = valueOf)]
value_of(this: &Symbol) -> Symbol4356     pub fn value_of(this: &Symbol) -> Symbol;
4357 }
4358 
4359 #[allow(non_snake_case)]
4360 pub mod Intl {
4361     use super::*;
4362 
4363     // Intl
4364     #[wasm_bindgen]
4365     extern "C" {
4366         /// The `Intl.getCanonicalLocales()` method returns an array containing
4367         /// the canonical locale names. Duplicates will be omitted and elements
4368         /// will be validated as structurally valid language tags.
4369         ///
4370         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/getCanonicalLocales)
4371         #[wasm_bindgen(js_name = getCanonicalLocales, js_namespace = Intl)]
get_canonical_locales(s: &JsValue) -> Array4372         pub fn get_canonical_locales(s: &JsValue) -> Array;
4373     }
4374 
4375     // Intl.Collator
4376     #[wasm_bindgen]
4377     extern "C" {
4378         /// The `Intl.Collator` object is a constructor for collators, objects
4379         /// that enable language sensitive string comparison.
4380         ///
4381         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator)
4382         #[wasm_bindgen(extends = Object, js_namespace = Intl)]
4383         #[derive(Clone, Debug)]
4384         pub type Collator;
4385 
4386         /// The `Intl.Collator` object is a constructor for collators, objects
4387         /// that enable language sensitive string comparison.
4388         ///
4389         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator)
4390         #[wasm_bindgen(constructor, js_namespace = Intl)]
new(locales: &Array, options: &Object) -> Collator4391         pub fn new(locales: &Array, options: &Object) -> Collator;
4392 
4393         /// The Intl.Collator.prototype.compare property returns a function that
4394         /// compares two strings according to the sort order of this Collator
4395         /// object.
4396         ///
4397         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator/compare)
4398         #[wasm_bindgen(method, getter, js_class = "Intl.Collator")]
compare(this: &Collator) -> Function4399         pub fn compare(this: &Collator) -> Function;
4400 
4401         /// The `Intl.Collator.prototype.resolvedOptions()` method returns a new
4402         /// object with properties reflecting the locale and collation options
4403         /// computed during initialization of this Collator object.
4404         ///
4405         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator/resolvedOptions)
4406         #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
resolved_options(this: &Collator) -> Object4407         pub fn resolved_options(this: &Collator) -> Object;
4408 
4409         /// The `Intl.Collator.supportedLocalesOf()` method returns an array
4410         /// containing those of the provided locales that are supported in
4411         /// collation without having to fall back to the runtime's default
4412         /// locale.
4413         ///
4414         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator/supportedLocalesOf)
4415         #[wasm_bindgen(static_method_of = Collator, js_namespace = Intl, js_name = supportedLocalesOf)]
supported_locales_of(locales: &Array, options: &Object) -> Array4416         pub fn supported_locales_of(locales: &Array, options: &Object) -> Array;
4417     }
4418 
4419     // Intl.DateTimeFormat
4420     #[wasm_bindgen]
4421     extern "C" {
4422         /// The `Intl.DateTimeFormat` object is a constructor for objects
4423         /// that enable language-sensitive date and time formatting.
4424         ///
4425         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat)
4426         #[wasm_bindgen(extends = Object, js_namespace = Intl)]
4427         #[derive(Clone, Debug)]
4428         pub type DateTimeFormat;
4429 
4430         /// The `Intl.DateTimeFormat` object is a constructor for objects
4431         /// that enable language-sensitive date and time formatting.
4432         ///
4433         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat)
4434         #[wasm_bindgen(constructor, js_namespace = Intl)]
new(locales: &Array, options: &Object) -> DateTimeFormat4435         pub fn new(locales: &Array, options: &Object) -> DateTimeFormat;
4436 
4437         /// The Intl.DateTimeFormat.prototype.format property returns a getter function that
4438         /// formats a date according to the locale and formatting options of this
4439         /// Intl.DateTimeFormat object.
4440         ///
4441         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/format)
4442         #[wasm_bindgen(method, getter, js_class = "Intl.DateTimeFormat")]
format(this: &DateTimeFormat) -> Function4443         pub fn format(this: &DateTimeFormat) -> Function;
4444 
4445         /// The `Intl.DateTimeFormat.prototype.formatToParts()` method allows locale-aware
4446         /// formatting of strings produced by DateTimeFormat formatters.
4447         ///
4448         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/formatToParts)
4449         #[wasm_bindgen(method, js_class = "Intl.DateTimeFormat", js_name = formatToParts)]
format_to_parts(this: &DateTimeFormat, date: &Date) -> Array4450         pub fn format_to_parts(this: &DateTimeFormat, date: &Date) -> Array;
4451 
4452         /// The `Intl.DateTimeFormat.prototype.resolvedOptions()` method returns a new
4453         /// object with properties reflecting the locale and date and time formatting
4454         /// options computed during initialization of this DateTimeFormat object.
4455         ///
4456         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/resolvedOptions)
4457         #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
resolved_options(this: &DateTimeFormat) -> Object4458         pub fn resolved_options(this: &DateTimeFormat) -> Object;
4459 
4460         /// The `Intl.DateTimeFormat.supportedLocalesOf()` method returns an array
4461         /// containing those of the provided locales that are supported in date
4462         /// and time formatting without having to fall back to the runtime's default
4463         /// locale.
4464         ///
4465         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/supportedLocalesOf)
4466         #[wasm_bindgen(static_method_of = DateTimeFormat, js_namespace = Intl, js_name = supportedLocalesOf)]
supported_locales_of(locales: &Array, options: &Object) -> Array4467         pub fn supported_locales_of(locales: &Array, options: &Object) -> Array;
4468     }
4469 
4470     // Intl.NumberFormat
4471     #[wasm_bindgen]
4472     extern "C" {
4473         /// The `Intl.NumberFormat` object is a constructor for objects
4474         /// that enable language sensitive number formatting.
4475         ///
4476         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat)
4477         #[wasm_bindgen(extends = Object, js_namespace = Intl)]
4478         #[derive(Clone, Debug)]
4479         pub type NumberFormat;
4480 
4481         /// The `Intl.NumberFormat` object is a constructor for objects
4482         /// that enable language sensitive number formatting.
4483         ///
4484         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat)
4485         #[wasm_bindgen(constructor, js_namespace = Intl)]
new(locales: &Array, options: &Object) -> NumberFormat4486         pub fn new(locales: &Array, options: &Object) -> NumberFormat;
4487 
4488         /// The Intl.NumberFormat.prototype.format property returns a getter function that
4489         /// formats a number according to the locale and formatting options of this
4490         /// NumberFormat object.
4491         ///
4492         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/format)
4493         #[wasm_bindgen(method, getter, js_class = "Intl.NumberFormat")]
format(this: &NumberFormat) -> Function4494         pub fn format(this: &NumberFormat) -> Function;
4495 
4496         /// The `Intl.Numberformat.prototype.formatToParts()` method allows locale-aware
4497         /// formatting of strings produced by NumberTimeFormat formatters.
4498         ///
4499         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/formatToParts)
4500         #[wasm_bindgen(method, js_class = "Intl.NumberFormat", js_name = formatToParts)]
format_to_parts(this: &NumberFormat, number: f64) -> Array4501         pub fn format_to_parts(this: &NumberFormat, number: f64) -> Array;
4502 
4503         /// The `Intl.NumberFormat.prototype.resolvedOptions()` method returns a new
4504         /// object with properties reflecting the locale and number formatting
4505         /// options computed during initialization of this NumberFormat object.
4506         ///
4507         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/resolvedOptions)
4508         #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
resolved_options(this: &NumberFormat) -> Object4509         pub fn resolved_options(this: &NumberFormat) -> Object;
4510 
4511         /// The `Intl.NumberFormat.supportedLocalesOf()` method returns an array
4512         /// containing those of the provided locales that are supported in number
4513         /// formatting without having to fall back to the runtime's default locale.
4514         ///
4515         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/supportedLocalesOf)
4516         #[wasm_bindgen(static_method_of = NumberFormat, js_namespace = Intl, js_name = supportedLocalesOf)]
supported_locales_of(locales: &Array, options: &Object) -> Array4517         pub fn supported_locales_of(locales: &Array, options: &Object) -> Array;
4518     }
4519 
4520     // Intl.PluralRules
4521     #[wasm_bindgen]
4522     extern "C" {
4523         /// The `Intl.PluralRules` object is a constructor for objects
4524         /// that enable plural sensitive formatting and plural language rules.
4525         ///
4526         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules)
4527         #[wasm_bindgen(extends = Object, js_namespace = Intl)]
4528         #[derive(Clone, Debug)]
4529         pub type PluralRules;
4530 
4531         /// The `Intl.PluralRules` object is a constructor for objects
4532         /// that enable plural sensitive formatting and plural language rules.
4533         ///
4534         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules)
4535         #[wasm_bindgen(constructor, js_namespace = Intl)]
new(locales: &Array, options: &Object) -> PluralRules4536         pub fn new(locales: &Array, options: &Object) -> PluralRules;
4537 
4538         /// The `Intl.PluralRules.prototype.resolvedOptions()` method returns a new
4539         /// object with properties reflecting the locale and plural formatting
4540         /// options computed during initialization of this PluralRules object.
4541         ///
4542         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules/resolvedOptions)
4543         #[wasm_bindgen(method, js_namespace = Intl, js_name = resolvedOptions)]
resolved_options(this: &PluralRules) -> Object4544         pub fn resolved_options(this: &PluralRules) -> Object;
4545 
4546         /// The `Intl.PluralRules.prototype.select()` method returns a String indicating
4547         /// which plural rule to use for locale-aware formatting.
4548         ///
4549         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules/select)
4550         #[wasm_bindgen(method, js_namespace = Intl)]
select(this: &PluralRules, number: f64) -> JsString4551         pub fn select(this: &PluralRules, number: f64) -> JsString;
4552 
4553         /// The `Intl.PluralRules.supportedLocalesOf()` method returns an array
4554         /// containing those of the provided locales that are supported in plural
4555         /// formatting without having to fall back to the runtime's default locale.
4556         ///
4557         /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules/supportedLocalesOf)
4558         #[wasm_bindgen(static_method_of = PluralRules, js_namespace = Intl, js_name = supportedLocalesOf)]
supported_locales_of(locales: &Array, options: &Object) -> Array4559         pub fn supported_locales_of(locales: &Array, options: &Object) -> Array;
4560     }
4561 }
4562 
4563 // Promise
4564 #[wasm_bindgen]
4565 extern "C" {
4566     /// The `Promise` object represents the eventual completion (or failure) of
4567     /// an asynchronous operation, and its resulting value.
4568     ///
4569     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
4570     #[must_use]
4571     #[wasm_bindgen(extends = Object)]
4572     #[derive(Clone, Debug)]
4573     pub type Promise;
4574 
4575     /// Creates a new `Promise` with the provided executor `cb`
4576     ///
4577     /// The `cb` is a function that is passed with the arguments `resolve` and
4578     /// `reject`. The `cb` function is executed immediately by the `Promise`
4579     /// implementation, passing `resolve` and `reject` functions (the executor
4580     /// is called before the `Promise` constructor even returns the created
4581     /// object). The `resolve` and `reject` functions, when called, resolve or
4582     /// reject the promise, respectively. The executor normally initiates
4583     /// some asynchronous work, and then, once that completes, either calls
4584     /// the `resolve` function to resolve the promise or else rejects it if an
4585     /// error occurred.
4586     ///
4587     /// If an error is thrown in the executor function, the promise is rejected.
4588     /// The return value of the executor is ignored.
4589     ///
4590     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
4591     #[wasm_bindgen(constructor)]
new(cb: &mut dyn FnMut(Function, Function)) -> Promise4592     pub fn new(cb: &mut dyn FnMut(Function, Function)) -> Promise;
4593 
4594     /// The `Promise.all(iterable)` method returns a single `Promise` that
4595     /// resolves when all of the promises in the iterable argument have resolved
4596     /// or when the iterable argument contains no promises. It rejects with the
4597     /// reason of the first promise that rejects.
4598     ///
4599     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all)
4600     #[wasm_bindgen(static_method_of = Promise)]
all(obj: &JsValue) -> Promise4601     pub fn all(obj: &JsValue) -> Promise;
4602 
4603     /// The `Promise.race(iterable)` method returns a promise that resolves or
4604     /// rejects as soon as one of the promises in the iterable resolves or
4605     /// rejects, with the value or reason from that promise.
4606     ///
4607     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/race)
4608     #[wasm_bindgen(static_method_of = Promise)]
race(obj: &JsValue) -> Promise4609     pub fn race(obj: &JsValue) -> Promise;
4610 
4611     /// The `Promise.reject(reason)` method returns a `Promise` object that is
4612     /// rejected with the given reason.
4613     ///
4614     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/reject)
4615     #[wasm_bindgen(static_method_of = Promise)]
reject(obj: &JsValue) -> Promise4616     pub fn reject(obj: &JsValue) -> Promise;
4617 
4618     /// The `Promise.resolve(value)` method returns a `Promise` object that is
4619     /// resolved with the given value. If the value is a promise, that promise
4620     /// is returned; if the value is a thenable (i.e. has a "then" method), the
4621     /// returned promise will "follow" that thenable, adopting its eventual
4622     /// state; otherwise the returned promise will be fulfilled with the value.
4623     ///
4624     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/resolve)
4625     #[wasm_bindgen(static_method_of = Promise)]
resolve(obj: &JsValue) -> Promise4626     pub fn resolve(obj: &JsValue) -> Promise;
4627 
4628     /// The `catch()` method returns a `Promise` and deals with rejected cases
4629     /// only.  It behaves the same as calling `Promise.prototype.then(undefined,
4630     /// onRejected)` (in fact, calling `obj.catch(onRejected)` internally calls
4631     /// `obj.then(undefined, onRejected)`).
4632     ///
4633     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/catch)
4634     #[wasm_bindgen(method)]
catch(this: &Promise, cb: &Closure<dyn FnMut(JsValue)>) -> Promise4635     pub fn catch(this: &Promise, cb: &Closure<dyn FnMut(JsValue)>) -> Promise;
4636 
4637     /// The `then()` method returns a `Promise`. It takes up to two arguments:
4638     /// callback functions for the success and failure cases of the `Promise`.
4639     ///
4640     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then)
4641     #[wasm_bindgen(method)]
then(this: &Promise, cb: &Closure<dyn FnMut(JsValue)>) -> Promise4642     pub fn then(this: &Promise, cb: &Closure<dyn FnMut(JsValue)>) -> Promise;
4643 
4644     /// Same as `then`, only with both arguments provided.
4645     #[wasm_bindgen(method, js_name = then)]
then2( this: &Promise, resolve: &Closure<dyn FnMut(JsValue)>, reject: &Closure<dyn FnMut(JsValue)>, ) -> Promise4646     pub fn then2(
4647         this: &Promise,
4648         resolve: &Closure<dyn FnMut(JsValue)>,
4649         reject: &Closure<dyn FnMut(JsValue)>,
4650     ) -> Promise;
4651 
4652     /// The `finally()` method returns a `Promise`. When the promise is settled,
4653     /// whether fulfilled or rejected, the specified callback function is
4654     /// executed. This provides a way for code that must be executed once the
4655     /// `Promise` has been dealt with to be run whether the promise was
4656     /// fulfilled successfully or rejected.
4657     ///
4658     /// This lets you avoid duplicating code in both the promise's `then()` and
4659     /// `catch()` handlers.
4660     ///
4661     /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/finally)
4662     #[wasm_bindgen(method)]
finally(this: &Promise, cb: &Closure<dyn FnMut()>) -> Promise4663     pub fn finally(this: &Promise, cb: &Closure<dyn FnMut()>) -> Promise;
4664 }
4665 
4666 /// Returns a handle to the global scope object.
4667 ///
4668 /// This allows access to the global properties and global names by accessing
4669 /// the `Object` returned.
global() -> Object4670 pub fn global() -> Object {
4671     thread_local!(static GLOBAL: Object = get_global_object());
4672 
4673     return GLOBAL.with(|g| g.clone());
4674 
4675     fn get_global_object() -> Object {
4676         // This is a bit wonky, but we're basically using `#[wasm_bindgen]`
4677         // attributes to synthesize imports so we can access properties of the
4678         // form:
4679         //
4680         // * `globalThis.globalThis`
4681         // * `self.self`
4682         // * ... (etc)
4683         //
4684         // Accessing the global object is not an easy thing to do, and what we
4685         // basically want is `globalThis` but we can't rely on that existing
4686         // everywhere. In the meantime we've got the fallbacks mentioned in:
4687         //
4688         // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis
4689         //
4690         // Note that this is pretty heavy code-size wise but it at least gets
4691         // the job largely done for now and avoids the `Function` constructor at
4692         // the end which triggers CSP errors.
4693         #[wasm_bindgen]
4694         extern "C" {
4695             type Global;
4696 
4697             #[wasm_bindgen(getter, catch, static_method_of = Global, js_class = globalThis, js_name = globalThis)]
4698             fn get_global_this() -> Result<Object, JsValue>;
4699 
4700             #[wasm_bindgen(getter, catch, static_method_of = Global, js_class = self, js_name = self)]
4701             fn get_self() -> Result<Object, JsValue>;
4702 
4703             #[wasm_bindgen(getter, catch, static_method_of = Global, js_class = window, js_name = window)]
4704             fn get_window() -> Result<Object, JsValue>;
4705 
4706             #[wasm_bindgen(getter, catch, static_method_of = Global, js_class = global, js_name = global)]
4707             fn get_global() -> Result<Object, JsValue>;
4708         }
4709 
4710         let static_object = Global::get_global_this()
4711             .or_else(|_| Global::get_self())
4712             .or_else(|_| Global::get_window())
4713             .or_else(|_| Global::get_global());
4714         if let Ok(obj) = static_object {
4715             if !obj.is_undefined() {
4716                 return obj;
4717             }
4718         }
4719 
4720         // According to StackOverflow you can access the global object via:
4721         //
4722         //      const global = Function('return this')();
4723         //
4724         // I think that's because the manufactured function isn't in "strict" mode.
4725         // It also turns out that non-strict functions will ignore `undefined`
4726         // values for `this` when using the `apply` function.
4727         //
4728         // As a result we use the equivalent of this snippet to get a handle to the
4729         // global object in a sort of roundabout way that should hopefully work in
4730         // all contexts like ESM, node, browsers, etc.
4731         let this = Function::new_no_args("return this")
4732             .call0(&JsValue::undefined())
4733             .ok();
4734 
4735         // Note that we avoid `unwrap()` on `call0` to avoid code size bloat, we
4736         // just handle the `Err` case as returning a different object.
4737         debug_assert!(this.is_some());
4738         match this {
4739             Some(this) => this.unchecked_into(),
4740             None => JsValue::undefined().unchecked_into(),
4741         }
4742     }
4743 }
4744 
4745 macro_rules! arrays {
4746     ($(#[doc = $ctor:literal] #[doc = $mdn:literal] $name:ident: $ty:ident,)*) => ($(
4747         #[wasm_bindgen]
4748         extern "C" {
4749             #[wasm_bindgen(extends = Object)]
4750             #[derive(Clone, Debug)]
4751             pub type $name;
4752 
4753             /// The
4754             #[doc = $ctor]
4755             /// constructor creates an array of unsigned 8-bit integers.
4756             ///
4757             /// [MDN documentation](
4758             #[doc = $mdn]
4759             /// )
4760             #[wasm_bindgen(constructor)]
4761             pub fn new(constructor_arg: &JsValue) -> $name;
4762 
4763             /// An
4764             #[doc = $ctor]
4765             /// which creates an array with an internal buffer large
4766             /// enough for `length` elements.
4767             ///
4768             /// [MDN documentation](
4769             #[doc = $mdn]
4770             /// )
4771             #[wasm_bindgen(constructor)]
4772             pub fn new_with_length(length: u32) -> $name;
4773 
4774             /// An
4775             #[doc = $ctor]
4776             /// which creates an array with the given buffer but is a
4777             /// view starting at `byte_offset`.
4778             ///
4779             /// [MDN documentation](
4780             #[doc = $mdn]
4781             /// )
4782             #[wasm_bindgen(constructor)]
4783             pub fn new_with_byte_offset(buffer: &JsValue, byte_offset: u32) -> $name;
4784 
4785             /// An
4786             #[doc = $ctor]
4787             /// which creates an array with the given buffer but is a
4788             /// view starting at `byte_offset` for `length` elements.
4789             ///
4790             /// [MDN documentation](
4791             #[doc = $mdn]
4792             /// )
4793             #[wasm_bindgen(constructor)]
4794             pub fn new_with_byte_offset_and_length(
4795                 buffer: &JsValue,
4796                 byte_offset: u32,
4797                 length: u32,
4798             ) -> $name;
4799 
4800             /// The `fill()` method fills all the elements of an array from a start index
4801             /// to an end index with a static value. The end index is not included.
4802             ///
4803             /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/fill)
4804             #[wasm_bindgen(method)]
4805             pub fn fill(this: &$name, value: $ty, start: u32, end: u32) -> $name;
4806 
4807             /// The buffer accessor property represents the `ArrayBuffer` referenced
4808             /// by a `TypedArray` at construction time.
4809             #[wasm_bindgen(getter, method)]
4810             pub fn buffer(this: &$name) -> ArrayBuffer;
4811 
4812             /// The `subarray()` method stores multiple values in the typed array,
4813             /// reading input values from a specified array.
4814             #[wasm_bindgen(method)]
4815             pub fn subarray(this: &$name, begin: u32, end: u32) -> $name;
4816 
4817             /// The `slice()` method returns a shallow copy of a portion of a typed
4818             /// array into a new typed array object. This method has the same algorithm
4819             /// as `Array.prototype.slice()`.
4820             #[wasm_bindgen(method)]
4821             pub fn slice(this: &$name, begin: u32, end: u32) -> $name;
4822 
4823             /// The `forEach()` method executes a provided function once per array
4824             /// element. This method has the same algorithm as
4825             /// `Array.prototype.forEach()`. `TypedArray` is one of the typed array
4826             /// types here.
4827             #[wasm_bindgen(method, js_name = forEach)]
4828             pub fn for_each(this: &$name, callback: &mut dyn FnMut($ty, u32, $name));
4829 
4830             /// The length accessor property represents the length (in elements) of a
4831             /// typed array.
4832             #[wasm_bindgen(method, getter)]
4833             pub fn length(this: &$name) -> u32;
4834 
4835             /// The byteLength accessor property represents the length (in bytes) of a
4836             /// typed array.
4837             #[wasm_bindgen(method, getter, js_name = byteLength)]
4838             pub fn byte_length(this: &$name) -> u32;
4839 
4840             /// The byteOffset accessor property represents the offset (in bytes) of a
4841             /// typed array from the start of its `ArrayBuffer`.
4842             #[wasm_bindgen(method, getter, js_name = byteOffset)]
4843             pub fn byte_offset(this: &$name) -> u32;
4844 
4845             /// The `set()` method stores multiple values in the typed array, reading
4846             /// input values from a specified array.
4847             #[wasm_bindgen(method)]
4848             pub fn set(this: &$name, src: &JsValue, offset: u32);
4849         }
4850 
4851         impl $name {
4852             /// Creates a JS typed array which is a view into wasm's linear
4853             /// memory at the slice specified.
4854             ///
4855             /// This function returns a new typed array which is a view into
4856             /// wasm's memory. This view does not copy the underlying data.
4857             ///
4858             /// # Unsafety
4859             ///
4860             /// Views into WebAssembly memory are only valid so long as the
4861             /// backing buffer isn't resized in JS. Once this function is called
4862             /// any future calls to `Box::new` (or malloc of any form) may cause
4863             /// the returned value here to be invalidated. Use with caution!
4864             ///
4865             /// Additionally the returned object can be safely mutated but the
4866             /// input slice isn't guaranteed to be mutable.
4867             ///
4868             /// Finally, the returned object is disconnected from the input
4869             /// slice's lifetime, so there's no guarantee that the data is read
4870             /// at the right time.
4871             pub unsafe fn view(rust: &[$ty]) -> $name {
4872                 let buf = wasm_bindgen::memory();
4873                 let mem = buf.unchecked_ref::<WebAssembly::Memory>();
4874                 $name::new_with_byte_offset_and_length(
4875                     &mem.buffer(),
4876                     rust.as_ptr() as u32,
4877                     rust.len() as u32,
4878                 )
4879             }
4880 
4881             /// Creates a JS typed array which is a view into wasm's linear
4882             /// memory at the specified pointer with specified length.
4883             ///
4884             /// This function returns a new typed array which is a view into
4885             /// wasm's memory. This view does not copy the underlying data.
4886             ///
4887             /// # Unsafety
4888             ///
4889             /// Views into WebAssembly memory are only valid so long as the
4890             /// backing buffer isn't resized in JS. Once this function is called
4891             /// any future calls to `Box::new` (or malloc of any form) may cause
4892             /// the returned value here to be invalidated. Use with caution!
4893             ///
4894             /// Additionally the returned object can be safely mutated,
4895             /// the changes are guranteed to be reflected in the input array.
4896             pub unsafe fn view_mut_raw(ptr: *mut $ty, length: usize) -> $name {
4897                 let buf = wasm_bindgen::memory();
4898                 let mem = buf.unchecked_ref::<WebAssembly::Memory>();
4899                 $name::new_with_byte_offset_and_length(
4900                     &mem.buffer(),
4901                     ptr as u32,
4902                     length as u32
4903                 )
4904             }
4905 
4906             fn raw_copy_to(&self, dst: &mut [$ty]) {
4907                 let buf = wasm_bindgen::memory();
4908                 let mem = buf.unchecked_ref::<WebAssembly::Memory>();
4909                 let all_wasm_memory = $name::new(&mem.buffer());
4910                 let offset = dst.as_ptr() as usize / mem::size_of::<$ty>();
4911                 all_wasm_memory.set(self, offset as u32);
4912             }
4913 
4914             /// Copy the contents of this JS typed array into the destination
4915             /// Rust slice.
4916             ///
4917             /// This function will efficiently copy the memory from a typed
4918             /// array into this wasm module's own linear memory, initializing
4919             /// the memory destination provided.
4920             ///
4921             /// # Panics
4922             ///
4923             /// This function will panic if this typed array's length is
4924             /// different than the length of the provided `dst` array.
4925             pub fn copy_to(&self, dst: &mut [$ty]) {
4926                 assert_eq!(self.length() as usize, dst.len());
4927                 self.raw_copy_to(dst);
4928             }
4929 
4930             /// Efficiently copies the contents of this JS typed array into a new Vec.
4931             pub fn to_vec(&self) -> Vec<$ty> {
4932                 let mut output = vec![$ty::default(); self.length() as usize];
4933                 self.raw_copy_to(&mut output);
4934                 output
4935             }
4936         }
4937 
4938         impl<'a> From<&'a [$ty]> for $name {
4939             #[inline]
4940             fn from(slice: &'a [$ty]) -> $name {
4941                 // This is safe because the `new` function makes a copy if its argument is a TypedArray
4942                 unsafe { $name::new(&$name::view(slice)) }
4943             }
4944         }
4945     )*);
4946 }
4947 
4948 arrays! {
4949     /// `Int8Array()`
4950     /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int8Array
4951     Int8Array: i8,
4952 
4953     /// `Int16Array()`
4954     /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int16Array
4955     Int16Array: i16,
4956 
4957     /// `Int32Array()`
4958     /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int32Array
4959     Int32Array: i32,
4960 
4961     /// `Uint8Array()`
4962     /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array
4963     Uint8Array: u8,
4964 
4965     /// `Uint8ClampedArray()`
4966     /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8ClampedArray
4967     Uint8ClampedArray: u8,
4968 
4969     /// `Uint16Array()`
4970     /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint16Array
4971     Uint16Array: u16,
4972 
4973     /// `Uint32Array()`
4974     /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint32Array
4975     Uint32Array: u32,
4976 
4977     /// `Float32Array()`
4978     /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float32Array
4979     Float32Array: f32,
4980 
4981     /// `Float64Array()`
4982     /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float64Array
4983     Float64Array: f64,
4984 }
4985