Skip to content
This repository has been archived by the owner on Dec 13, 2024. It is now read-only.

Commit

Permalink
Have simplified .union
Browse files Browse the repository at this point in the history
  • Loading branch information
akopachov committed Dec 4, 2016
1 parent 2e4fa14 commit e4a6b13
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 29 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mini-linq-js",
"version": "1.3.0",
"version": "1.3.1",
"description": "LINQ for JavaScript library, which allows to work with arrays in a more easy way and focus on business logic.",
"main": "dist/mini-linq.full.min.js",
"authors": [
Expand Down
2 changes: 1 addition & 1 deletion dist/mini-linq.full.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/mini-linq.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/mini-linq.with-knockout.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/mini-linq.with-lazy.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mini-linq-js",
"version": "1.3.0",
"version": "1.3.1",
"description": "LINQ for JavaScript library, which allows to work with arrays in a more easy way and focus on business logic.",
"homepage": "https://github.com/akopachov/mini-linq-js",
"keywords": ["linq", "array"],
Expand Down
24 changes: 1 addition & 23 deletions src/mini-linq.js
Original file line number Diff line number Diff line change
Expand Up @@ -572,29 +572,7 @@ SOFTWARE.
},

union: function(anotherCollection, comparator) {
if (typeof (comparator) === "string") {
comparator = LINQ.utils.parseExpression(comparator);
} else if (typeof (comparator) !== "function") {
comparator = function (a, b) { return a === b; }
}

var result = [];
var allValues = [].concat(this, anotherCollection);
for (var i = 0, l = allValues.length; i < l; i++) {
var addToResult = true;
for (var j = 0, rl = result.length; j < rl; j++) {
if (comparator(allValues[i], result[j])) {
addToResult = false;
break;
}
}

if (addToResult) {
result.push(allValues[i]);
}
}

return result;
return [].concat(this, anotherCollection).distinct(function(e) {return e}, comparator);
},

except: function(anotherCollection, comparator) {
Expand Down

0 comments on commit e4a6b13

Please sign in to comment.