Skip to content

Commit 0711e38

Browse files
committed
added jasmine, tslint fixes
1 parent 6de7ccf commit 0711e38

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+2168
-992
lines changed

.npmignore

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
.vscode
2-
.gitignore
3-
node_modules
42
bower_components
5-
test
63
demo
4+
node_modules
5+
test
6+
.gitignore
7+
.npmignore
8+
.travis.yml
79
bower.json
810
gulpfile.js

.travis.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
language: node_js
2+
node_js:
3+
- "node"
4+
before_script:
5+
- npm install -g gulp
6+
script: gulp test

.vscode/settings.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
{
22
"typescript.tsdk": "./node_modules/typescript/lib",
33
"files.exclude": {
4-
".vscode": false,
5-
"dist": false,
6-
"node_modules": false,
7-
"bower_components": false
4+
".vscode": true,
5+
"dist": true,
6+
"node_modules": true,
7+
"bower_components": true,
8+
"test/*.js": true,
9+
"demo/*.js": true,
10+
".gitignore": true,
11+
".npmignore": true
812
}
913
}

bower.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@
1717
"homepage": "https://github.com/morrisjdev/Linq4JS",
1818
"ignore": [
1919
".vscode",
20-
"node_modules",
2120
"bower_components",
22-
"test",
2321
"demo",
22+
"node_modules",
23+
"test",
2424
".gitignore",
2525
".npmignore",
26+
".travis.yml",
2627
"gulpfile.js"
2728
]
2829
}

