-
Notifications
You must be signed in to change notification settings - Fork 68
Expand file tree
/
Copy pathjs.ex
More file actions
57 lines (47 loc) · 1.12 KB
/
js.ex
File metadata and controls
57 lines (47 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
defmodule ElixirScript.JS do
@moduledoc """
This module defines macros and functions which implement
JavaScript functionality that may not translate easily to
Elixir. For instance, creating a new object
"""
@doc """
Creates new JavaScript objects.
ex:
ElixirScript.JS.new User, ["first_name", "last_name"]
"""
defmacro new(module, params)
@doc """
Returns the type of the given value
"""
defmacro typeof(value)
@doc """
Determines if value is an instance of type.
"""
defmacro instanceof(value, type)
@doc """
Throws the term given
"""
defmacro throw(term)
@doc """
Creates a breakpoint for JavaScript debuggers to stop at
"""
defmacro debugger()
@doc """
The current JavaScript context
"""
defmacro this()
@doc """
Mutates an existing JavaScript object.
ex:
ElixirScript.JS.mutate elem, "width", 100
"""
defmacro mutate(object, key, value)
@doc """
Takes the given map and returns an object
Throws an error if any key is not a
number, binary, or atom
ex:
ElixirScript.JS.map_to_object(%{my: "map"})
"""
defmacro map_to_object(object)
end