Skip to content

Commit

Permalink
dependencies updated
Browse files Browse the repository at this point in the history
  • Loading branch information
goranhrovat committed Jun 30, 2019
1 parent 851aca0 commit 6d7353d
Show file tree
Hide file tree
Showing 8 changed files with 1,751 additions and 3,584 deletions.
6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -52,7 +52,7 @@ import {Enumerable, List, Dictionary, HashSet, EqualityComparers,
```
#### Get the specific version
```html
<script src="https://unpkg.com/linqify@1.2.0"></script>
<script src="https://unpkg.com/linqify@1.2.1"></script>
```
#### Get the latest minor and patch version of specific major version
```html
Expand Down Expand Up @@ -88,8 +88,8 @@ import {Enumerable, List, Dictionary, HashSet, EqualityComparers,
```javascript
function ageComparer (a, b) {
if (a.Age > b.Age) return 1;
else if (a.Age < b.Age) return -1;
else return 0;
if (a.Age < b.Age) return -1;
return 0;
}
let people = [{Name:"Jack", Age:18}, {Name:"Joe", Age:22}, {Name:"Jack", Age:20}];

Expand Down
5,211 changes: 1,686 additions & 3,525 deletions package-lock.json

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "linqify",
"version": "1.2.0",
"version": "1.2.1",
"description": "Javascript LINQ library based on C# LINQ",
"main": "dist/linqify.js",
"module": "dist/linqify.esm.js",
Expand Down Expand Up @@ -38,20 +38,20 @@
},
"homepage": "https://linqify.github.io",
"devDependencies": {
"@babel/core": "^7.3.3",
"@babel/plugin-transform-runtime": "^7.2.0",
"@babel/preset-env": "^7.3.1",
"@babel/runtime": "^7.3.1",
"coveralls": "^3.0.2",
"eslint": "^5.14.1",
"eslint-config-prettier": "^4.0.0",
"jest": "^24.1.0",
"prettier": "^1.16.4",
"rollup": "^1.2.2",
"rollup-plugin-babel": "^4.3.2",
"rollup-plugin-commonjs": "^9.2.0",
"rollup-plugin-node-resolve": "^4.0.0",
"rollup-plugin-terser": "^4.0.4",
"@babel/core": "^7.4.5",
"@babel/plugin-transform-runtime": "^7.4.4",
"@babel/preset-env": "^7.4.5",
"@babel/runtime": "^7.4.5",
"coveralls": "^3.0.4",
"eslint": "^6.0.1",
"eslint-config-prettier": "^6.0.0",
"jest": "^24.8.0",
"prettier": "^1.18.2",
"rollup": "^1.16.3",
"rollup-plugin-babel": "^4.3.3",
"rollup-plugin-commonjs": "^10.0.1",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-terser": "^5.0.0",
"typedoc": "^0.14.2"
}
}
4 changes: 2 additions & 2 deletions src/DataStructures/Dictionary.js
Expand Up @@ -52,7 +52,7 @@ class Dictionary extends IEnumerable {
} else {
for (let t of this._data.get(this._comparer.GetHashCode(key))) {
if (this._comparer.Equals(t.key, key)) {
throw "Key already exists";
throw new Error("Key already exists");
}
}
this._data.get(this._comparer.GetHashCode(key)).push({ key, value });
Expand Down Expand Up @@ -105,7 +105,7 @@ class Dictionary extends IEnumerable {
if (this._comparer.Equals(t.key, key)) return t.value;
}
}
throw "Key does not exist";
throw new Error("Key does not exist");
}

Set(key, value) {
Expand Down
45 changes: 25 additions & 20 deletions src/DataStructures/List.js
Expand Up @@ -36,12 +36,14 @@ class List extends IEnumerable {
}

Get(index) {
if (index < 0 || index >= this.CountNative) throw "Index not valid";
if (index < 0 || index >= this.CountNative)
throw new Error("Index not valid");
return this._data[index];
}

Set(index, item) {
if (index < 0 || index >= this.CountNative) throw "Index not valid";
if (index < 0 || index >= this.CountNative)
throw new Error("Index not valid");
this._data[index] = item;
}

Expand Down Expand Up @@ -71,11 +73,11 @@ class List extends IEnumerable {
[index, count, item, comparer] = args;
comparer = comparer || this._comparer;
} else {
throw "Wrong number of arguments";
throw new Error("Wrong number of arguments");
}

if (index < 0 || count < 0 || index + count > this.CountNative)
throw "Not a valid range";
throw new Error("Not a valid range");

let start = index;
let stop = index + count - 1;
Expand Down Expand Up @@ -123,7 +125,7 @@ class List extends IEnumerable {
} else if (args.length === 4) {
[index, array, arrayIndex, count] = args;
} else {
throw "Wrong number of arguments";
throw new Error("Wrong number of arguments");
}

if (
Expand All @@ -133,7 +135,7 @@ class List extends IEnumerable {
index + count > this.CountNative ||
arrayIndex + count > array.length
)
throw "Not a valid range";
throw new Error("Not a valid range");

for (let i = 0; i < count; i++) {
array[arrayIndex + i] = this._data[index + i];
Expand Down Expand Up @@ -170,11 +172,11 @@ class List extends IEnumerable {
} else if (args.length === 3) {
[startIndex, count, match] = args;
} else {
throw "Wrong number of arguments";
throw new Error("Wrong number of arguments");
}

if (startIndex < 0 || count < 0 || startIndex + count > this.CountNative)
throw "Not a valid range";
throw new Error("Not a valid range");

for (let i = startIndex; i < startIndex + count; i++) {
if (match(this._data[i])) return i;
Expand Down Expand Up @@ -204,11 +206,11 @@ class List extends IEnumerable {
} else if (args.length === 3) {
[startIndex, count, match] = args;
} else {
throw "Wrong number of arguments";
throw new Error("Wrong number of arguments");
}

if (startIndex < 0 || count < 0 || startIndex + count > this.CountNative)
throw "Not a valid range";
throw new Error("Not a valid range");

let last_i = -1;
for (let i = startIndex; i < startIndex + count; i++) {
Expand All @@ -221,7 +223,7 @@ class List extends IEnumerable {

GetRange(index, count) {
if (index < 0 || count < 0 || index + count > this.CountNative)
throw "Not a valid range";
throw new Error("Not a valid range");

return new List(this.Skip(index).Take(count), this._comparer);
}
Expand All @@ -233,7 +235,7 @@ class List extends IEnumerable {
*/
IndexOf(item, index = 0, count = this.CountNative - index) {
if (index < 0 || count < 0 || index + count > this.CountNative)
throw "Not a valid range";
throw new Error("Not a valid range");

for (let i = index; i < index + count; i++) {
if (this._comparer(item, this._data[i]) === 0) return i;
Expand All @@ -242,13 +244,15 @@ class List extends IEnumerable {
}

Insert(index, item) {
if (index < 0 || index > this.CountNative) throw "Not a valid range";
if (index < 0 || index > this.CountNative)
throw new Error("Not a valid range");

this._data.splice(index, 0, item);
}

InsertRange(index, collection) {
if (index < 0 || index > this.CountNative) throw "Not a valid range";
if (index < 0 || index > this.CountNative)
throw new Error("Not a valid range");

if (getType(collection) != "Array") collection = [...collection];
var args = [index, 0].concat(collection);
Expand All @@ -262,7 +266,7 @@ class List extends IEnumerable {
*/
LastIndexOf(item, index = 0, count = this.CountNative - index) {
if (index < 0 || count < 0 || index + count > this.CountNative)
throw "Not a valid range";
throw new Error("Not a valid range");

let foundInd = -1;
for (let i = index; i < index + count; i++) {
Expand All @@ -288,13 +292,14 @@ class List extends IEnumerable {
}

RemoveAt(index) {
if (index < 0 || index >= this.CountNative) throw "Not a valid range";
if (index < 0 || index >= this.CountNative)
throw new Error("Not a valid range");
this._data.splice(index, 1);
}

RemoveRange(index, count) {
if (index < 0 || count < 0 || index + count > this.CountNative)
throw "Not a valid range";
throw new Error("Not a valid range");
this._data.splice(index, count);
}

Expand All @@ -304,7 +309,7 @@ class List extends IEnumerable {
*/
ReverseNative(index = 0, count = this.CountNative - index) {
if (index < 0 || count < 0 || index + count > this.CountNative)
throw "Not a valid range";
throw new Error("Not a valid range");

if (index === 0 && count === this.CountNative) {
this._data.reverse();
Expand Down Expand Up @@ -335,12 +340,12 @@ class List extends IEnumerable {
[index, count, comparer] = args;
comparer = comparer || this._comparer;
} else {
throw "Wrong number of arguments";
throw new Error("Wrong number of arguments");
}
}

if (index < 0 || count < 0 || index + count > this.CountNative)
throw "Not a valid range";
throw new Error("Not a valid range");

if (index === 0 && count === this.CountNative) {
this._data.sort(comparer);
Expand Down
32 changes: 16 additions & 16 deletions src/Methods/Methods.js
Expand Up @@ -21,7 +21,7 @@ setMtd("Aggregate", function(arg1, arg2, resultSelector = t => t) {
let fun, seed;
let thisIterator = this[Symbol.iterator]();
let val = thisIterator.next();
if (val.done) throw "Source contains no elements";
if (val.done) throw new Error("Source contains no elements");
if (getType(arg1) === "function") {
// first argument is accumulator function and is only argument
seed = defaultVal(getType(val.value));
Expand Down Expand Up @@ -73,7 +73,7 @@ setMtd("Cast", function() {
});

setMtd("Concat", function*(second) {
if (second == null) throw "Second is null";
if (second == null) throw new Error("Second is null");
yield* this;
yield* second;
});
Expand Down Expand Up @@ -122,7 +122,7 @@ setMtd("ElementAt", function(index) {
if (cur++ === index) return t;
}
}
throw "Out of range";
throw new Error("Out of range");
});

setMtd("ElementAtOrDefault", function(index, defaultValue = null) {
Expand All @@ -137,14 +137,14 @@ setMtd("Except", function*(
second,
comparer = EqualityComparers.PrimitiveComparer
) {
if (second == null) throw "Second is null";
if (second == null) throw new Error("Second is null");
let sec = Enumerable.From(second).ToHashSet(comparer);
for (let t of this) if (sec.Add(t)) yield t;
});

setMtd("First", function(predicate = _t => true) {
for (let t of this) if (predicate(t)) return t;
throw "No first element";
throw new Error("No first element");
});

setMtd("FirstOrDefault", function(predicate = _t => true, defaultValue = null) {
Expand Down Expand Up @@ -194,7 +194,7 @@ setMtd("GroupBy", function(
resultSelector = arg2; // 5
if (getType(arg3) === "Object") comparer = arg3; // 6
} else {
throw "Wrong arguments";
throw new Error("Wrong arguments");
}

return this.ToLookup(keySelector, elementSelector, comparer).Select(g =>
Expand All @@ -221,7 +221,7 @@ setMtd("Intersect", function*(
second,
comparer = EqualityComparers.PrimitiveComparer
) {
if (second == null) throw "Second is null";
if (second == null) throw new Error("Second is null");
let first = this.ToHashSet(comparer);
for (let t of second) {
let val = first.TryGetValue(t);
Expand Down Expand Up @@ -257,7 +257,7 @@ setMtd("Last", function(predicate = _t => true) {
last = t;
notfound = false;
}
if (notfound) throw "No last element";
if (notfound) throw new Error("No last element");
return last;
});

Expand All @@ -270,7 +270,7 @@ setMtd("LastOrDefault", function(predicate = _t => true, defaultValue = null) {
setMtd("Max", function(selector = t => t) {
let thisIterator = this[Symbol.iterator]();
let val = thisIterator.next();
if (val.done) throw "Source contains no elements";
if (val.done) throw new Error("Source contains no elements");
let myval = selector(val.value);

for (let t of this) if (selector(t) > myval) myval = selector(t);
Expand All @@ -281,7 +281,7 @@ setMtd("Max", function(selector = t => t) {
setMtd("Min", function(selector = t => t) {
let thisIterator = this[Symbol.iterator]();
let val = thisIterator.next();
if (val.done) throw "Source contains no elements";
if (val.done) throw new Error("Source contains no elements");
let myval = selector(val.value);

for (let t of this) if (selector(t) < myval) myval = selector(t);
Expand Down Expand Up @@ -331,7 +331,7 @@ setMtd("SequenceEqual", function(
second,
comparer = EqualityComparers.PrimitiveComparer
) {
if (second == null) throw "Second is null";
if (second == null) throw new Error("Second is null");
let thisIterator = this[Symbol.iterator]();
let secondIterator = second[Symbol.iterator]();
// eslint-disable-next-line no-constant-condition
Expand All @@ -347,8 +347,8 @@ setMtd("SequenceEqual", function(
setMtd("Single", function(predicate = _t => true) {
let thisIterator = this.Where(predicate)[Symbol.iterator]();
let val = thisIterator.next();
if (val.done) throw "No element";
if (!thisIterator.next().done) throw "More than 1 element";
if (val.done) throw new Error("No element");
if (!thisIterator.next().done) throw new Error("More than 1 element");
return val.value;
});

Expand All @@ -359,7 +359,7 @@ setMtd("SingleOrDefault", function(
let thisIterator = this.Where(predicate)[Symbol.iterator]();
let val = thisIterator.next();
if (val.done) return defaultValue;
if (!thisIterator.next().done) throw "More than 1 element";
if (!thisIterator.next().done) throw new Error("More than 1 element");
return val.value;
});

Expand Down Expand Up @@ -488,7 +488,7 @@ setMtd("Union", function*(
second,
comparer = EqualityComparers.PrimitiveComparer
) {
if (second == null) throw "Second is null";
if (second == null) throw new Error("Second is null");
let hashset = new HashSet(comparer);
for (let t of this) if (hashset.Add(t)) yield t;
for (let t of second) if (hashset.Add(t)) yield t;
Expand All @@ -500,7 +500,7 @@ setMtd("Where", function*(predicate) {
});

setMtd("Zip", function*(second, resultSelector) {
if (second == null) throw "Second is null";
if (second == null) throw new Error("Second is null");
let thisIterator = this[Symbol.iterator]();
let secondIterator = second[Symbol.iterator]();
while (true) {
Expand Down
3 changes: 2 additions & 1 deletion src/NoConflict/NoConflict.js
Expand Up @@ -6,7 +6,8 @@ const {
} = require("./AddConflict");

const noConflict = function() {
if (noConflictMode.value) throw "You can call noConflict only once!";
if (noConflictMode.value)
throw new Error("You can call noConflict only once!");

if (typeof window !== "undefined") {
// only browser - remove global vars
Expand Down

0 comments on commit 6d7353d

Please sign in to comment.