Skip to content

Commit

Permalink
Added support for ArraySet() to be initialized with an array
Browse files Browse the repository at this point in the history
  • Loading branch information
nazar-pc committed Feb 23, 2018
1 parent 9196d41 commit db82ca8
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 13 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.3.0",
"version" : "1.4.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 @@ -225,13 +225,13 @@ function ArrayMap
@forEach (, key) !~>
@delete(key)
# LiveScript doesn't support classes, so we do it in ugly way
function ArraySet
function ArraySet (array)
/**
* This is a Set with very interesting property: different arrays with the same contents will be treated as the same array
*
* Implementation keeps weak references to make the whole thing fast and efficient
*/
new Set
set = new Set
..has = (key) ->
key = get_unique_key(key)
Set::has.call(@, key)
Expand All @@ -248,6 +248,10 @@ function ArraySet
..clear = !->
@forEach (, key) !~>
@delete(key)
if array
for item in array
set.add(item)
set

function Wrapper
{
Expand Down
12 changes: 6 additions & 6 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 db82ca8

Please sign in to comment.