Skip to content

Commit

Permalink
Added support for ArrayMap() to be initialized with an array
Browse files Browse the repository at this point in the history
  • Loading branch information
nazar-pc committed Mar 15, 2018
1 parent 781a09f commit 16cf791
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"detox",
"utils"
],
"version" : "1.5.0",
"version" : "1.6.0",
"homepage" : "https://github.com/Detox/utils",
"author" : "Nazar Mokrynskyi <nazar@mokrynskyi.com>",
"repository" : {
Expand Down
14 changes: 10 additions & 4 deletions src/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions src/index.ls
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ function get_unique_key (key)
*
* Implementation keeps weak references to make the whole thing fast and efficient
*/
function ArrayMap
new Map
function ArrayMap (array)
map = new Map
..get = (key) ->
key = get_unique_key(key)
Map::get.call(@, key)
Expand All @@ -224,6 +224,10 @@ function ArrayMap
..clear = !->
@forEach (, key) !~>
@delete(key)
if array
for [key, value] in array
map.set(key, value)
map
# LiveScript doesn't support classes, so we do it in ugly way
/**
* This is a Set with very interesting property: different arrays with the same contents will be treated as the same array
Expand Down
14 changes: 7 additions & 7 deletions src/index.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 16cf791

Please sign in to comment.