mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2024-12-28 20:43:23 +03:00
js-sys: run rustfmt
This commit is contained in:
parent
f9cd329b14
commit
7db28b4548
@ -20,12 +20,12 @@
|
|||||||
|
|
||||||
extern crate wasm_bindgen;
|
extern crate wasm_bindgen;
|
||||||
|
|
||||||
use std::mem;
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
use std::mem;
|
||||||
|
|
||||||
use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering::SeqCst};
|
use std::sync::atomic::{AtomicUsize, Ordering::SeqCst, ATOMIC_USIZE_INIT};
|
||||||
use wasm_bindgen::JsCast;
|
|
||||||
use wasm_bindgen::prelude::*;
|
use wasm_bindgen::prelude::*;
|
||||||
|
use wasm_bindgen::JsCast;
|
||||||
|
|
||||||
// When adding new imports:
|
// When adding new imports:
|
||||||
//
|
//
|
||||||
@ -304,14 +304,22 @@ extern "C" {
|
|||||||
///
|
///
|
||||||
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce)
|
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce)
|
||||||
#[wasm_bindgen(method)]
|
#[wasm_bindgen(method)]
|
||||||
pub fn reduce(this: &Array, predicate: &mut FnMut(JsValue, JsValue, u32, Array) -> JsValue, initial_value: &JsValue) -> JsValue;
|
pub fn reduce(
|
||||||
|
this: &Array,
|
||||||
|
predicate: &mut FnMut(JsValue, JsValue, u32, Array) -> JsValue,
|
||||||
|
initial_value: &JsValue,
|
||||||
|
) -> JsValue;
|
||||||
|
|
||||||
/// The reduceRight() method applies a function against an accumulator and each value
|
/// The reduceRight() method applies a function against an accumulator and each value
|
||||||
/// of the array (from right-to-left) to reduce it to a single value.
|
/// of the array (from right-to-left) to reduce it to a single value.
|
||||||
///
|
///
|
||||||
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/ReduceRight)
|
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/ReduceRight)
|
||||||
#[wasm_bindgen(method, js_name = reduceRight)]
|
#[wasm_bindgen(method, js_name = reduceRight)]
|
||||||
pub fn reduce_right(this: &Array, predicate: &mut FnMut(JsValue, JsValue, u32, Array) -> JsValue, initial_value: &JsValue) -> JsValue;
|
pub fn reduce_right(
|
||||||
|
this: &Array,
|
||||||
|
predicate: &mut FnMut(JsValue, JsValue, u32, Array) -> JsValue,
|
||||||
|
initial_value: &JsValue,
|
||||||
|
) -> JsValue;
|
||||||
|
|
||||||
/// The reverse() method reverses an array in place. The first array
|
/// The reverse() method reverses an array in place. The first array
|
||||||
/// element becomes the last, and the last array element becomes the first.
|
/// element becomes the last, and the last array element becomes the first.
|
||||||
@ -831,14 +839,25 @@ extern "C" {
|
|||||||
///
|
///
|
||||||
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
|
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
|
||||||
#[wasm_bindgen(method, catch, js_name = call)]
|
#[wasm_bindgen(method, catch, js_name = call)]
|
||||||
pub fn call2(this: &Function, context: &JsValue, arg1: &JsValue, arg2: &JsValue) -> Result<JsValue, JsValue>;
|
pub fn call2(
|
||||||
|
this: &Function,
|
||||||
|
context: &JsValue,
|
||||||
|
arg1: &JsValue,
|
||||||
|
arg2: &JsValue,
|
||||||
|
) -> Result<JsValue, JsValue>;
|
||||||
|
|
||||||
/// The `call()` method calls a function with a given this value and
|
/// The `call()` method calls a function with a given this value and
|
||||||
/// arguments provided individually.
|
/// arguments provided individually.
|
||||||
///
|
///
|
||||||
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
|
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call)
|
||||||
#[wasm_bindgen(method, catch, js_name = call)]
|
#[wasm_bindgen(method, catch, js_name = call)]
|
||||||
pub fn call3(this: &Function, context: &JsValue, arg1: &JsValue, arg2: &JsValue, arg3: &JsValue) -> Result<JsValue, JsValue>;
|
pub fn call3(
|
||||||
|
this: &Function,
|
||||||
|
context: &JsValue,
|
||||||
|
arg1: &JsValue,
|
||||||
|
arg2: &JsValue,
|
||||||
|
arg3: &JsValue,
|
||||||
|
) -> Result<JsValue, JsValue>;
|
||||||
|
|
||||||
/// The bind() method creates a new function that, when called, has its this keyword set to the provided value,
|
/// The bind() method creates a new function that, when called, has its this keyword set to the provided value,
|
||||||
/// with a given sequence of arguments preceding any provided when the new function is called.
|
/// with a given sequence of arguments preceding any provided when the new function is called.
|
||||||
@ -885,7 +904,7 @@ impl Function {
|
|||||||
|
|
||||||
// Generator
|
// Generator
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
extern {
|
extern "C" {
|
||||||
#[wasm_bindgen(extends = Object)]
|
#[wasm_bindgen(extends = Object)]
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub type Generator;
|
pub type Generator;
|
||||||
@ -1072,7 +1091,7 @@ extern "C" {
|
|||||||
|
|
||||||
// Map
|
// Map
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
extern {
|
extern "C" {
|
||||||
#[wasm_bindgen(extends = Object)]
|
#[wasm_bindgen(extends = Object)]
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub type Map;
|
pub type Map;
|
||||||
@ -1134,7 +1153,7 @@ extern {
|
|||||||
|
|
||||||
// Map Iterator
|
// Map Iterator
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
extern {
|
extern "C" {
|
||||||
/// The entries() method returns a new Iterator object that contains
|
/// The entries() method returns a new Iterator object that contains
|
||||||
/// the [key, value] pairs for each element in the Map object in
|
/// the [key, value] pairs for each element in the Map object in
|
||||||
/// insertion order.
|
/// insertion order.
|
||||||
@ -1160,7 +1179,7 @@ extern {
|
|||||||
|
|
||||||
// Iterator
|
// Iterator
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
extern {
|
extern "C" {
|
||||||
/// Any object that conforms to the JS iterator protocol. For example,
|
/// Any object that conforms to the JS iterator protocol. For example,
|
||||||
/// something returned by `myArray[Symbol.iterator]()`.
|
/// something returned by `myArray[Symbol.iterator]()`.
|
||||||
///
|
///
|
||||||
@ -1201,7 +1220,10 @@ impl<'a> IntoIterator for &'a Iterator {
|
|||||||
type IntoIter = Iter<'a>;
|
type IntoIter = Iter<'a>;
|
||||||
|
|
||||||
fn into_iter(self) -> Iter<'a> {
|
fn into_iter(self) -> Iter<'a> {
|
||||||
Iter { js: self, state: IterState::new() }
|
Iter {
|
||||||
|
js: self,
|
||||||
|
state: IterState::new(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1218,7 +1240,10 @@ impl IntoIterator for Iterator {
|
|||||||
type IntoIter = IntoIter;
|
type IntoIter = IntoIter;
|
||||||
|
|
||||||
fn into_iter(self) -> IntoIter {
|
fn into_iter(self) -> IntoIter {
|
||||||
IntoIter { js: self, state: IterState::new() }
|
IntoIter {
|
||||||
|
js: self,
|
||||||
|
state: IterState::new(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1237,13 +1262,13 @@ impl IterState {
|
|||||||
|
|
||||||
fn next(&mut self, js: &Iterator) -> Option<Result<JsValue, JsValue>> {
|
fn next(&mut self, js: &Iterator) -> Option<Result<JsValue, JsValue>> {
|
||||||
if self.done {
|
if self.done {
|
||||||
return None
|
return None;
|
||||||
}
|
}
|
||||||
let next = match js.next() {
|
let next = match js.next() {
|
||||||
Ok(val) => val,
|
Ok(val) => val,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
self.done = true;
|
self.done = true;
|
||||||
return Some(Err(e))
|
return Some(Err(e));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if next.done() {
|
if next.done() {
|
||||||
@ -1283,7 +1308,7 @@ pub fn try_iter(val: &JsValue) -> Result<Option<IntoIter>, JsValue> {
|
|||||||
|
|
||||||
// IteratorNext
|
// IteratorNext
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
extern {
|
extern "C" {
|
||||||
/// The result of calling `next()` on a JS iterator.
|
/// The result of calling `next()` on a JS iterator.
|
||||||
///
|
///
|
||||||
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols)
|
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols)
|
||||||
@ -1400,7 +1425,6 @@ extern "C" {
|
|||||||
#[wasm_bindgen(static_method_of = Math)]
|
#[wasm_bindgen(static_method_of = Math)]
|
||||||
pub fn cos(x: f64) -> f64;
|
pub fn cos(x: f64) -> f64;
|
||||||
|
|
||||||
|
|
||||||
/// The Math.cosh() function returns the hyperbolic cosine of a number,
|
/// The Math.cosh() function returns the hyperbolic cosine of a number,
|
||||||
/// that can be expressed using the constant e.
|
/// that can be expressed using the constant e.
|
||||||
///
|
///
|
||||||
@ -2028,7 +2052,8 @@ extern "C" {
|
|||||||
///
|
///
|
||||||
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign)
|
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign)
|
||||||
#[wasm_bindgen(static_method_of = Object, js_name = assign)]
|
#[wasm_bindgen(static_method_of = Object, js_name = assign)]
|
||||||
pub fn assign3(target: &Object, source1: &Object, source2: &Object, source3: &Object) -> Object;
|
pub fn assign3(target: &Object, source1: &Object, source2: &Object, source3: &Object)
|
||||||
|
-> Object;
|
||||||
|
|
||||||
/// The Object.create() method creates a new object, using an existing
|
/// The Object.create() method creates a new object, using an existing
|
||||||
/// object to provide the newly created object's prototype.
|
/// object to provide the newly created object's prototype.
|
||||||
@ -2245,7 +2270,7 @@ impl Object {
|
|||||||
|
|
||||||
// Proxy
|
// Proxy
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
extern {
|
extern "C" {
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub type Proxy;
|
pub type Proxy;
|
||||||
|
|
||||||
@ -2267,7 +2292,7 @@ extern {
|
|||||||
|
|
||||||
// RangeError
|
// RangeError
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
extern {
|
extern "C" {
|
||||||
/// The RangeError object indicates an error when a value is not in the set
|
/// The RangeError object indicates an error when a value is not in the set
|
||||||
/// or range of allowed values.
|
/// or range of allowed values.
|
||||||
///
|
///
|
||||||
@ -2286,7 +2311,7 @@ extern {
|
|||||||
|
|
||||||
// ReferenceError
|
// ReferenceError
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
extern {
|
extern "C" {
|
||||||
/// The ReferenceError object represents an error when a non-existent
|
/// The ReferenceError object represents an error when a non-existent
|
||||||
/// variable is referenced.
|
/// variable is referenced.
|
||||||
///
|
///
|
||||||
@ -2625,7 +2650,7 @@ extern "C" {
|
|||||||
|
|
||||||
// Set
|
// Set
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
extern {
|
extern "C" {
|
||||||
#[wasm_bindgen(extends = Object)]
|
#[wasm_bindgen(extends = Object)]
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub type Set;
|
pub type Set;
|
||||||
@ -2681,7 +2706,7 @@ extern {
|
|||||||
|
|
||||||
// SetIterator
|
// SetIterator
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
extern {
|
extern "C" {
|
||||||
/// The `entries()` method returns a new Iterator object that contains an
|
/// The `entries()` method returns a new Iterator object that contains an
|
||||||
/// array of [value, value] for each element in the Set object, in insertion
|
/// array of [value, value] for each element in the Set object, in insertion
|
||||||
/// order. For Set objects there is no key like in Map objects. However, to
|
/// order. For Set objects there is no key like in Map objects. However, to
|
||||||
@ -2710,7 +2735,7 @@ extern {
|
|||||||
|
|
||||||
// SyntaxError
|
// SyntaxError
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
extern {
|
extern "C" {
|
||||||
/// A SyntaxError is thrown when the JavaScript engine encounters tokens or
|
/// A SyntaxError is thrown when the JavaScript engine encounters tokens or
|
||||||
/// token order that does not conform to the syntax of the language when
|
/// token order that does not conform to the syntax of the language when
|
||||||
/// parsing code.
|
/// parsing code.
|
||||||
@ -2731,7 +2756,7 @@ extern {
|
|||||||
|
|
||||||
// TypeError
|
// TypeError
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
extern {
|
extern "C" {
|
||||||
/// The TypeError object represents an error when a value is not of the
|
/// The TypeError object represents an error when a value is not of the
|
||||||
/// expected type.
|
/// expected type.
|
||||||
///
|
///
|
||||||
@ -2964,7 +2989,7 @@ extern "C" {
|
|||||||
|
|
||||||
// URIError
|
// URIError
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
extern {
|
extern "C" {
|
||||||
/// The URIError object represents an error when a global URI handling
|
/// The URIError object represents an error when a global URI handling
|
||||||
/// function was used in a wrong way.
|
/// function was used in a wrong way.
|
||||||
///
|
///
|
||||||
@ -3508,7 +3533,12 @@ extern "C" {
|
|||||||
///
|
///
|
||||||
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare)
|
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare)
|
||||||
#[wasm_bindgen(method, js_class = "String", js_name = localeCompare)]
|
#[wasm_bindgen(method, js_class = "String", js_name = localeCompare)]
|
||||||
pub fn locale_compare(this: &JsString, compare_string: &str, locales: &Array, options: &Object) -> i32;
|
pub fn locale_compare(
|
||||||
|
this: &JsString,
|
||||||
|
compare_string: &str,
|
||||||
|
locales: &Array,
|
||||||
|
options: &Object,
|
||||||
|
) -> i32;
|
||||||
|
|
||||||
/// The match() method retrieves the matches when matching a string against a regular expression.
|
/// The match() method retrieves the matches when matching a string against a regular expression.
|
||||||
///
|
///
|
||||||
@ -3560,14 +3590,22 @@ extern "C" {
|
|||||||
|
|
||||||
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace)
|
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace)
|
||||||
#[wasm_bindgen(method, js_class = "String", js_name = replace)]
|
#[wasm_bindgen(method, js_class = "String", js_name = replace)]
|
||||||
pub fn replace_with_function(this: &JsString, pattern: &str, replacement: &Function) -> JsString;
|
pub fn replace_with_function(
|
||||||
|
this: &JsString,
|
||||||
|
pattern: &str,
|
||||||
|
replacement: &Function,
|
||||||
|
) -> JsString;
|
||||||
|
|
||||||
#[wasm_bindgen(method, js_class = "String", js_name = replace)]
|
#[wasm_bindgen(method, js_class = "String", js_name = replace)]
|
||||||
pub fn replace_by_pattern(this: &JsString, pattern: &RegExp, replacement: &str) -> JsString;
|
pub fn replace_by_pattern(this: &JsString, pattern: &RegExp, replacement: &str) -> JsString;
|
||||||
|
|
||||||
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace)
|
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace)
|
||||||
#[wasm_bindgen(method, js_class = "String", js_name = replace)]
|
#[wasm_bindgen(method, js_class = "String", js_name = replace)]
|
||||||
pub fn replace_by_pattern_with_function(this: &JsString, pattern: &RegExp, replacement: &Function) -> JsString;
|
pub fn replace_by_pattern_with_function(
|
||||||
|
this: &JsString,
|
||||||
|
pattern: &RegExp,
|
||||||
|
replacement: &Function,
|
||||||
|
) -> JsString;
|
||||||
|
|
||||||
/// The search() method executes a search for a match between
|
/// The search() method executes a search for a match between
|
||||||
/// a regular expression and this String object.
|
/// a regular expression and this String object.
|
||||||
@ -4210,7 +4248,7 @@ pub mod Intl {
|
|||||||
|
|
||||||
// Promise
|
// Promise
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
extern {
|
extern "C" {
|
||||||
/// The `Promise` object represents the eventual completion (or failure) of
|
/// The `Promise` object represents the eventual completion (or failure) of
|
||||||
/// an asynchronous operation, and its resulting value.
|
/// an asynchronous operation, and its resulting value.
|
||||||
///
|
///
|
||||||
@ -4289,9 +4327,11 @@ extern {
|
|||||||
|
|
||||||
/// Same as `then`, only with both arguments provided.
|
/// Same as `then`, only with both arguments provided.
|
||||||
#[wasm_bindgen(method, js_name = then)]
|
#[wasm_bindgen(method, js_name = then)]
|
||||||
pub fn then2(this: &Promise,
|
pub fn then2(
|
||||||
resolve: &Closure<FnMut(JsValue)>,
|
this: &Promise,
|
||||||
reject: &Closure<FnMut(JsValue)>) -> Promise;
|
resolve: &Closure<FnMut(JsValue)>,
|
||||||
|
reject: &Closure<FnMut(JsValue)>,
|
||||||
|
) -> Promise;
|
||||||
|
|
||||||
/// The `finally()` method returns a `Promise`. When the promise is settled,
|
/// The `finally()` method returns a `Promise`. When the promise is settled,
|
||||||
/// whether fulfilled or rejected, the specified callback function is
|
/// whether fulfilled or rejected, the specified callback function is
|
||||||
|
Loading…
Reference in New Issue
Block a user