2018-06-08 16:46:51 -07:00
//! Bindings to JavaScript's standard, built-in objects, including their methods
//! and properties.
//!
//! This does *not* include any Web, Node, or any other JS environment
//! APIs. Only the things that are guaranteed to exist in the global scope by
//! the ECMAScript standard.
//!
//! https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects
//!
//! ## A Note About `camelCase`, `snake_case`, and Naming Conventions
//!
//! JavaScript's global objects use `camelCase` naming conventions for functions
//! and methods, but Rust style is to use `snake_case`. These bindings expose
//! the Rust style `snake_case` name. Additionally, acronyms within a method
//! name are all lower case, where as in JavaScript they are all upper case. For
//! example, `decodeURI` in JavaScript is exposed as `decode_uri` in these
//! bindings.
use wasm_bindgen_macro ::* ;
use JsValue ;
if_std! {
use std ::prelude ::v1 ::* ;
}
// When adding new imports:
//
// * Keep imports in alphabetical order.
//
// * Rename imports with `js_name = ...` according to the note about `camelCase`
// and `snake_case` in the module's documentation above.
//
// * Include the one sentence summary of the import from the MDN link in the
// module's documentation above, and the MDN link itself.
//
// * If a function or method can throw an exception, make it catchable by adding
// `#[wasm_bindgen(catch)]`.
//
2018-06-27 08:33:37 +02:00
// * Add a new `#[test]` into the appropriate file in the
// `tests/all/js_globals/` directory. If the imported function or
// method can throw an exception, make sure to also add test coverage
// for that case.
2018-06-08 16:46:51 -07:00
#[ wasm_bindgen ]
2018-06-27 22:42:34 -07:00
extern " C " {
2018-06-08 16:46:51 -07:00
/// The `decodeURI()` function decodes a Uniform Resource Identifier (URI)
/// previously created by `encodeURI` or by a similar routine.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURI
#[ wasm_bindgen(catch, js_name = decodeURI) ]
2018-06-23 16:59:49 -07:00
pub fn decode_uri ( encoded : & str ) -> Result < JsString , JsValue > ;
2018-06-08 16:46:51 -07:00
2018-07-01 15:59:12 +03:00
/// The decodeURIComponent() function decodes a Uniform Resource Identifier (URI) component
/// previously created by encodeURIComponent or by a similar routine.
2018-07-05 13:02:40 -07:00
///
2018-07-01 15:53:44 +03:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent
#[ wasm_bindgen(catch, js_name = decodeURIComponent) ]
pub fn decode_uri_component ( encoded : & str ) -> Result < JsString , JsValue > ;
2018-06-08 16:46:51 -07:00
/// The `encodeURI()` function encodes a Uniform Resource Identifier (URI)
/// by replacing each instance of certain characters by one, two, three, or
/// four escape sequences representing the UTF-8 encoding of the character
/// (will only be four escape sequences for characters composed of two
/// "surrogate" characters).
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI
#[ wasm_bindgen(js_name = encodeURI) ]
2018-06-23 16:59:49 -07:00
pub fn encode_uri ( decoded : & str ) -> JsString ;
2018-06-08 16:46:51 -07:00
2018-07-01 15:59:12 +03:00
/// The encodeURIComponent() function encodes a Uniform Resource Identifier (URI) component
/// by replacing each instance of certain characters by one, two, three, or four escape sequences
/// representing the UTF-8 encoding of the character
/// (will only be four escape sequences for characters composed of two "surrogate" characters).
2018-07-05 13:02:40 -07:00
///
2018-07-01 15:59:12 +03:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent
#[ wasm_bindgen(js_name = encodeURIComponent) ]
pub fn encode_uri_component ( decoded : & str ) -> JsString ;
2018-06-08 16:46:51 -07:00
/// The `eval()` function evaluates JavaScript code represented as a string.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval
#[ wasm_bindgen(catch) ]
pub fn eval ( js_source_text : & str ) -> Result < JsValue , JsValue > ;
}
2018-06-26 00:34:17 -04:00
// UInt8Array
#[ wasm_bindgen ]
2018-06-27 22:42:34 -07:00
extern " C " {
2018-06-26 00:34:17 -04:00
pub type Uint8Array ;
/// The `Uint8Array()` constructor creates an array of unsigned 8-bit integers.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array
#[ wasm_bindgen(constructor) ]
pub fn new ( constructor_arg : JsValue ) -> Uint8Array ;
/// The fill() method fills all the elements of an array from a start index
/// to an end index with a static value. The end index is not included.
///
/// http://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/fill
#[ wasm_bindgen(method) ]
pub fn fill ( this : & Uint8Array , value : JsValue , start : u32 , end : u32 ) -> Uint8Array ;
}
2018-06-21 22:16:24 +02:00
// Array
2018-06-08 16:46:51 -07:00
#[ wasm_bindgen ]
2018-06-27 22:42:34 -07:00
extern " C " {
2018-06-21 22:16:24 +02:00
pub type Array ;
2018-06-08 16:46:51 -07:00
2018-06-25 20:33:39 +02:00
/// The copyWithin() method shallow copies part of an array to another
/// location in the same array and returns it, without modifying its size.
2018-06-08 16:46:51 -07:00
///
2018-06-21 22:16:24 +02:00
/// http://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin
#[ wasm_bindgen(method, js_name = copyWithin) ]
pub fn copy_within ( this : & Array , target : i32 , start : i32 , end : i32 ) -> Array ;
2018-06-20 20:46:04 +02:00
2018-06-25 16:17:53 -07:00
/// The concat() method is used to merge two or more arrays. This method
2018-06-22 18:25:19 +02:00
/// does not change the existing arrays, but instead returns a new array.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat
#[ wasm_bindgen(method) ]
pub fn concat ( this : & Array , array : & Array ) -> Array ;
2018-06-27 13:45:47 +02:00
/// The every() method tests whether all elements in the array pass the test
/// implemented by the provided function.
2018-06-27 22:42:34 -07:00
///
2018-06-27 13:45:47 +02:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every
#[ wasm_bindgen(method) ]
pub fn every ( this : & Array , predicate : & mut FnMut ( JsValue , u32 , Array ) -> bool ) -> bool ;
2018-06-25 20:33:39 +02:00
/// The fill() method fills all the elements of an array from a start index
/// to an end index with a static value. The end index is not included.
2018-06-20 20:46:04 +02:00
///
2018-06-21 22:16:24 +02:00
/// http://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fill
#[ wasm_bindgen(method) ]
pub fn fill ( this : & Array , value : JsValue , start : u32 , end : u32 ) -> Array ;
2018-06-20 17:16:57 -04:00
2018-06-25 16:19:07 -07:00
/// The `filter()` method creates a new array with all elements that pass the
/// test implemented by the provided function.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter
#[ wasm_bindgen(method) ]
pub fn filter ( this : & Array , predicate : & mut FnMut ( JsValue , u32 , Array ) -> bool ) -> Array ;
2018-07-05 15:05:23 -07:00
/// The `find()` method returns the value of the first element in the array that satisfies
/// the provided testing function. Otherwise `undefined` is returned.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find
#[ wasm_bindgen(method) ]
pub fn find ( this : & Array , predicate : & mut FnMut ( JsValue , u32 , Array ) -> bool ) -> JsValue ;
2018-06-26 10:18:31 -07:00
/// The includes() method determines whether an array includes a certain
/// element, returning true or false as appropriate.
2018-06-22 10:45:33 -07:00
///
2018-06-26 10:18:31 -07:00
/// http://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes
#[ wasm_bindgen(method) ]
pub fn includes ( this : & Array , value : JsValue , from_index : i32 ) -> bool ;
2018-06-21 21:30:57 -07:00
2018-06-25 20:33:39 +02:00
/// The indexOf() method returns the first index at which a given element
/// can be found in the array, or -1 if it is not present.
2018-06-20 17:16:57 -04:00
///
/// http://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf
#[ wasm_bindgen(method, js_name = indexOf) ]
pub fn index_of ( this : & Array , value : JsValue , from_index : i32 ) -> i32 ;
2018-06-20 17:36:35 -04:00
2018-06-26 11:04:28 -07:00
/// The Array.isArray() method determines whether the passed value is an Array.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray
#[ wasm_bindgen(static_method_of = Array, js_name = isArray) ]
pub fn is_array ( value : & JsValue ) -> bool ;
2018-06-21 22:16:24 +02:00
/// The join() method joins all elements of an array (or an array-like object)
/// into a string and returns this string.
2018-06-20 17:38:47 -04:00
///
/// http://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join
#[ wasm_bindgen(method) ]
2018-06-23 16:59:49 -07:00
pub fn join ( this : & Array , delimiter : & str ) -> JsString ;
2018-06-20 17:46:10 -04:00
2018-06-25 20:33:39 +02:00
/// The lastIndexOf() method returns the last index at which a given element
/// can be found in the array, or -1 if it is not present. The array is
/// searched backwards, starting at fromIndex.
2018-06-20 17:51:02 -04:00
///
2018-06-21 22:16:24 +02:00
/// http://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf
#[ wasm_bindgen(method, js_name = lastIndexOf) ]
pub fn last_index_of ( this : & Array , value : JsValue , from_index : i32 ) -> i32 ;
2018-06-20 17:55:25 -04:00
2018-06-26 10:18:31 -07:00
/// The length property of an object which is an instance of type Array
/// sets or returns the number of elements in that array. The value is an
/// unsigned, 32-bit integer that is always numerically greater than the
/// highest index in the array.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/length
#[ wasm_bindgen(method, getter, structural) ]
pub fn length ( this : & Array ) -> u32 ;
2018-06-25 20:33:39 +02:00
/// The pop() method removes the last element from an array and returns that
/// element. This method changes the length of the array.
2018-06-20 17:55:25 -04:00
///
/// http://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/pop
#[ wasm_bindgen(method) ]
pub fn pop ( this : & Array ) -> JsValue ;
2018-06-20 17:58:15 -04:00
2018-06-25 20:33:39 +02:00
/// The push() method adds one or more elements to the end of an array and
/// returns the new length of the array.
2018-06-20 17:58:15 -04:00
///
/// http://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push
#[ wasm_bindgen(method) ]
pub fn push ( this : & Array , value : JsValue ) -> u32 ;
2018-06-20 18:00:58 -04:00
2018-06-25 20:33:39 +02:00
/// The reverse() method reverses an array in place. The first array
/// element becomes the last, and the last array element becomes the first.
2018-06-21 22:16:24 +02:00
///
2018-06-20 18:00:58 -04:00
/// http://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse
#[ wasm_bindgen(method) ]
pub fn reverse ( this : & Array ) -> Array ;
2018-06-20 18:03:26 -04:00
2018-06-26 10:18:31 -07:00
/// The shift() method removes the first element from an array and returns
/// that removed element. This method changes the length of the array.
///
/// http://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/shift
#[ wasm_bindgen(method) ]
pub fn shift ( this : & Array ) -> JsValue ;
2018-06-25 20:33:39 +02:00
/// The slice() method returns a shallow copy of a portion of an array into
/// a new array object selected from begin to end (end not included).
2018-06-21 22:16:24 +02:00
/// The original array will not be modified.
///
/// http://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice
#[ wasm_bindgen(method) ]
pub fn slice ( this : & Array , start : u32 , end : u32 ) -> Array ;
2018-06-28 13:57:01 -07:00
/// The some() method tests whether at least one element in the array passes the test implemented
/// by the provided function.
/// Note: This method returns false for any condition put on an empty array.
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some
#[ wasm_bindgen(method) ]
pub fn some ( this : & Array , predicate : & mut FnMut ( JsValue ) -> bool ) -> bool ;
2018-06-22 00:09:49 +02:00
/// The sort() method sorts the elements of an array in place and returns
/// the array. The sort is not necessarily stable. The default sort
/// order is according to string Unicode code points.
///
/// The time and space complexity of the sort cannot be guaranteed as it
/// is implementation dependent.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort
2018-06-20 18:06:08 -04:00
#[ wasm_bindgen(method) ]
2018-06-22 00:09:49 +02:00
pub fn sort ( this : & Array ) -> Array ;
2018-06-20 18:23:26 -04:00
2018-06-25 20:33:39 +02:00
/// The toString() method returns a string representing the specified array
/// and its elements.
2018-06-20 18:23:26 -04:00
///
/// http://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toString
#[ wasm_bindgen(method, js_name = toString) ]
2018-06-23 16:59:49 -07:00
pub fn to_string ( this : & Array ) -> JsString ;
2018-06-20 18:27:10 -04:00
2018-06-25 20:33:39 +02:00
/// The unshift() method adds one or more elements to the beginning of an
/// array and returns the new length of the array.
2018-06-20 18:27:10 -04:00
///
2018-06-21 22:16:24 +02:00
/// http://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/unshift
2018-06-20 18:27:10 -04:00
#[ wasm_bindgen(method) ]
2018-06-21 22:16:24 +02:00
pub fn unshift ( this : & Array , value : JsValue ) -> u32 ;
2018-06-21 17:00:02 -04:00
}
2018-06-20 18:27:10 -04:00
2018-07-04 20:53:49 +02:00
// ArrayBuffer
#[ wasm_bindgen ]
extern " C " {
pub type ArrayBuffer ;
/// The `ArrayBuffer` object is used to represent a generic,
/// fixed-length raw binary data buffer. You cannot directly
/// manipulate the contents of an `ArrayBuffer`; instead, you
/// create one of the typed array objects or a `DataView` object
/// which represents the buffer in a specific format, and use that
/// to read and write the contents of the buffer.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer
#[ wasm_bindgen(constructor) ]
pub fn new ( length : u32 ) -> ArrayBuffer ;
/// The `slice()` method returns a new `ArrayBuffer` whose contents
/// are a copy of this `ArrayBuffer`'s bytes from begin, inclusive,
/// up to end, exclusive.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/isView
#[ wasm_bindgen(static_method_of = ArrayBuffer, js_name = isView) ]
pub fn is_view ( value : JsValue ) -> bool ;
/// The `slice()` method returns a new `ArrayBuffer` whose contents
/// are a copy of this `ArrayBuffer`'s bytes from begin, inclusive,
/// up to end, exclusive.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/slice
#[ wasm_bindgen(method) ]
pub fn slice ( this : & ArrayBuffer , begin : u32 ) -> ArrayBuffer ;
/// Like `slice()` but with the `end` argument.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/slice
#[ wasm_bindgen(method, js_name = slice) ]
pub fn slice_with_end ( this : & ArrayBuffer , begin : u32 , end : u32 ) -> ArrayBuffer ;
}
2018-06-21 17:11:08 -04:00
// Array Iterator
2018-06-21 17:00:02 -04:00
#[ wasm_bindgen ]
2018-06-27 22:42:34 -07:00
extern " C " {
2018-06-21 17:00:02 -04:00
pub type ArrayIterator ;
2018-06-20 18:27:10 -04:00
2018-06-25 20:33:39 +02:00
/// The keys() method returns a new Array Iterator object that contains the
/// keys for each index in the array.
2018-06-21 17:00:02 -04:00
///
/// http://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/keys
#[ wasm_bindgen(method) ]
pub fn keys ( this : & Array ) -> ArrayIterator ;
2018-06-21 17:11:08 -04:00
2018-06-25 20:33:39 +02:00
/// The entries() method returns a new Array Iterator object that contains
/// the key/value pairs for each index in the array.
2018-06-21 17:11:08 -04:00
///
/// http://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/entries
#[ wasm_bindgen(method) ]
pub fn entries ( this : & Array ) -> ArrayIterator ;
2018-06-21 22:16:24 +02:00
}
2018-06-27 09:07:47 +02:00
// Boolean
#[ wasm_bindgen ]
2018-06-27 22:42:34 -07:00
extern " C " {
2018-06-27 09:07:47 +02:00
pub type Boolean ;
/// The `Boolean()` constructor creates an object wrapper for a boolean value.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean
#[ wasm_bindgen(constructor) ]
pub fn new ( value : JsValue ) -> Boolean ;
/// The `valueOf()` method returns the primitive value of a `Boolean` object.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean/valueOf
#[ wasm_bindgen(method, js_name = valueOf) ]
pub fn value_of ( this : & Boolean ) -> bool ;
}
2018-06-29 22:46:27 +09:00
// Error
#[ wasm_bindgen ]
extern " C " {
pub type Error ;
/// The Error constructor creates an error object.
/// Instances of Error objects are thrown when runtime errors occur.
/// The Error object can also be used as a base object for user-defined exceptions.
/// See below for standard built-in error types.
2018-07-05 13:02:40 -07:00
///
2018-06-29 22:46:27 +09:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error
#[ wasm_bindgen(constructor) ]
pub fn new ( message : & JsString ) -> Error ;
/// The message property is a human-readable description of the error.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/message
#[ wasm_bindgen(method, getter, structural) ]
pub fn message ( this : & Error ) -> JsString ;
#[ wasm_bindgen(method, setter, structural) ]
pub fn set_message ( this : & Error , message : & JsString ) ;
/// The name property represents a name for the type of error. The initial value is "Error".
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/name
#[ wasm_bindgen(method, getter, structural) ]
pub fn name ( this : & Error ) -> JsString ;
#[ wasm_bindgen(method, setter, structural) ]
pub fn set_name ( this : & Error , name : & JsString ) ;
/// The toString() method returns a string representing the specified Error object
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/toString
#[ wasm_bindgen(method, js_name = toString) ]
pub fn to_string ( this : & Error ) -> JsString ;
}
2018-06-23 23:41:28 +03:00
// Function
#[ wasm_bindgen ]
2018-06-27 22:42:34 -07:00
extern " C " {
2018-06-26 21:35:28 +03:00
pub type Function ;
/// The apply() method calls a function with a given this value, and arguments provided as an array
/// (or an array-like object).
2018-06-27 22:42:34 -07:00
///
2018-06-26 21:35:28 +03:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/apply
#[ wasm_bindgen(method) ]
pub fn apply ( this : & Function , context : & JsValue , args : & Array ) -> Function ;
2018-06-23 23:41:28 +03:00
2018-07-01 15:44:36 +03:00
/// 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.
2018-07-05 13:02:40 -07:00
///
2018-07-01 15:44:36 +03:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind
#[ wasm_bindgen(method) ]
pub fn bind ( this : & Function , context : & JsValue ) -> Function ;
2018-06-23 23:41:28 +03:00
/// The length property indicates the number of arguments expected by the function.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/length
#[ wasm_bindgen(method, getter, structural) ]
2018-06-26 21:35:28 +03:00
pub fn length ( this : & Function ) -> u32 ;
2018-06-23 23:41:28 +03:00
2018-06-25 20:33:39 +02:00
/// A Function object's read-only name property indicates the function's
/// name as specified when it was created or "anonymous" for functions
/// created anonymously.
2018-06-23 23:41:28 +03:00
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name
#[ wasm_bindgen(method, getter, structural) ]
2018-06-26 21:35:28 +03:00
pub fn name ( this : & Function ) -> JsString ;
/// The toString() method returns a string representing the source code of the function.
2018-06-27 22:42:34 -07:00
///
2018-06-26 21:35:28 +03:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/toString
#[ wasm_bindgen(method, js_name = toString) ]
pub fn to_string ( this : & Function ) -> JsString ;
2018-06-23 23:41:28 +03:00
}
2018-07-03 23:42:49 +03:00
// Generator
#[ wasm_bindgen ]
extern {
pub type Generator ;
/// The next() method returns an object with two properties done and value.
/// You can also provide a parameter to the next method to send a value to the generator.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/next
2018-07-04 01:22:56 +03:00
#[ wasm_bindgen(method, structural, catch) ]
pub fn next ( this : & Generator , value : & JsValue ) -> Result < JsValue , JsValue > ;
/// The return() method returns the given value and finishes the generator.
2018-07-05 13:02:40 -07:00
///
2018-07-04 01:22:56 +03:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/return
#[ wasm_bindgen(method, structural, js_name = return) ]
pub fn return_ ( this : & Generator , value : & JsValue ) -> JsValue ;
2018-07-03 23:48:54 +03:00
/// The throw() method resumes the execution of a generator by throwing an error into it
/// and returns an object with two properties done and value.
2018-07-05 13:02:40 -07:00
///
2018-07-03 23:48:54 +03:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/throw
2018-07-04 01:22:56 +03:00
#[ wasm_bindgen(method, structural, catch) ]
pub fn throw ( this : & Generator , error : & Error ) -> Result < JsValue , JsValue > ;
2018-07-03 23:42:49 +03:00
}
2018-06-28 21:51:39 +02:00
// Map
2018-06-25 21:41:28 +02:00
#[ wasm_bindgen ]
extern {
2018-06-28 21:51:39 +02:00
pub type Map ;
/// The clear() method removes all elements from a Map object.
2018-07-05 13:02:40 -07:00
///
2018-06-28 21:51:39 +02:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/clear
#[ wasm_bindgen(method) ]
pub fn clear ( this : & Map ) ;
2018-06-28 21:52:27 +02:00
/// The delete() method removes the specified element from a Map object.
2018-07-05 13:02:40 -07:00
///
2018-06-28 21:52:27 +02:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/delete
#[ wasm_bindgen(method) ]
pub fn delete ( this : & Map , key : & str ) -> bool ;
2018-06-28 21:53:20 +02:00
/// The get() method returns a specified element from a Map object.
2018-07-05 13:02:40 -07:00
///
2018-06-28 21:53:20 +02:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/get
#[ wasm_bindgen(method) ]
pub fn get ( this : & Map , key : & JsValue ) -> JsValue ;
2018-06-28 21:54:10 +02:00
2018-07-05 13:02:40 -07:00
/// The has() method returns a boolean indicating whether an element with
2018-06-28 21:54:10 +02:00
/// the specified key exists or not.
2018-07-05 13:02:40 -07:00
///
2018-06-28 21:54:10 +02:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/has
#[ wasm_bindgen(method) ]
pub fn has ( this : & Map , key : & JsValue ) -> bool ;
2018-06-28 21:55:10 +02:00
2018-07-05 13:02:40 -07:00
/// The Map object holds key-value pairs. Any value (both objects and
2018-06-28 21:55:10 +02:00
/// primitive values) maybe used as either a key or a value.
2018-07-05 13:02:40 -07:00
///
2018-06-28 21:55:10 +02:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map
#[ wasm_bindgen(constructor) ]
pub fn new ( ) -> Map ;
2018-06-28 21:55:55 +02:00
2018-07-05 13:02:40 -07:00
/// The set() method adds or updates an element with a specified key
2018-06-28 21:55:55 +02:00
/// and value to a Map object.
2018-07-05 13:02:40 -07:00
///
2018-06-28 21:55:55 +02:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/set
#[ wasm_bindgen(method) ]
pub fn set ( this : & Map , key : & JsValue , value : & JsValue ) -> Map ;
2018-06-28 21:56:49 +02:00
2018-07-05 13:02:40 -07:00
/// The value of size is an integer representing how many entries
/// the Map object has. A set accessor function for size is undefined;
2018-06-28 21:56:49 +02:00
/// you can not change this property.
2018-07-05 13:02:40 -07:00
///
2018-06-28 21:56:49 +02:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/size
#[ wasm_bindgen(method, getter, structural) ]
2018-07-05 13:02:40 -07:00
pub fn size ( this : & Map ) -> u32 ;
2018-06-28 21:51:39 +02:00
}
2018-06-28 21:58:34 +02:00
// Map Iterator
#[ wasm_bindgen ]
extern {
pub type MapIterator ;
2018-07-05 13:02:40 -07:00
/// The entries() method returns a new Iterator object that contains
/// the [key, value] pairs for each element in the Map object in
2018-06-28 21:58:34 +02:00
/// insertion order.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/entries
#[ wasm_bindgen(method) ]
pub fn entries ( this : & Map ) -> MapIterator ;
2018-06-28 21:59:11 +02:00
2018-07-05 13:02:40 -07:00
/// The keys() method returns a new Iterator object that contains the
2018-06-28 21:59:11 +02:00
/// keys for each element in the Map object in insertion order.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/keys
#[ wasm_bindgen(method) ]
pub fn keys ( this : & Map ) -> MapIterator ;
2018-06-28 22:00:02 +02:00
2018-07-05 13:02:40 -07:00
/// The values() method returns a new Iterator object that contains the
2018-06-28 22:00:02 +02:00
/// values for each element in the Map object in insertion order.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/values
#[ wasm_bindgen(method) ]
pub fn values ( this : & Map ) -> MapIterator ;
2018-06-28 21:58:34 +02:00
}
2018-06-25 21:41:28 +02:00
// Math
#[ wasm_bindgen ]
2018-06-27 22:42:34 -07:00
extern " C " {
2018-06-25 21:41:28 +02:00
pub type Math ;
2018-07-05 13:02:40 -07:00
2018-06-25 21:41:28 +02:00
/// The Math.abs() function returns the absolute value of a number, that is
/// Math.abs(x) = |x|
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/abs
#[ wasm_bindgen(static_method_of = Math) ]
2018-07-05 13:02:40 -07:00
pub fn abs ( x : f64 ) -> f64 ;
2018-06-25 21:46:01 +02:00
/// The Math.acos() function returns the arccosine (in radians) of a
/// number, that is ∀x∊[-1;1]
/// Math.acos(x) = arccos(x) = the unique y∊[0;π] such that cos(y)=x
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/acos
#[ wasm_bindgen(static_method_of = Math) ]
2018-07-05 13:02:40 -07:00
pub fn acos ( x : f64 ) -> f64 ;
2018-06-25 21:46:01 +02:00
2018-06-25 21:54:24 +02:00
/// The Math.acosh() function returns the hyperbolic arc-cosine of a
/// number, that is ∀x ≥ 1
/// Math.acosh(x) = arcosh(x) = the unique y ≥ 0 such that cosh(y) = x
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/acosh
#[ wasm_bindgen(static_method_of = Math) ]
2018-07-05 13:02:40 -07:00
pub fn acosh ( x : f64 ) -> f64 ;
2018-06-25 21:54:24 +02:00
2018-06-25 22:04:59 +02:00
/// The Math.asin() function returns the arcsine (in radians) of a
/// number, that is ∀x ∊ [-1;1]
/// Math.asin(x) = arcsin(x) = the unique y∊[-π2;π2] such that sin(y) = x
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/asin
#[ wasm_bindgen(static_method_of = Math) ]
2018-07-05 13:02:40 -07:00
pub fn asin ( x : f64 ) -> f64 ;
2018-06-25 22:04:59 +02:00
2018-06-25 22:23:24 +02:00
/// The Math.asinh() function returns the hyperbolic arcsine of a
/// number, that is Math.asinh(x) = arsinh(x) = the unique y such that sinh(y) = x
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/asinh
#[ wasm_bindgen(static_method_of = Math) ]
2018-07-05 13:02:40 -07:00
pub fn asinh ( x : f64 ) -> f64 ;
2018-06-25 22:23:24 +02:00
2018-06-25 22:23:58 +02:00
/// The Math.atan() function returns the arctangent (in radians) of a
/// number, that is Math.atan(x) = arctan(x) = the unique y ∊ [-π2;π2]such that
/// tan(y) = x
#[ wasm_bindgen(static_method_of = Math) ]
2018-07-05 13:02:40 -07:00
pub fn atan ( x : f64 ) -> f64 ;
2018-06-25 22:23:24 +02:00
2018-06-25 22:27:55 +02:00
/// The Math.atan2() function returns the arctangent of the quotient of
/// its arguments.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atan2
#[ wasm_bindgen(static_method_of = Math) ]
2018-07-05 13:02:40 -07:00
pub fn atan2 ( y : f64 , x : f64 ) -> f64 ;
2018-06-25 22:27:55 +02:00
2018-06-25 22:32:04 +02:00
/// The Math.atanh() function returns the hyperbolic arctangent of a number,
/// that is ∀x ∊ (-1,1), Math.atanh(x) = arctanh(x) = the unique y such that
/// tanh(y) = x
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atanh
#[ wasm_bindgen(static_method_of = Math) ]
2018-07-05 13:02:40 -07:00
pub fn atanh ( x : f64 ) -> f64 ;
2018-06-25 22:35:55 +02:00
/// The Math.cbrt() function returns the cube root of a number, that is
/// Math.cbrt(x) = x^3 = the unique y such that y^3 = x
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cbrt
#[ wasm_bindgen(static_method_of = Math) ]
2018-07-05 13:02:40 -07:00
pub fn cbrt ( x : f64 ) -> f64 ;
2018-06-25 22:35:55 +02:00
2018-06-25 22:41:22 +02:00
/// The Math.ceil() function returns the smallest integer greater than
/// or equal to a given number.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/ceil
#[ wasm_bindgen(static_method_of = Math) ]
2018-07-05 13:02:40 -07:00
pub fn ceil ( x : f64 ) -> i32 ;
2018-06-25 22:47:21 +02:00
/// The Math.clz32() function returns the number of leading zero bits in
/// the 32-bit binary representation of a number.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/clz32
#[ wasm_bindgen(static_method_of = Math) ]
2018-07-05 13:02:40 -07:00
pub fn clz32 ( x : i32 ) -> u32 ;
2018-06-27 10:44:43 +05:30
2018-06-28 12:46:53 -04:00
/// The Math.cos() static function returns the cosine of the specified angle,
/// which must be specified in radians. This value is length(adjacent)/length(hypotenuse).
2018-06-28 15:05:10 -04:00
///
2018-06-28 12:46:53 -04:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cos
#[ wasm_bindgen(static_method_of = Math) ]
2018-07-05 13:02:40 -07:00
pub fn cos ( x : f64 ) -> f64 ;
2018-06-28 12:46:53 -04:00
/// The Math.cosh() function returns the hyperbolic cosine of a number,
/// that can be expressed using the constant e.
2018-06-28 15:05:10 -04:00
///
2018-06-28 12:46:53 -04:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cosh
#[ wasm_bindgen(static_method_of = Math) ]
2018-07-05 13:02:40 -07:00
pub fn cosh ( x : f64 ) -> f64 ;
2018-06-28 12:46:53 -04:00
/// The Math.exp() function returns e^x, where x is the argument, and e is Euler's number
/// (also known as Napier's constant), the base of the natural logarithms.
2018-06-28 15:05:10 -04:00
///
2018-06-28 12:46:53 -04:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/exp
#[ wasm_bindgen(static_method_of = Math) ]
2018-07-05 13:02:40 -07:00
pub fn exp ( x : f64 ) -> f64 ;
2018-06-28 12:46:53 -04:00
/// The Math.expm1() function returns e^x - 1, where x is the argument, and e the base of the
/// natural logarithms.
2018-06-28 15:05:10 -04:00
///
2018-06-28 12:46:53 -04:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/expm1
#[ wasm_bindgen(static_method_of = Math) ]
2018-07-05 13:02:40 -07:00
pub fn expm1 ( x : f64 ) -> f64 ;
2018-06-28 12:46:53 -04:00
2018-06-27 10:44:43 +05:30
/// The Math.floor() function returns the largest integer less than or
/// equal to a given number.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/floor
#[ wasm_bindgen(static_method_of = Math) ]
2018-07-05 13:02:40 -07:00
pub fn floor ( x : f64 ) -> i32 ;
2018-06-28 12:46:53 -04:00
/// The Math.fround() function returns the nearest 32-bit single precision float representation
/// of a Number.
2018-06-28 15:05:10 -04:00
///
2018-06-28 12:46:53 -04:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/fround
#[ wasm_bindgen(static_method_of = Math) ]
2018-07-05 13:02:40 -07:00
pub fn fround ( x : f64 ) -> f32 ;
2018-06-28 15:05:10 -04:00
2018-06-28 12:46:53 -04:00
/// The Math.imul() function returns the result of the C-like 32-bit multiplication of the
/// two parameters.
2018-06-28 15:05:10 -04:00
///
2018-06-28 12:46:53 -04:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul
#[ wasm_bindgen(static_method_of = Math) ]
2018-07-05 13:02:40 -07:00
pub fn imul ( x : i32 , y : i32 ) -> i32 ;
2018-06-28 12:46:53 -04:00
/// The Math.log() function returns the natural logarithm (base e) of a number.
/// The JavaScript Math.log() function is equivalent to ln(x) in mathematics.
2018-06-28 15:05:10 -04:00
///
2018-06-28 12:46:53 -04:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log
#[ wasm_bindgen(static_method_of = Math) ]
2018-07-05 13:02:40 -07:00
pub fn log ( x : f64 ) -> f64 ;
2018-06-28 12:46:53 -04:00
/// The Math.log10() function returns the base 10 logarithm of a number.
2018-06-28 15:05:10 -04:00
///
2018-06-28 12:46:53 -04:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log10
#[ wasm_bindgen(static_method_of = Math) ]
2018-07-05 13:02:40 -07:00
pub fn log10 ( x : f64 ) -> f64 ;
2018-06-28 12:46:53 -04:00
/// The Math.log1p() function returns the natural logarithm (base e) of 1 + a number.
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log1p
#[ wasm_bindgen(static_method_of = Math) ]
2018-07-05 13:02:40 -07:00
pub fn log1p ( x : f64 ) -> f64 ;
2018-06-28 12:46:53 -04:00
/// The Math.log2() function returns the base 2 logarithm of a number.
2018-06-28 15:05:10 -04:00
///
2018-06-28 12:46:53 -04:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log2
#[ wasm_bindgen(static_method_of = Math) ]
2018-07-05 13:02:40 -07:00
pub fn log2 ( x : f64 ) -> f64 ;
2018-06-28 12:46:53 -04:00
2018-07-03 19:31:17 +02:00
/// The Math.pow() function returns the base to the exponent power, that is, base^exponent.
2018-07-05 13:02:40 -07:00
///
2018-07-03 19:31:17 +02:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/pow
#[ wasm_bindgen(static_method_of = Math) ]
2018-07-05 13:02:40 -07:00
pub fn pow ( base : f64 , exponent : f64 ) -> f64 ;
2018-07-03 19:31:17 +02:00
/// The Math.round() function returns the value of a number rounded to the nearest integer.
2018-07-05 13:02:40 -07:00
///
2018-07-03 19:31:17 +02:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/round
#[ wasm_bindgen(static_method_of = Math) ]
2018-07-05 13:02:40 -07:00
pub fn round ( x : f64 ) -> i32 ;
2018-07-03 19:31:17 +02:00
/// The Math.sign() function returns the sign of a number, indicating whether the number is
/// positive, negative or zero.
2018-07-05 13:02:40 -07:00
///
2018-07-03 19:31:17 +02:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sign
#[ wasm_bindgen(static_method_of = Math) ]
2018-07-05 13:02:40 -07:00
pub fn sign ( x : f64 ) -> f64 ;
2018-07-03 19:31:17 +02:00
/// The Math.sin() function returns the sine of a number.
2018-07-05 13:02:40 -07:00
///
2018-07-03 19:31:17 +02:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sin
#[ wasm_bindgen(static_method_of = Math) ]
2018-07-05 13:02:40 -07:00
pub fn sin ( x : f64 ) -> f64 ;
2018-07-03 19:31:17 +02:00
/// The Math.sinh() function returns the hyperbolic sine of a number, that can be expressed
/// using the constant e: Math.sinh(x) = (e^x - e^-x)/2
2018-07-05 13:02:40 -07:00
///
2018-07-03 19:31:17 +02:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sinh
#[ wasm_bindgen(static_method_of = Math) ]
2018-07-05 13:02:40 -07:00
pub fn sinh ( x : f64 ) -> f64 ;
2018-07-03 19:31:17 +02:00
/// The Math.sqrt() function returns the square root of a number, that is
/// ∀x ≥ 0, Math.sqrt(x) = √x = the unique y ≥ 0 such that y^2 = x
2018-07-05 13:02:40 -07:00
///
2018-07-03 19:31:17 +02:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sqrt
#[ wasm_bindgen(static_method_of = Math) ]
2018-07-05 13:02:40 -07:00
pub fn sqrt ( x : f64 ) -> f64 ;
2018-07-03 19:31:17 +02:00
/// The Math.tan() function returns the tangent of a number.
2018-07-05 13:02:40 -07:00
///
2018-07-03 19:31:17 +02:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/tan
#[ wasm_bindgen(static_method_of = Math) ]
2018-07-05 13:02:40 -07:00
pub fn tan ( x : f64 ) -> f64 ;
2018-07-03 19:31:17 +02:00
/// The Math.tanh() function returns the hyperbolic tangent of a number, that is
/// tanh x = sinh x / cosh x = (e^x - e^-x)/(e^x + e^-x) = (e^2x - 1)/(e^2x + 1)
2018-07-05 13:02:40 -07:00
///
2018-07-03 19:31:17 +02:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/tanh
#[ wasm_bindgen(static_method_of = Math) ]
2018-07-05 13:02:40 -07:00
pub fn tanh ( x : f64 ) -> f64 ;
2018-07-03 19:31:17 +02:00
/// The Math.trunc() function returns the integer part of a number by removing any fractional
/// digits.
2018-07-05 13:02:40 -07:00
///
2018-07-03 19:31:17 +02:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/trunc
#[ wasm_bindgen(static_method_of = Math) ]
2018-07-05 13:02:40 -07:00
pub fn trunc ( x : f64 ) -> i32 ;
2018-06-25 21:41:28 +02:00
}
2018-06-23 14:43:43 +02:00
// Number.
#[ wasm_bindgen ]
2018-06-27 22:42:34 -07:00
extern " C " {
2018-06-23 14:43:43 +02:00
pub type Number ;
2018-07-02 23:06:46 +02:00
/// The Number.isInteger() method determines whether the passed value is an integer.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger
#[ wasm_bindgen(static_method_of = Number, js_name = isInteger) ]
pub fn is_integer ( object : & Object ) -> bool ;
2018-06-27 09:36:37 +02:00
/// The `Number` JavaScript object is a wrapper object allowing
/// you to work with numerical values. A `Number` object is
/// created using the `Number()` constructor.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number
#[ wasm_bindgen(constructor) ]
pub fn new ( value : JsValue ) -> Number ;
2018-06-23 19:03:55 +02:00
/// The toLocaleString() method returns a string with a language sensitive
/// representation of this number.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString
#[ wasm_bindgen(method, js_name = toLocaleString) ]
2018-06-23 16:59:49 -07:00
pub fn to_locale_string ( this : & Number , locale : & str ) -> JsString ;
2018-06-23 19:03:55 +02:00
2018-06-23 18:18:58 +02:00
/// The toPrecision() method returns a string representing the Number
/// object to the specified precision.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toPrecision
#[ wasm_bindgen(catch, method, js_name = toPrecision) ]
2018-06-23 16:59:49 -07:00
pub fn to_precision ( this : & Number , precision : u8 ) -> Result < JsString , JsValue > ;
2018-06-23 18:18:58 +02:00
2018-06-24 10:08:23 +02:00
/// The toFixed() method returns a string representing the Number
/// object using fixed-point notation.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed
#[ wasm_bindgen(catch, method, js_name = toFixed) ]
2018-06-24 20:48:37 +02:00
pub fn to_fixed ( this : & Number , digits : u8 ) -> Result < JsString , JsValue > ;
2018-06-24 10:08:23 +02:00
/// The toExponential() method returns a string representing the Number
/// object in exponential notation.
///
2018-06-24 10:10:52 +02:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toExponential
2018-06-24 10:08:23 +02:00
#[ wasm_bindgen(catch, method, js_name = toExponential) ]
2018-06-24 20:48:37 +02:00
pub fn to_exponential ( this : & Number , fraction_digits : u8 ) -> Result < JsString , JsValue > ;
2018-06-24 10:08:23 +02:00
2018-06-23 17:38:13 +02:00
/// The toString() method returns a string representing the
/// specified Number object.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString
#[ wasm_bindgen(catch, method, js_name = toString) ]
2018-06-23 16:59:49 -07:00
pub fn to_string ( this : & Number , radix : u8 ) -> Result < JsString , JsValue > ;
2018-06-23 17:38:13 +02:00
2018-06-23 14:43:43 +02:00
/// The valueOf() method returns the wrapped primitive value of
/// a Number object.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/valueOf
#[ wasm_bindgen(method, js_name = valueOf) ]
2018-07-05 13:02:40 -07:00
pub fn value_of ( this : & Number ) -> f64 ;
2018-06-23 14:43:43 +02:00
}
2018-06-25 10:12:27 +02:00
// Date.
#[ wasm_bindgen ]
2018-06-27 22:42:34 -07:00
extern " C " {
2018-06-25 10:12:27 +02:00
pub type Date ;
2018-06-25 10:16:58 +02:00
2018-07-02 22:44:38 +02:00
/// The getDate() method returns the day of the month for the
/// specified date according to local time.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getDate
#[ wasm_bindgen(method, js_name = getDate) ]
2018-07-05 13:02:40 -07:00
pub fn get_date ( this : & Date ) -> u32 ;
2018-07-02 22:44:38 +02:00
2018-07-04 19:41:06 +09:00
/// The getDay() method returns the day of the week for the specified date according to local time,
/// where 0 represents Sunday. For the day of the month see getDate().
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getDay
#[ wasm_bindgen(method, js_name = getDay) ]
2018-07-05 13:02:40 -07:00
pub fn get_day ( this : & Date ) -> u32 ;
2018-07-04 19:41:06 +09:00
2018-07-04 19:52:12 +09:00
/// The getFullYear() method returns the year of the specified date according to local time.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getFullYear
#[ wasm_bindgen(method, js_name = getFullYear) ]
2018-07-05 13:02:40 -07:00
pub fn get_full_year ( this : & Date ) -> u32 ;
2018-07-04 19:52:12 +09:00
2018-06-27 22:42:34 -07:00
/// Creates a JavaScript Date instance that represents
/// a single moment in time. Date objects are based on a time value that is
2018-06-26 16:52:56 +02:00
/// the number of milliseconds since 1 January 1970 UTC.
2018-06-27 22:42:34 -07:00
///
2018-06-26 16:52:56 +02:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date
#[ wasm_bindgen(constructor) ]
pub fn new ( ) -> Date ;
2018-06-27 09:40:40 +02:00
/// The `Date.now()` method returns the number of milliseconds
/// elapsed since January 1, 1970 00:00:00 UTC.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now
#[ wasm_bindgen(static_method_of = Date) ]
2018-07-03 14:26:00 +02:00
pub fn now ( ) -> f64 ;
2018-06-27 09:40:40 +02:00
2018-06-25 10:17:31 +02:00
/// The toDateString() method returns the date portion of a Date object
/// in human readable form in American English.
2018-06-27 22:42:34 -07:00
///
2018-06-25 10:17:31 +02:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toDateString
#[ wasm_bindgen(method, js_name = toDateString) ]
pub fn to_date_string ( this : & Date ) -> JsString ;
2018-06-25 10:16:58 +02:00
/// The toISOString() method returns a string in simplified extended ISO format (ISO
/// 8601), which is always 24 or 27 characters long (YYYY-MM-DDTHH:mm:ss.sssZ or
2018-06-27 22:42:34 -07:00
/// ±YYYYYY-MM-DDTHH:mm:ss.sssZ, respectively). The timezone is always zero UTC offset,
2018-06-25 10:16:58 +02:00
/// as denoted by the suffix "Z"
2018-06-27 22:42:34 -07:00
///
2018-06-25 10:16:58 +02:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString
#[ wasm_bindgen(method, js_name = toISOString) ]
pub fn to_iso_string ( this : & Date ) -> JsString ;
2018-06-25 10:16:30 +02:00
/// The toJSON() method returns a string representation of the Date object.
2018-06-27 22:42:34 -07:00
///
2018-06-25 10:16:30 +02:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toJSON
#[ wasm_bindgen(method, js_name = toJSON) ]
pub fn to_json ( this : & Date ) -> JsString ;
2018-06-25 10:15:02 +02:00
2018-06-25 10:16:04 +02:00
/// The toLocaleDateString() method returns a string with a language sensitive
/// representation of the date portion of this date. The new locales and options
/// arguments let applications specify the language whose formatting conventions
/// should be used and allow to customize the behavior of the function.
/// In older implementations, which ignore the locales and options arguments,
/// the locale used and the form of the string
/// returned are entirely implementation dependent.
2018-06-27 22:42:34 -07:00
///
2018-06-25 10:16:04 +02:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString
#[ wasm_bindgen(method, js_name = toLocaleDateString) ]
pub fn to_locale_date_string ( this : & Date , locale : JsString , options : JsValue ) -> JsString ;
2018-06-27 22:42:34 -07:00
/// The toLocaleString() method returns a string with a language sensitive
/// representation of this date. The new locales and options arguments
/// let applications specify the language whose formatting conventions
/// should be used and customize the behavior of the function.
/// In older implementations, which ignore the locales
/// and options arguments, the locale used and the form of the string
2018-06-25 10:15:02 +02:00
/// returned are entirely implementation dependent.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString
#[ wasm_bindgen(method, js_name = toLocaleString) ]
pub fn to_locale_string ( this : & Date , locale : JsString , options : JsValue ) -> JsString ;
2018-06-25 10:14:27 +02:00
/// The toLocaleTimeString() method returns a string with a language sensitive
/// representation of the time portion of this date. The new locales and options
/// arguments let applications specify the language whose formatting conventions should be
/// used and customize the behavior of the function. In older implementations, which ignore
/// the locales and options arguments, the locale used and the form of the string
/// returned are entirely implementation dependent.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleTimeString
#[ wasm_bindgen(method, js_name = toLocaleTimeString) ]
pub fn to_locale_time_string ( this : & Date , locale : JsString ) -> JsString ;
2018-06-25 10:13:32 +02:00
2018-06-25 10:14:00 +02:00
/// The toString() method returns a string representing
/// the specified Date object.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toString
#[ wasm_bindgen(method, js_name = toString) ]
pub fn to_string ( this : & Date ) -> JsString ;
2018-06-25 10:13:32 +02:00
/// The toTimeString() method returns the time portion of a Date object in human
/// readable form in American English.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toTimeString
#[ wasm_bindgen(method, js_name = toTimeString) ]
pub fn to_time_string ( this : & Date ) -> JsString ;
2018-06-25 10:13:01 +02:00
/// The toUTCString() method converts a date to a string,
/// using the UTC time zone.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toUTCString
#[ wasm_bindgen(method, js_name = toUTCString) ]
pub fn to_utc_string ( this : & Date ) -> JsString ;
2018-06-25 10:12:27 +02:00
2018-06-27 09:41:16 +02:00
/// The `Date.UTC()` method accepts the same parameters as the
/// longest form of the constructor, and returns the number of
/// milliseconds in a `Date` object since January 1, 1970,
/// 00:00:00, universal time.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/UTC
#[ wasm_bindgen(static_method_of = Date, js_name = UTC) ]
2018-07-03 14:26:00 +02:00
pub fn utc ( year : f64 , month : f64 ) -> f64 ;
2018-06-27 09:41:16 +02:00
2018-06-25 10:12:27 +02:00
/// The valueOf() method returns the primitive value of
/// a Date object.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/valueOf
#[ wasm_bindgen(method, js_name = valueOf) ]
pub fn value_of ( this : & Date ) -> Date ;
}
2018-06-21 22:16:24 +02:00
// Object.
#[ wasm_bindgen ]
2018-06-27 22:42:34 -07:00
extern " C " {
2018-06-21 22:16:24 +02:00
pub type Object ;
/// The `hasOwnProperty()` method returns a boolean indicating whether the
/// object has the specified property as its own property (as opposed to
/// inheriting it).
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty
#[ wasm_bindgen(method, js_name = hasOwnProperty) ]
pub fn has_own_property ( this : & Object , property : & JsValue ) -> bool ;
2018-07-02 17:32:16 +02:00
/// The Object.isExtensible() method determines if an object is extensible
/// (whether it can have new properties added to it).
2018-07-05 13:02:40 -07:00
///
2018-07-02 17:32:16 +02:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isExtensible
#[ wasm_bindgen(static_method_of = Object, js_name = isExtensible) ]
pub fn is_extensible ( object : & Object ) -> bool ;
/// The Object.isFrozen() determines if an object is frozen.
2018-07-05 13:02:40 -07:00
///
2018-07-02 17:32:16 +02:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isFrozen
#[ wasm_bindgen(static_method_of = Object, js_name = isFrozen) ]
pub fn is_frozen ( object : & Object ) -> bool ;
/// The Object.isSealed() method determines if an object is sealed.
2018-07-05 13:02:40 -07:00
///
2018-07-02 17:32:16 +02:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isSealed
#[ wasm_bindgen(static_method_of = Object, js_name = isSealed) ]
pub fn is_sealed ( object : & Object ) -> bool ;
2018-06-21 22:16:24 +02:00
/// The isPrototypeOf() method checks if an object exists in another
/// object's prototype chain.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isPrototypeOf
#[ wasm_bindgen(method, js_name = isPrototypeOf) ]
pub fn is_prototype_of ( this : & Object , value : & JsValue ) -> bool ;
2018-06-22 14:45:33 -07:00
/// The Object.keys() method returns an array of a given object's property
/// names, in the same order as we get with a normal loop.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys
#[ wasm_bindgen(static_method_of = Object) ]
pub fn keys ( object : & Object ) -> Array ;
2018-06-22 14:11:07 -07:00
/// The Object constructor creates an object wrapper.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object
#[ wasm_bindgen(constructor) ]
pub fn new ( ) -> Object ;
2018-07-02 17:31:40 +02:00
/// The Object.preventExtensions() method prevents
/// new properties from ever being added to an object
/// (i.e. prevents future extensions to the object).
2018-07-05 13:02:40 -07:00
///
2018-07-02 17:31:40 +02:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/preventExtensions
#[ wasm_bindgen(static_method_of = Object, js_name = preventExtensions) ]
pub fn prevent_extensions ( object : & Object ) ;
2018-06-21 22:16:24 +02:00
/// The propertyIsEnumerable() method returns a Boolean indicating
/// whether the specified property is enumerable.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/propertyIsEnumerable
#[ wasm_bindgen(method, js_name = propertyIsEnumerable) ]
pub fn property_is_enumerable ( this : & Object , property : & JsValue ) -> bool ;
2018-06-23 12:11:46 +02:00
2018-06-26 14:02:42 +02:00
/// The Object.seal() method seals an object, preventing new properties
/// from being added to it and marking all existing properties as non-configurable.
/// Values of present properties can still be changed as long as they are writable.
2018-06-27 22:42:34 -07:00
///
2018-06-26 14:02:42 +02:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/seal
#[ wasm_bindgen(static_method_of = Object) ]
pub fn seal ( value : & JsValue ) -> JsValue ;
2018-07-01 11:52:22 +02:00
/// The Object.setPrototypeOf() method sets the prototype (i.e., the internal
/// [[Prototype]] property) of a specified object to another object or null.
2018-07-05 13:02:40 -07:00
///
2018-07-01 11:52:22 +02:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/setPrototypeOf
#[ wasm_bindgen(static_method_of = Object, js_name = setPrototypeOf) ]
pub fn set_prototype_of ( object : & Object , prototype : & Object ) -> Object ;
2018-06-22 14:11:07 -07:00
/// The toLocaleString() method returns a string representing the object.
2018-06-25 20:33:39 +02:00
/// This method is meant to be overridden by derived objects for
/// locale-specific purposes.
2018-06-22 14:11:07 -07:00
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toLocaleString
#[ wasm_bindgen(method, js_name = toLocaleString) ]
pub fn to_locale_string ( this : & Object ) -> JsString ;
/// The toString() method returns a string representing the object.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString
#[ wasm_bindgen(method, js_name = toString) ]
pub fn to_string ( this : & Object ) -> JsString ;
2018-06-23 12:11:46 +02:00
/// The valueOf() method returns the primitive value of the
/// specified object.
2018-06-23 16:59:49 -07:00
///
2018-06-23 12:11:46 +02:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/valueOf
#[ wasm_bindgen(method, js_name = valueOf) ]
pub fn value_of ( this : & Object ) -> Object ;
2018-07-01 23:50:10 +02:00
/// The Object.values() method returns an array of a given object's
/// own enumerable property values, in the same order as that provided
/// by a for...in loop (the difference being that a for-in loop
/// enumerates properties in the prototype chain as well).
2018-07-05 13:02:40 -07:00
///
2018-07-01 23:50:10 +02:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/values
#[ wasm_bindgen(static_method_of = Object) ]
pub fn values ( object : & Object ) -> Array ;
2018-06-21 22:16:24 +02:00
}
2018-06-22 17:51:44 -07:00
2018-07-04 09:27:32 +02:00
// Proxy
#[ wasm_bindgen ]
extern {
pub type Proxy ;
/// The Proxy object is used to define custom behavior for fundamental
/// operations (e.g. property lookup, assignment, enumeration, function
/// invocation, etc).
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy
#[ wasm_bindgen(constructor) ]
pub fn new ( target : & JsValue , handler : & Object ) -> Proxy ;
2018-07-04 10:05:42 +02:00
/// The Proxy.revocable() method is used to create a revocable Proxy object.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/revocable
#[ wasm_bindgen(static_method_of = Proxy) ]
pub fn revocable ( target : & JsValue , handler : & Object ) -> Object ;
2018-07-04 09:27:32 +02:00
}
2018-07-04 11:43:34 +02:00
// Reflect
#[ wasm_bindgen ]
extern " C " {
pub type Reflect ;
/// The static Reflect.apply() method calls a target function with arguments as specified.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/apply
2018-07-04 16:10:17 +02:00
#[ wasm_bindgen(static_method_of = Reflect) ]
pub fn apply ( target : & Function , this_argument : & JsValue , arguments_list : & Array ) -> JsValue ;
2018-07-04 12:07:02 +02:00
/// The static Reflect.construct() method acts like the new operator, but as a function.
/// It is equivalent to calling new target(...args). It gives also the added option to
/// specify a different prototype.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/construct
2018-07-04 16:10:17 +02:00
#[ wasm_bindgen(static_method_of = Reflect) ]
pub fn construct ( target : & Function , arguments_list : & Array ) -> JsValue ;
#[ wasm_bindgen(static_method_of = Reflect, js_name = construct) ]
pub fn construct_with_new_target ( target : & Function , arguments_list : & Array , new_target : & Function ) -> JsValue ;
2018-07-04 12:17:01 +02:00
/// The static Reflect.defineProperty() method is like Object.defineProperty()
/// but returns a Boolean.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/defineProperty
2018-07-05 08:33:22 +02:00
#[ wasm_bindgen(static_method_of = Reflect, js_name = defineProperty) ]
pub fn define_property ( target : & Object , property_key : & JsValue , attributes : & Object ) -> bool ;
2018-07-04 12:24:52 +02:00
/// The static Reflect.deleteProperty() method allows to delete properties.
/// It is like the delete operator as a function.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/deleteProperty
2018-07-04 16:10:17 +02:00
#[ wasm_bindgen(static_method_of = Reflect, js_name = deleteProperty) ]
pub fn delete_property ( target : & Object , key : & JsValue ) -> bool ;
2018-07-04 12:31:24 +02:00
/// The static Reflect.get() method works like getting a property from
/// an object (target[propertyKey]) as a function.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/get
2018-07-04 16:10:17 +02:00
#[ wasm_bindgen(static_method_of = Reflect) ]
pub fn get ( target : & Object , key : & JsValue ) -> JsValue ;
2018-07-04 12:35:40 +02:00
/// The static Reflect.getOwnPropertyDescriptor() method is similar to
/// Object.getOwnPropertyDescriptor(). It returns a property descriptor
/// of the given property if it exists on the object, undefined otherwise.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/getOwnPropertyDescriptor
2018-07-04 16:10:17 +02:00
#[ wasm_bindgen(static_method_of = Reflect, js_name = getOwnPropertyDescriptor) ]
pub fn get_own_property_descriptor ( target : & Object , property_key : & JsValue ) -> JsValue ;
2018-07-04 12:39:56 +02:00
/// The static Reflect.getPrototypeOf() method is almost the same
/// method as Object.getPrototypeOf(). It returns the prototype
/// (i.e. the value of the internal [[Prototype]] property) of
/// the specified object.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/getPrototypeOf
2018-07-04 16:10:17 +02:00
#[ wasm_bindgen(static_method_of = Reflect, js_name = getPrototypeOf) ]
pub fn get_prototype_of ( target : & Object ) -> Object ;
2018-07-04 12:44:49 +02:00
/// The static Reflect.has() method works like the in operator as a function.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/has
2018-07-04 15:32:34 +02:00
#[ wasm_bindgen(static_method_of = Reflect) ]
pub fn has ( target : & Object , property_key : & JsValue ) -> bool ;
2018-07-04 12:49:07 +02:00
/// The static Reflect.isExtensible() method determines if an object is extensible
/// (whether it can have new properties added to it). It is similar to
/// Object.isExtensible(), but with some differences.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/isExtensible
2018-07-04 16:10:17 +02:00
#[ wasm_bindgen(static_method_of = Reflect, js_name = isExtensible) ]
pub fn is_extensible ( target : & Object ) -> bool ;
2018-07-04 12:53:38 +02:00
/// The static Reflect.ownKeys() method returns an array of the
/// target object's own property keys.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/ownKeys
2018-07-04 16:10:17 +02:00
#[ wasm_bindgen(static_method_of = Reflect, js_name = ownKeys) ]
pub fn own_keys ( target : & Object ) -> Array ;
2018-07-04 12:56:37 +02:00
/// The static Reflect.preventExtensions() method prevents new
/// properties from ever being added to an object (i.e. prevents
/// future extensions to the object). It is similar to
/// Object.preventExtensions(), but with some differences.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/preventExtensions
2018-07-04 16:10:17 +02:00
#[ wasm_bindgen(static_method_of = Reflect, js_name = preventExtensions) ]
pub fn prevent_extensions ( target : & Object ) -> bool ;
2018-07-04 13:08:43 +02:00
/// The static Reflect.set() method works like setting a
/// property on an object.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/set
2018-07-04 16:10:17 +02:00
#[ wasm_bindgen(static_method_of = Reflect) ]
pub fn set ( target : & Object , property_key : & JsValue , value : & JsValue ) -> bool ;
#[ wasm_bindgen(static_method_of = Reflect, js_name = set) ]
pub fn set_with_receiver ( target : & Object , property_key : & JsValue , value : & JsValue , receiver : & Object ) -> bool ;
2018-07-04 13:13:35 +02:00
/// The static Reflect.setPrototypeOf() method is the same
/// method as Object.setPrototypeOf(). It sets the prototype
/// (i.e., the internal [[Prototype]] property) of a specified
/// object to another object or to null.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/setPrototypeOf
2018-07-04 16:10:17 +02:00
#[ wasm_bindgen(static_method_of = Reflect, js_name = setPrototypeOf) ]
pub fn set_prototype_of ( target : & Object , prototype : & JsValue ) -> bool ;
2018-07-04 11:43:34 +02:00
}
2018-06-28 22:57:49 +02:00
// Set
2018-06-26 13:12:32 +05:00
#[ wasm_bindgen ]
extern {
2018-06-28 22:57:49 +02:00
pub type Set ;
2018-07-05 13:02:40 -07:00
/// The add() method appends a new element with a specified value to the
2018-06-28 22:57:49 +02:00
/// end of a Set object.
2018-07-05 13:02:40 -07:00
///
2018-06-28 22:57:49 +02:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/add
#[ wasm_bindgen(method) ]
pub fn add ( this : & Set , value : & JsValue ) -> Set ;
/// The clear() method removes all elements from a Set object.
2018-07-05 13:02:40 -07:00
///
2018-06-28 22:57:49 +02:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/clear
#[ wasm_bindgen(method) ]
pub fn clear ( this : & Set ) ;
/// The delete() method removes the specified element from a Set object.
2018-07-05 13:02:40 -07:00
///
2018-06-28 22:57:49 +02:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/delete
#[ wasm_bindgen(method) ]
pub fn delete ( this : & Set , value : & JsValue ) -> bool ;
2018-07-05 13:02:40 -07:00
/// The has() method returns a boolean indicating whether an element
2018-06-28 22:57:49 +02:00
/// with the specified value exists in a Set object or not.
2018-07-05 13:02:40 -07:00
///
2018-06-28 22:57:49 +02:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/has
#[ wasm_bindgen(method) ]
pub fn has ( this : & Set , value : & JsValue ) -> bool ;
2018-07-05 13:02:40 -07:00
/// The Set object lets you store unique values of any type, whether primitive
2018-06-28 22:57:49 +02:00
/// values or object references.
2018-07-05 13:02:40 -07:00
///
2018-06-28 22:57:49 +02:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set
#[ wasm_bindgen(constructor) ]
pub fn new ( ) -> Set ;
/// The size accessor property returns the number of elements in a Set object.
2018-07-05 13:02:40 -07:00
///
2018-06-28 22:57:49 +02:00
/// https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Set/size
#[ wasm_bindgen(method, getter, structural) ]
2018-07-05 13:02:40 -07:00
pub fn size ( this : & Set ) -> u32 ;
2018-06-28 22:57:49 +02:00
}
// SetIterator
#[ wasm_bindgen ]
extern {
pub type SetIterator ;
2018-07-05 13:02:40 -07:00
/// The entries() method returns a new Iterator object that contains
/// an array of [value, value] for each element in the Set object,
/// in insertion order. For Set objects there is no key like in
2018-06-28 22:57:49 +02:00
/// Map objects. However, to keep the API similar to the Map object,
2018-07-05 13:02:40 -07:00
/// each entry has the same value for its key and value here, so that
2018-06-28 22:57:49 +02:00
/// an array [value, value] is returned.
2018-07-05 13:02:40 -07:00
///
2018-06-28 22:57:49 +02:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/entries
#[ wasm_bindgen(method) ]
pub fn entries ( set : & Set ) -> SetIterator ;
2018-07-05 13:02:40 -07:00
/// The keys() method is an alias for this method (for similarity with
/// Map objects); it behaves exactly the same and returns values
2018-06-28 22:57:49 +02:00
/// of Set elements.
2018-07-05 13:02:40 -07:00
///
2018-06-28 22:57:49 +02:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/values
#[ wasm_bindgen(method) ]
pub fn keys ( set : & Set ) -> SetIterator ;
2018-07-05 13:02:40 -07:00
/// The values() method returns a new Iterator object that contains the
2018-06-28 22:57:49 +02:00
/// values for each element in the Set object in insertion order.
2018-07-05 13:02:40 -07:00
///
2018-06-28 22:57:49 +02:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/values
#[ wasm_bindgen(method) ]
pub fn values ( set : & Set ) -> SetIterator ;
}
2018-06-26 13:12:32 +05:00
// WeakMap
#[ wasm_bindgen ]
2018-06-27 22:42:34 -07:00
extern " C " {
2018-06-26 13:12:32 +05:00
pub type WeakMap ;
2018-07-05 13:02:40 -07:00
/// The WeakMap object is a collection of key/value pairs in which the keys are weakly referenced.
2018-06-26 23:50:31 +05:00
/// The keys must be objects and the values can be arbitrary values.
2018-06-26 13:12:32 +05:00
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap
#[ wasm_bindgen(constructor) ]
pub fn new ( ) -> WeakMap ;
2018-06-27 22:42:34 -07:00
/// The set() method sets the value for the key in the WeakMap object. Returns
2018-06-26 13:12:32 +05:00
/// the WeakMap object.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/set
2018-06-27 22:42:34 -07:00
#[ wasm_bindgen(method, js_class = " WeakMap " ) ]
2018-06-26 23:50:31 +05:00
pub fn set ( this : & WeakMap , key : Object , value : JsValue ) -> WeakMap ;
2018-06-26 13:12:32 +05:00
2018-06-27 22:42:34 -07:00
/// The get() method returns a specified by key element
2018-06-26 13:12:32 +05:00
/// from a WeakMap object.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/get
#[ wasm_bindgen(method) ]
2018-06-26 23:50:31 +05:00
pub fn get ( this : & WeakMap , key : Object ) -> JsValue ;
2018-06-26 13:12:32 +05:00
2018-06-27 22:42:34 -07:00
/// The has() method returns a boolean indicating whether an element with
2018-06-26 13:12:32 +05:00
/// the specified key exists in the WeakMap object or not.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/has
#[ wasm_bindgen(method) ]
2018-06-26 23:50:31 +05:00
pub fn has ( this : & WeakMap , key : Object ) -> bool ;
2018-06-26 13:12:32 +05:00
/// The delete() method removes the specified element from a WeakMap object.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/delete
#[ wasm_bindgen(method) ]
2018-06-26 23:50:31 +05:00
pub fn delete ( this : & WeakMap , key : Object ) -> bool ;
2018-06-26 13:12:32 +05:00
}
2018-06-27 13:48:32 +05:00
// WeakSet
2018-06-27 13:15:47 +05:00
#[ wasm_bindgen ]
2018-06-27 22:42:34 -07:00
extern " C " {
2018-06-27 13:15:47 +05:00
pub type WeakSet ;
/// The WeakSet object lets you store weakly held objects in a collection.
2018-06-27 22:42:34 -07:00
///
2018-06-27 13:15:47 +05:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet
#[ wasm_bindgen(constructor) ]
pub fn new ( ) -> WeakSet ;
2018-06-27 13:26:53 +05:00
/// The has() method returns a boolean indicating whether an object exists in a WeakSet or not.
2018-06-27 22:42:34 -07:00
///
2018-06-27 13:26:53 +05:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet/has
#[ wasm_bindgen(method) ]
pub fn has ( this : & WeakSet , value : Object ) -> bool ;
2018-06-27 13:38:33 +05:00
/// The add() method appends a new object to the end of a WeakSet object.
2018-06-27 22:42:34 -07:00
///
2018-06-27 13:38:33 +05:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet/add
#[ wasm_bindgen(method) ]
pub fn add ( this : & WeakSet , value : Object ) -> WeakSet ;
2018-06-27 13:44:01 +05:00
/// The delete() method removes the specified element from a WeakSet object.
2018-06-27 22:42:34 -07:00
///
2018-06-27 13:44:01 +05:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet/delete
#[ wasm_bindgen(method) ]
pub fn delete ( this : & WeakSet , value : Object ) -> bool ;
2018-06-27 13:15:47 +05:00
}
2018-07-04 15:27:01 +02:00
// WebAssembly
#[ wasm_bindgen ]
extern " C " {
pub type WebAssembly ;
/// The `WebAssembly.validate()` function validates a given typed
/// array of WebAssembly binary code, returning whether the bytes
/// form a valid wasm module (`true`) or not (`false`).
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/validate
2018-07-04 15:51:55 +02:00
#[ wasm_bindgen(static_method_of = WebAssembly, catch) ]
pub fn validate ( bufferSource : JsValue ) -> Result < bool , JsValue > ;
2018-07-04 15:27:01 +02:00
}
2018-06-23 16:59:49 -07:00
// JsString
2018-06-22 17:51:44 -07:00
#[ wasm_bindgen ]
2018-06-27 22:42:34 -07:00
extern " C " {
2018-06-23 16:59:49 -07:00
#[ wasm_bindgen(js_name = JsString) ]
2018-06-22 17:51:44 -07:00
pub type JsString ;
2018-06-26 22:10:25 +02:00
/// The length property of a String object indicates the length of a string,
/// in UTF-16 code units.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length
#[ wasm_bindgen(method, getter, structural) ]
pub fn length ( this : & JsString ) -> u32 ;
2018-06-25 21:30:04 +02:00
/// The String object's charAt() method returns a new string consisting of the single
/// UTF-16 code unit located at the specified offset into the string.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charAt
#[ wasm_bindgen(method, js_class = " String " , js_name = charAt) ]
pub fn char_at ( this : & JsString , index : u32 ) -> JsString ;
2018-06-26 21:25:44 +09:00
/// The charCodeAt() method returns an integer between 0 and 65535 representing the UTF-16 code unit at
/// the given index (the UTF-16 code unit matches the Unicode code point for code points representable in
/// a single UTF-16 code unit, but might also be the first code unit of a surrogate pair for
/// code points not representable in a single UTF-16 code unit, e.g. Unicode code points > 0x10000).
/// If you want the entire code point value, use codePointAt().
///
2018-07-05 13:02:40 -07:00
/// Returns `NaN` if index is out of range.
///
2018-06-26 21:25:44 +09:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charCodeAt
#[ wasm_bindgen(method, js_class = " String " , js_name = charCodeAt) ]
2018-07-05 13:02:40 -07:00
pub fn char_code_at ( this : & JsString , index : u32 ) -> f64 ;
2018-06-27 00:48:09 +09:00
2018-06-26 22:05:16 +09:00
/// The codePointAt() method returns a non-negative integer that is the Unicode code point value.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt
#[ wasm_bindgen(method, js_class = " String " , js_name = codePointAt) ]
pub fn code_point_at ( this : & JsString , pos : u32 ) -> JsValue ;
2018-06-27 00:48:09 +09:00
/// The concat() method concatenates the string arguments to the calling string and returns a new string.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/concat
#[ wasm_bindgen(method, js_class = " String " ) ]
pub fn concat ( this : & JsString , string_2 : & JsString ) -> JsString ;
2018-06-26 20:29:07 +09:00
/// The includes() method determines whether one string may be found within another string, returning true or false as appropriate.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes
#[ wasm_bindgen(method, js_class = " String " ) ]
pub fn includes ( this : & JsString , search_string : & JsString , position : i32 ) -> bool ;
2018-06-25 21:30:04 +02:00
/// The indexOf() method returns the index within the calling String object of
/// the first occurrence of the specified value, starting the search at fromIndex.
/// Returns -1 if the value is not found.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf
#[ wasm_bindgen(method, js_class = " String " , js_name = indexOf) ]
pub fn index_of ( this : & JsString , search_value : & JsString , from_index : i32 ) -> i32 ;
2018-06-27 22:42:34 -07:00
2018-06-22 17:51:44 -07:00
/// The slice() method extracts a section of a string and returns it as a
/// new string, without modifying the original string.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice
#[ wasm_bindgen(method, js_class = " String " ) ]
pub fn slice ( this : & JsString , start : u32 , end : u32 ) -> JsString ;
2018-06-25 20:24:44 +02:00
2018-06-25 21:30:04 +02:00
/// The startsWith() method determines whether a string begins with the characters
/// of a specified string, returning true or false as appropriate.
2018-06-25 20:24:44 +02:00
///
2018-06-25 21:30:04 +02:00
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith
#[ wasm_bindgen(method, js_class = " String " , js_name = startsWith) ]
pub fn starts_with ( this : & JsString , search_string : & JsString , position : u32 ) -> bool ;
/// The substring() method returns the part of the string between the start and end indexes,
/// or to the end of the string.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring
#[ wasm_bindgen(method, js_class = " String " ) ]
pub fn substring ( this : & JsString , index_start : u32 , index_end : u32 ) -> JsString ;
2018-06-25 22:20:38 +02:00
2018-06-24 23:03:39 +02:00
/// The substr() method returns the part of a string between
/// the start index and a number of characters after it.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr
#[ wasm_bindgen(method, js_class = " String " ) ]
pub fn substr ( this : & JsString , start : i32 , length : i32 ) -> JsString ;
2018-06-26 22:10:25 +02:00
2018-07-01 23:11:13 +02:00
/// The toLowerCase() method returns the calling string value
/// converted to lower case.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLowerCase
#[ wasm_bindgen(method, js_class = " String " , js_name = toLowerCase) ]
pub fn to_lower_case ( this : & JsString ) -> JsString ;
2018-06-26 22:21:51 +02:00
/// The toString() method returns a string representing the specified object.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toString
#[ wasm_bindgen(method, js_class = " String " , js_name = toString) ]
pub fn to_string ( this : & JsString ) -> JsString ;
2018-07-01 23:12:42 +02:00
/// The toUpperCase() method returns the calling string value
/// converted to uppercase (the value will be converted to a
/// string if it isn't one).
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase
#[ wasm_bindgen(method, js_class = " String " , js_name = toUpperCase) ]
pub fn to_upper_case ( this : & JsString ) -> JsString ;
2018-06-26 22:10:25 +02:00
/// The trim() method removes whitespace from both ends of a string.
/// Whitespace in this context is all the whitespace characters
/// (space, tab, no-break space, etc.) and all the line terminator characters (LF, CR, etc.).
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trim
#[ wasm_bindgen(method, js_class = " String " ) ]
pub fn trim ( this : & JsString ) -> JsString ;
/// The trimEnd() method removes whitespace from the end of a string.
/// trimRight() is an alias of this method.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimEnd
#[ wasm_bindgen(method, js_class = " String " , js_name = trimEnd) ]
pub fn trim_end ( this : & JsString ) -> JsString ;
/// The trimEnd() method removes whitespace from the end of a string.
/// trimRight() is an alias of this method.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimEnd
#[ wasm_bindgen(method, js_class = " String " , js_name = trimRight) ]
pub fn trim_right ( this : & JsString ) -> JsString ;
/// The trimStart() method removes whitespace from the beginning of a string.
/// trimLeft() is an alias of this method.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimStart
#[ wasm_bindgen(method, js_class = " String " , js_name = trimStart) ]
pub fn trim_start ( this : & JsString ) -> JsString ;
/// The trimStart() method removes whitespace from the beginning of a string.
/// trimLeft() is an alias of this method.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimStart
#[ wasm_bindgen(method, js_class = " String " , js_name = trimLeft) ]
pub fn trim_left ( this : & JsString ) -> JsString ;
2018-06-26 22:21:51 +02:00
/// The valueOf() method returns the primitive value of a String object.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/valueOf
#[ wasm_bindgen(method, js_class = " String " , js_name = valueOf) ]
pub fn value_of ( this : & JsString ) -> JsString ;
2018-06-23 14:43:43 +02:00
}
2018-06-23 16:59:49 -07:00
impl < ' a > From < & ' a str > for JsString {
fn from ( s : & ' a str ) -> Self {
JsString {
obj : JsValue ::from_str ( s ) ,
}
}
}
if_std! {
impl From < String > for JsString {
fn from ( s : String ) -> Self {
From ::from ( & * s )
}
}
impl < ' a > From < & ' a JsString > for String {
fn from ( s : & ' a JsString ) -> Self {
s . obj . as_string ( ) . unwrap ( )
}
}
impl From < JsString > for String {
fn from ( s : JsString ) -> Self {
From ::from ( & s )
}
}
}
2018-07-03 20:53:17 +09:00
// Symbol
#[ wasm_bindgen ]
extern " C " {
pub type Symbol ;
/// The Symbol.hasInstance well-known symbol is used to determine
/// if a constructor object recognizes an object as its instance.
/// The instanceof operator's behavior can be customized by this symbol.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/hasInstance
#[ wasm_bindgen(static_method_of = Symbol, getter, structural, js_name = hasInstance) ]
pub fn has_instance ( ) -> Symbol ;
2018-07-06 17:07:43 +09:00
/// The Symbol.isConcatSpreadable well-known symbol is used to configure if an object should be flattened to
/// its array elements when using the Array.prototype.concat() method.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/isConcatSpreadable
#[ wasm_bindgen(static_method_of = Symbol, getter, structural, js_name = isConcatSpreadable) ]
pub fn is_concat_spreadable ( ) -> Symbol ;
/// The Symbol.iterator well-known symbol specifies the default iterator for an object.
/// Used by for...of.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/iterator
#[ wasm_bindgen(static_method_of = Symbol, getter, structural) ]
pub fn iterator ( ) -> Symbol ;
/// The Symbol.match well-known symbol specifies the matching of a regular expression against a string.
/// This function is called by the String.prototype.match() method.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/match
#[ wasm_bindgen(static_method_of = Symbol, getter, structural, js_name = match) ]
pub fn match_ ( ) -> Symbol ;
/// The Symbol.replace well-known symbol specifies the method that replaces matched substrings of a string.
/// This function is called by the String.prototype.replace() method.
///
/// For more information, see RegExp.prototype[@@replace]() and String.prototype.replace().
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/replace
#[ wasm_bindgen(static_method_of = Symbol, getter, structural) ]
pub fn replace ( ) -> Symbol ;
/// The Symbol.search well-known symbol specifies the method that returns the index within a string that matches the regular expression.
/// This function is called by the String.prototype.search() method.
///
/// For more information, see RegExp.prototype[@@search]() and String.prototype.search().
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/search
#[ wasm_bindgen(static_method_of = Symbol, getter, structural) ]
pub fn search ( ) -> Symbol ;
/// The well-known symbol Symbol.species specifies a function-valued property that the constructor function uses to create derived objects.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/species
#[ wasm_bindgen(static_method_of = Symbol, getter, structural) ]
pub fn species ( ) -> Symbol ;
/// The Symbol.split well-known symbol specifies the method that splits a string at the indices that match a regular expression.
/// This function is called by the String.prototype.split() method.
///
/// For more information, see RegExp.prototype[@@split]() and String.prototype.split().
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/split
#[ wasm_bindgen(static_method_of = Symbol, getter, structural) ]
pub fn split ( ) -> Symbol ;
/// The Symbol.toPrimitive is a symbol that specifies a function valued property that is called to convert an object to a corresponding primitive value.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toPrimitive
#[ wasm_bindgen(static_method_of = Symbol, getter, structural, js_name = toPrimitive) ]
pub fn to_primitive ( ) -> Symbol ;
/// The Symbol.toStringTag well-known symbol is a string valued property that is used in the creation of the default string description of an object.
/// It is accessed internally by the Object.prototype.toString() method.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toString
#[ wasm_bindgen(static_method_of = Symbol, getter, structural, js_name = toStringTag) ]
pub fn to_string_tag ( ) -> Symbol ;
2018-07-03 20:53:17 +09:00
}