elixir_script v0.18.0 ElixirScript.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
Imports a JavaScript module
Imports a JavaScript module
Determines if value is an instance of type
Creates new JavaScript objects
Throws the term given
Returns the type of the given value
Updates an existing JavaScript object
Functions
Macros
Imports a JavaScript module.
Works like import/2, but tries to infer the path to the module.
Only works for default imports. Uses Macro.underscore
to infer path.
ex: JS.import React #translates to “import React from ‘react’”
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 module is not a list, then it is treated as a default import, otherwise it is not.
ex: JS.import A, “a” #translates to “import A from ‘a’”
JS.import [A, B, C], “a” #translates to “import {A, B, C} from ‘a’”