Skip to content

Commit a21197b

Browse files
committed
merge in async_scheduler
2 parents cec1423 + fe7d266 commit a21197b

File tree

34 files changed

+893
-207
lines changed

34 files changed

+893
-207
lines changed

.credo.exs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
{Credo.Check.Design.DuplicatedCode, excluded_macros: []},
5858
{Credo.Check.Design.TagTODO, exit_status: 2},
5959
{Credo.Check.Design.TagFIXME},
60+
{Credo.Check.Design.AliasUsage, false},
6061

6162
{Credo.Check.Readability.FunctionNames},
6263
{Credo.Check.Readability.LargeNumbers},

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ module.exports = {
66
'no-restricted-syntax': 'off',
77
'no-underscore-dangle': 'off',
88
'import/extensions': 'off',
9+
'import/no-extraneous-dependencies': ['error', { devDependencies: true }],
910
},
1011
extends: 'airbnb-base',
1112
plugins: ['import'],

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
88
### Added
99
- Reimplement `String.split_at/2` to make sure Unicode library isn't compiled
1010
- Added `ElixirScript.JS.map_to_object/2` with options [keys: :string, symbols: false]
11+
- Added `ElixirScript.JS.object_to_map/1|2` with options [keys: :atom, recurse_array: true]
1112

1213
### Fixed
1314
- Make sure not to add underscores to erlang functions

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.PHONY: compile test clean js_compile elixir_compile elixir_test js_test deps elixir_deps js_deps
22

3-
default: compile
3+
default: deps compile
44

55
compile: js_compile elixir_compile
66

lib/elixir_script.ex

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ defmodule ElixirScript do
4646
4747
* `root`: Optional root for imports of FFI JavaScript modules. Defaults to `.`. If using output directly in a browser, you may want to make it something like `/js` or some uri.
4848
49-
5049
Now run `mix compile` and you should see a JavaScript file named `elixirscript.build.js` in the `priv/elixir_script/build/` directory. ElixirScript outputs JavaScript in the ES Module format. If your browser supports it, you can include the output in a script tag with the type "module"
5150
5251
```html

lib/elixir_script/beam.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ defmodule ElixirScript.Beam do
5353
else
5454
:error ->
5555
{:error, "Unknown module"}
56-
{:error,:beam_lib,{:unknown_chunk,"non_existing.beam",:debug_info}} ->
56+
{:error, :beam_lib, {:unknown_chunk, "non_existing.beam", :debug_info}} ->
5757
{:error, "Unsupported version of Erlang"}
58-
{:error,:beam_lib,{:missing_chunk, _ , _}} ->
58+
{:error, :beam_lib, {:missing_chunk, _ , _}} ->
5959
{:error, "Debug info not available"}
60-
{:error,:beam_lib,{:file_error,"non_existing.beam",:enoent}} ->
60+
{:error, :beam_lib, {:file_error, "non_existing.beam", :enoent}} ->
6161
{:error, "Debug info not available"}
6262
end
6363
end

lib/elixir_script/cli.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ defmodule ElixirScript.CLI do
3434

3535
end
3636

37-
defp help_message() do
37+
defp help_message do
3838
"""
3939
usage: elixirscript <module> [options]
4040
<module> the entry module of your application
@@ -64,7 +64,7 @@ defmodule ElixirScript.CLI do
6464
end
6565
end
6666

67-
def do_process(input, options) do
67+
defp do_process(input, options) do
6868
compile_opts = [
6969
output: Keyword.get(options, :output, :stdout),
7070
root: Keyword.get(options, :root, ".")

lib/elixir_script/lib/functions.ex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ defmodule ElixirScript.Core.Functions do
33
use ElixirScript.FFI, global: true
44

55
defexternal split_at(value, position)
6+
7+
defexternal graphemes(str)
68
end

lib/elixir_script/lib/js.ex

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,11 @@ defmodule ElixirScript.JS do
5555
Throws an error if any key is not a
5656
number, binary, or atom
5757
58-
5958
```elixir
6059
ElixirScript.JS.map_to_object(%{my: "map"})
6160
```
6261
"""
63-
defexternal map_to_object(object)
62+
defexternal map_to_object(map)
6463

6564
@doc """
6665
Takes the given map and returns an object
@@ -71,5 +70,25 @@ defmodule ElixirScript.JS do
7170
ElixirScript.JS.map_to_object(%{my: "map"}, keys: :string)
7271
```
7372
"""
74-
defexternal map_to_object(object, options)
73+
defexternal map_to_object(map, options)
74+
75+
@doc """
76+
Takes the given object and returns a map
77+
Options include [{:keys, :atom}, {:recurse_array, true}]
78+
79+
```elixir
80+
ElixirScript.JS.object_to_object({my: "object"})
81+
```
82+
"""
83+
defexternal object_to_map(object)
84+
85+
@doc """
86+
Takes the given object and returns a map
87+
Options include [{:keys, :atom}, {:recurse_array, true}]
88+
89+
```elixir
90+
ElixirScript.JS.object_to_object({my: "map"}, keys: :atom)
91+
```
92+
"""
93+
defexternal object_to_map(object, options)
7594
end

lib/elixir_script/lib/string.ex

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ defmodule ElixirScript.String do
6868
end)
6969
end
7070

71-
7271
def next_grapheme(nil), do: nil
7372
def next_grapheme(""), do: nil
7473

@@ -87,11 +86,11 @@ defmodule ElixirScript.String do
8786
end
8887

8988
def graphemes(str) do
90-
str.split('')
89+
ElixirScript.Core.Functions.graphemes(str)
9190
end
9291

9392
def length(str) do
94-
str.length()
93+
graphemes(str).length()
9594
end
9695

9796
def match?(str, regex) do

0 commit comments

Comments
 (0)