elixir_script v0.23.0 JS
This module defines macros and functions which implement JavaScript functionality that may not translate easily to Elixir. For instance, creating a new object, or updating an existing one.
Summary
Macros
Defines a generator. This is compiled into a generator function in JavaScript. defgen and defgenp are currently the only ways to use process in Elixirscript right now
Defines a private generator. This is compiled into a generator function in JavaScript
Imports a JavaScript module
Determines if value is an instance of type
Creates new JavaScript objects
Provides a convenient way to create a string-based map
Throws the term given
Returns the type of the given value
Updates an existing JavaScript object
Yields the current generator function
Yields the current generator function with the given term
Yields control to the given generator
Functions
Returns a reference to the global JavaScript object.
In browsers this would be window or self. In node this would be the global object.
Macros
Defines a generator. This is compiled into a generator function in JavaScript. defgen and defgenp are currently the only ways to use process in Elixirscript right now.
Defines a private generator. This is compiled into a generator function in JavaScript.
Imports a JavaScript module.
Elixir modules can use the normal import
, alias
and require
,
but JavaScript modules work differently and have to be imported
using this.
If default
is set to true then it is treated as a default import.
Otherwise it is treated as a namespace import.
ex: JS.import A, “a” #translates to “import A from ‘a’”
JS.import A, “a”, default: false #translates to “import * as A from ‘a’”
Provides a convenient way to create a string-based map.
Elixirscript, by default turns the following, %{a: "b"}
into {[Symbol.for("a")]: "b"}
in JavaScript. In order to get string keys,
one would have to do %{"a" => "b"}
which turns into {a: "b"}
in JavaScript. With Kernel.object
, you can create string keyed maps
conveniently, object(a: "b")
which turns into {a: "b"}