Crate js_sys

source ·
Expand description

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.

Modules

Structs

An iterator over the JS Symbol.iterator iteration protocol.
An iterator over the JS Symbol.iterator iteration protocol.
Any object that conforms to the JS iterator protocol. For example, something returned by myArray[Symbol.iterator]().
The result of calling next() on a JS iterator.
The JSON object contains methods for parsing JavaScript Object Notation (JSON) and converting values to JSON. It can’t be called or constructed, and aside from its two method properties, it has no interesting functionality of its own.
The Promise object represents the eventual completion (or failure) of an asynchronous operation, and its resulting value.
The RangeError object indicates an error when a value is not in the set or range of allowed values.
The ReferenceError object represents an error when a non-existent variable is referenced.
A SyntaxError is thrown when the JavaScript engine encounters tokens or token order that does not conform to the syntax of the language when parsing code.
The TypeError object represents an error when a value is not of the expected type.
The URIError object represents an error when a global URI handling function was used in a wrong way.

Functions

The decodeURI() function decodes a Uniform Resource Identifier (URI) previously created by encodeURI or by a similar routine.
The decodeURIComponent() function decodes a Uniform Resource Identifier (URI) component previously created by encodeURIComponent or by a similar routine.
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).
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).
The escape() function computes a new string in which certain characters have been replaced by a hexadecimal escape sequence.
The eval() function evaluates JavaScript code represented as a string.
Returns a handle to the global scope object.
The global isFinite() function determines whether the passed value is a finite number. If needed, the parameter is first converted to a number.
The parseFloat() function parses an argument and returns a floating point number, or NaN on error.
The parseInt() function parses a string argument and returns an integer of the specified radix (the base in mathematical numeral systems), or NaN on error.
Create an iterator over val using the JS iteration protocol and Symbol.iterator.
The unescape() function computes a new string in which hexadecimal escape sequences are replaced with the character that it represents. The escape sequences might be introduced by a function like escape. Usually, decodeURI or decodeURIComponent are preferred over unescape.