Skip to content

Commit 035ce3c

Browse files
committed
added unit tests, fixed some errors
1 parent d2f6683 commit 035ce3c

30 files changed

+706
-303
lines changed

bower.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,5 @@
2424
".gitignore",
2525
".npmignore",
2626
"gulpfile.js"
27-
],
28-
"devDependencies": {
29-
"qunit": "^2.1.1"
30-
}
27+
]
3128
}
File renamed without changes.

demo/tsconfig.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"compilerOptions": {
3+
"noImplicitAny": true,
4+
"noImplicitReturns": true,
5+
"alwaysStrict": true,
6+
"target": "es5",
7+
"outFile": "demo.js"
8+
},
9+
"include": [
10+
"../dist/linq4js.d.ts",
11+
"./**/*"
12+
]
13+
}

dev/IArray.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,8 @@
6969
/**
7070
* Adds objects to the array
7171
* @param objects The array of objects to add
72-
* @param generateId Auto-generate a property to identify objects in later processes
7372
*/
74-
AddRange(objects: Array<T>): Array<T>;
73+
AddRange(objects: Array<T>, generateId?: boolean): Array<T>;
7574

7675
/**
7776
* Inserts an entry at a specific position

dev/Modules/AddRange.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
Array.prototype.AddRange = function<T> (objects: Array<T>): Array<T> {
1+
Array.prototype.AddRange = function<T> (objects: Array<T>, generateId: boolean): Array<T> {
22
let that: Array<T> = this;
33

44
objects.ForEach(function (x: T) {
5-
that.Add(x);
5+
that.Add(x, generateId);
66
});
77

88
return that;

dist/linq4js.d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,8 @@ interface Array<T> {
7171
/**
7272
* Adds objects to the array
7373
* @param objects The array of objects to add
74-
* @param generateId Auto-generate a property to identify objects in later processes
7574
*/
76-
AddRange(objects: Array<T>): Array<T>;
75+
AddRange(objects: Array<T>, generateId?: boolean): Array<T>;
7776
/**
7877
* Inserts an entry at a specific position
7978
* @param object The object to insert

dist/linq4js.js

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -93,23 +93,6 @@ var Linq4JS;
9393
"use strict";
9494
"use strict";
9595
"use strict";
96-
var Linq4JS;
97-
(function (Linq4JS) {
98-
var OrderEntry = (function () {
99-
function OrderEntry(_direction, _valueSelector) {
100-
this.Direction = _direction;
101-
this.ValueSelector = _valueSelector;
102-
}
103-
return OrderEntry;
104-
}());
105-
Linq4JS.OrderEntry = OrderEntry;
106-
var OrderDirection;
107-
(function (OrderDirection) {
108-
OrderDirection[OrderDirection["Ascending"] = 0] = "Ascending";
109-
OrderDirection[OrderDirection["Descending"] = 1] = "Descending";
110-
})(OrderDirection = Linq4JS.OrderDirection || (Linq4JS.OrderDirection = {}));
111-
})(Linq4JS || (Linq4JS = {}));
112-
"use strict";
11396
Array.prototype.Add = function (object, generateId) {
11497
var that = this;
11598
if (object != null) {
@@ -135,10 +118,10 @@ Array.prototype.Add = function (object, generateId) {
135118
return that;
136119
};
137120
"use strict";
138-
Array.prototype.AddRange = function (objects) {
121+
Array.prototype.AddRange = function (objects, generateId) {
139122
var that = this;
140123
objects.ForEach(function (x) {
141-
that.Add(x);
124+
that.Add(x, generateId);
142125
});
143126
return that;
144127
};
@@ -782,3 +765,20 @@ Array.prototype.Zip = function (array, result) {
782765
}
783766
return newArray;
784767
};
768+
"use strict";
769+
var Linq4JS;
770+
(function (Linq4JS) {
771+
var OrderEntry = (function () {
772+
function OrderEntry(_direction, _valueSelector) {
773+
this.Direction = _direction;
774+
this.ValueSelector = _valueSelector;
775+
}
776+
return OrderEntry;
777+
}());
778+
Linq4JS.OrderEntry = OrderEntry;
779+
var OrderDirection;
780+
(function (OrderDirection) {
781+
OrderDirection[OrderDirection["Ascending"] = 0] = "Ascending";
782+
OrderDirection[OrderDirection["Descending"] = 1] = "Descending";
783+
})(OrderDirection = Linq4JS.OrderDirection || (Linq4JS.OrderDirection = {}));
784+
})(Linq4JS || (Linq4JS = {}));

dist/linq4js.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gulpfile.js

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,9 @@ var gulp = require("gulp");
22

33
var minify = require("gulp-minify");
44
var typescript = require("gulp-typescript");
5-
var devTS = typescript.createProject("tsconfig.json", {
6-
outFile: "linq4js.js",
7-
declaration: true
8-
});
9-
var demoTS = typescript.createProject("tsconfig.json", {
10-
outFile: "demo.js"
11-
});
12-
var testTS = typescript.createProject("tsconfig.json", {
13-
outFile: "test.js"
14-
});
5+
var devTS = typescript.createProject("tsconfig.json");
6+
var demoTS = typescript.createProject("demo/tsconfig.json");
7+
var testTS = typescript.createProject("test/tsconfig.json");
158

169
var merge = require("merge2");
1710

@@ -20,19 +13,19 @@ var connect = require("gulp-connect");
2013

2114
/*JS*/
2215
gulp.task("demots", function () {
23-
return gulp.src(["demo/**/*.ts", "dist/linq4js.d.ts"])
16+
return demoTS.src()
2417
.pipe(demoTS())
2518
.pipe(gulp.dest("demo"));
2619
});
2720

2821
gulp.task("testts", function () {
29-
return gulp.src("test/**/*.ts")
22+
return testTS.src()
3023
.pipe(testTS())
3124
.pipe(gulp.dest("test"));
3225
});
3326

3427
gulp.task("typescript", function () {
35-
var tsResult = gulp.src("dev/**/*.ts")
28+
var tsResult = devTS.src()
3629
.pipe(devTS());
3730

3831
return merge([

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "linq4js",
3-
"version": "2.0.2",
3+
"version": "2.0.3",
44
"description": "Linq methods for JavaScript/TypeScript for working with Arrays",
55
"main": "dist/linq4js.js",
66
"typings": "dist/linq4js.d.ts",
@@ -25,12 +25,14 @@
2525
},
2626
"homepage": "https://github.com/morrisjdev/Linq4JS",
2727
"devDependencies": {
28+
"@types/qunit": "^2.0.31",
2829
"browser-sync": "^2.18.6",
2930
"gulp": "^3.9.1",
3031
"gulp-connect": "^5.0.0",
3132
"gulp-minify": "0.0.14",
3233
"gulp-typescript": "^3.1.4",
3334
"merge2": "^1.0.3",
35+
"qunitjs": "^2.1.1",
3436
"typescript": "^2.1.5"
3537
}
3638
}

0 commit comments

Comments
 (0)