dev/Entity.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace Linq4JS {
2-
export class GeneratedEntity{
3-
_GeneratedId_: number;
4-
Id: number;
2+
export class GeneratedEntity {
3+
public _GeneratedId_: number;
4+
public Id: number;
55
}
66
}

dev/Helper.ts

Lines changed: 34 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,92 +1,85 @@
11
namespace Linq4JS {
22
export class Helper {
3-
static ConvertStringFunction = function (functionString: string): any {
4-
5-
if (functionString.length == 0) {
6-
throw "Linq4JS: Cannot convert empty string to function";
3+
private static ConvertStringFunction(functionString: string): any {
4+
if (functionString.length === 0) {
5+
throw new Error("Linq4JS: Cannot convert empty string to function");
76
}
87

9-
let varnameString: string = functionString.substring(0, functionString.indexOf("=>")).replace(" ", "").replace("(", "").replace(")", "");
8+
let varnameString: string = functionString
9+
.substring(0, functionString.indexOf("=>"))
10+
.replace(" ", "")
11+
.replace("(", "")
12+
.replace(")", "");
1013

11-
let varnames: Array<string> = varnameString.split(",");
14+
let varnames: string[] = varnameString.split(",");
1215

1316
let func: string = functionString
14-
.substring(functionString.indexOf("=>") + 2)
17+
.substring(functionString.indexOf("=>") + ("=>").length)
1518
.replace("{", "").replace("}", "")
1619
.split(".match(//gi)").join("");
1720

1821
/*No return outside of quotations*/
19-
if(func.match(/return(?=([^\"']*[\"'][^\"']*[\"'])*[^\"']*$)/g) == null){
22+
if (func.match(/return(?=([^\"']*[\"'][^\"']*[\"'])*[^\"']*$)/g) == null) {
2023
func = "return " + func;
2124
}
2225

2326
return Function(...varnames, func);
2427
}
2528

26-
static ConvertFunction = function<T> (testFunction: any): T {
27-
29+
public static ConvertFunction<T>(testFunction: string | T): T {
2830
let result: T;
2931

30-
if (typeof testFunction == "function") {
32+
if (typeof testFunction === "function") {
3133
result = testFunction;
32-
}
33-
else if (typeof testFunction == "string") {
34+
} else if (typeof testFunction === "string") {
3435
result = Linq4JS.Helper.ConvertStringFunction(testFunction);
35-
}
36-
else {
37-
throw `Linq4JS: Cannot use '${testFunction}' as function`;
36+
} else {
37+
throw new Error(`Linq4JS: Cannot use '${testFunction}' as function`);
3838
}
3939

4040
return result;
4141
}
4242

43-
static OrderCompareFunction = function<T> (valueSelector: (item: T) => any, a: T, b: T, invert: boolean): number {
44-
let value_a = valueSelector(a);
45-
let value_b = valueSelector(b);
43+
public static OrderCompareFunction<T>(valueSelector: (item: T) => any, a: T, b: T, invert: boolean): number {
44+
let value_a: any = valueSelector(a);
45+
let value_b: any = valueSelector(b);
4646

47-
let type = typeof value_a;
47+
let type: string = typeof value_a;
4848

49-
if (type == "string") {
49+
if (type === "string") {
5050
let value_a_string: string = value_a;
5151
value_a_string = value_a_string.toLowerCase();
5252
let value_b_string: string = value_b;
5353
value_b_string = value_b_string.toLowerCase();
5454

5555
if (value_a_string > value_b_string) {
56-
return invert == true ? -1 : 1;
57-
}
58-
else if (value_a_string < value_b_string) {
59-
return invert == true ? 1 : -1;
60-
}
61-
else {
56+
return invert === true ? -1 : 1;
57+
} else if (value_a_string < value_b_string) {
58+
return invert === true ? 1 : -1;
59+
} else {
6260
return 0;
6361
}
6462

65-
}
66-
else if (type == "number") {
63+
} else if (type === "number") {
6764
let value_a_number: number = value_a;
6865
let value_b_number: number = value_b;
6966

70-
return invert == true ? value_b_number - value_a_number : value_a_number - value_b_number;
71-
}
72-
else if (type == "boolean") {
67+
return invert === true ? value_b_number - value_a_number : value_a_number - value_b_number;
68+
} else if (type === "boolean") {
7369
let value_a_bool: boolean = value_a;
7470
let value_b_bool: boolean = value_b;
7571

76-
if (value_a_bool == value_b_bool) {
72+
if (value_a_bool === value_b_bool) {
7773
return 0;
78-
}
79-
else {
80-
if (invert == true) {
74+
} else {
75+
if (invert === true) {
8176
return value_a_bool ? 1 : -1;
82-
}
83-
else {
77+
} else {
8478
return value_a_bool ? -1 : 1;
8579
}
8680
}
87-
}
88-
else {
89-
throw `Linq4JS: Cannot map type '${type}' for compare"`;
81+
} else {
82+
throw new Error(`Linq4JS: Cannot map type '${type}' for compare`);
9083
}
9184
}
9285
}

dev/IArray.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@
134134
* @param filter If set the function returns the last item that matches the filter
135135
*/
136136
Last(filter?: ((item: T) => boolean) | string): T;
137-
137+
138138
/**
139139
* Returns the last item of the array - returns `null` if no suitable item was found
140140
* @param filter If set the function returns the last item that matches the filter
@@ -155,11 +155,14 @@
155155

156156
/**
157157
* Takes entries as long as a condition is true
158-
* @param condition The condition-function (or function-string) that returns a boolean. All elements until a false gets created are taken
158+
* @param condition The condition-function (or function-string) that returns a boolean. All elements until a false gets thrown are taken
159159
* @param initial A initial-function (or function-string) that gets executed once at the start of the loop
160160
* @param after A function that gets executed after every element-iteration after the condition-function was evaluated
161161
*/
162-
TakeWhile(condition: ((item: T, storage?: any) => boolean) | string, initial?: ((storage: any) => void) | string, after?: ((item: T, storage: any) => void) | string): T[];
162+
TakeWhile(
163+
condition: ((item: T, storage?: any) => boolean) | string,
164+
initial?: ((storage: any) => void) | string,
165+
after?: ((item: T, storage: any) => void) | string): T[];
163166

164167
/**
165168
* Skips entries

dev/Modules/Add.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,22 @@
22
let that: T[] = this;
33

44
if (object != null) {
5-
if (generateId == true) {
5+
if (generateId === true) {
66
let newIndex: number;
77

88
let castedObject: Linq4JS.GeneratedEntity = object as any;
99
let last: Linq4JS.GeneratedEntity = that.LastOrDefault() as any;
10-
if(last != null){
10+
if (last != null) {
1111
newIndex = last._GeneratedId_ != null ? last._GeneratedId_ : 1;
1212

13-
while(that.Any(function(x: any){
14-
return (x as Linq4JS.GeneratedEntity)._GeneratedId_ == newIndex;
15-
})){
13+
while (that.Any(function(x: any) {
14+
return (x as Linq4JS.GeneratedEntity)._GeneratedId_ === newIndex;
15+
})) {
1616
newIndex++;
1717
}
1818

1919
castedObject._GeneratedId_ = newIndex;
20-
}
21-
else{
20+
} else {
2221
castedObject._GeneratedId_ = 1;
2322
}
2423
}

dev/Modules/Aggregate.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33

44
let result: any;
55

6-
if(startVal != null){
6+
if (startVal != null) {
77
result = startVal;
8-
}
9-
else{
8+
} else {
109
result = "";
1110
}
12-
11+
1312
let methodFunction = Linq4JS.Helper.ConvertFunction<(result: any, item: T) => any>(method);
1413

1514
that.ForEach(function(x){

dev/Modules/All.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Array.prototype.All = function<T> (this: T[], filter: ((item: T) => boolean) | string): boolean {
22
let that: T[] = this;
33

4-
return that.Count(filter) == that.Count();
4+
return that.Count(filter) === that.Count();
55
};

0 commit comments

Comments
 (0)