Last active
August 29, 2015 14:20
-
-
Save gr0uch/e7f7146735d7aec2f795 to your computer and use it in GitHub Desktop.
Revisions
-
0x8890 revised this gist
Aug 14, 2015 . 1 changed file with 2 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,11 +5,8 @@ * @return {Set} */ function union () { return new Set(arguments[0].concat( ...Array.prototype.slice.call(arguments, 1))) } console.log(union([1, 2, 3], [2, 3, 4])) // => [1, 2, 3, 4] -
0x8890 revised this gist
Aug 14, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ /** * Get the union of arrays with unique values by means of the Set type. * * @param {Array[]} * @return {Set} */ function union () { -
gr0uch revised this gist
May 2, 2015 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,14 +2,14 @@ * Get the union of arrays with unique values by means of the Set type. * * @param {Array} * @return {Set} */ function union () { return new Set(Array.prototype.reduce.call(arguments, (memo, array) => { memo.push(...array) return memo }, [])) } console.log(union([1, 2, 3], [2, 3, 4])) // => [1, 2, 3, 4] -
gr0uch revised this gist
May 2, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ * @param {Array} * @return {Array} */ function union () { return [...new Set(Array.prototype.reduce.call(arguments, (memo, array) => { memo.push(...array) -
gr0uch revised this gist
May 2, 2015 . 1 changed file with 5 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,10 +5,11 @@ * @return {Array} */ export default function union () { return [...new Set(Array.prototype.reduce.call(arguments, (memo, array) => { memo.push(...array) return memo }, []))] } console.log(union([1, 2, 3], [2, 3, 4])) // => [1, 2, 3, 4] -
gr0uch revised this gist
May 2, 2015 . 1 changed file with 4 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,12 +5,10 @@ * @return {Array} */ export default function union () { return [...new Set(Array.prototype.reduce.call(arguments, (memo, array) => { memo.push(...array) return memo }, []))] } console.log(union([1, 2, 3], [2, 3, 4])) // => [1, 2, 3, 4] -
gr0uch revised this gist
May 2, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ /** * Get the union of arrays with unique values by means of the Set type. * * @param {Array} * @return {Array} -
gr0uch created this gist
May 2, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ /** * Get the union of arrays with unique values by abusing the Set type. * * @param {Array} * @return {Array} */ export default function union () { return [...new Set([ ...Array.prototype.reduce.call(arguments, (memo, array) => { memo.push(...array) return memo }, []) ])] } console.log(union([1, 2, 3], [2, 3, 4])) // => [1, 2, 3, 4]