Skip to content

Commit a231f7e

Browse files
committed
added jsdoc
1 parent 1125995 commit a231f7e

31 files changed

+640
-117
lines changed

.bowerrc

Lines changed: 0 additions & 3 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
.vscode
21
node_modules
3-
lib
2+
bower_components

.npmignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
.vscode
22
node_modules
3-
lib
3+
bower_components
44
test
55
demo
6-
.bowerrc
76
bower.json
87
gulpfile.js

.vscode/settings.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"typescript.tsdk": "./node_modules/typescript/lib",
3+
"files.exclude": {
4+
".vscode": false,
5+
"dist": false,
6+
"node_modules": false,
7+
"bower_components": false
8+
}
9+
}

README.md

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ Conclusion:
3535
* Lightweight
3636
* Fast
3737
* Syntax from .NET
38+
* Build on top of array-prototype and no changes in code are required for usage
39+
* Integrates seamlessly into the project
40+
* TypeScript definitions
3841

3942
## Getting Started
4043

@@ -52,21 +55,21 @@ bower install linq4js
5255

5356
### Using JavaScript
5457

55-
Include this Line in your Project
58+
Include this line in your project
5659

5760
```html
5861
<script type="text/javascript" src="Linq4JS.js"></script>
5962
```
6063

6164
### Using TypeScript
6265

63-
Same thing, but also copy `Linq4JS.d.ts` to your project Folder to get the tooling support.
66+
Same thing, but also copy `Linq4JS.d.ts` to your project folder to get the tooling support.
6467

6568
## Usage
6669

6770
### Clone
6871

69-
Create a copy of the array
72+
Creates a copy of the array
7073

7174
```javascript
7275
var array = ["item1", "item2", "item3", "item4", "no"];
@@ -77,7 +80,7 @@ array.Clone();
7780

7881
### FindIndex
7982

80-
Get the Index of the first item found by a filter
83+
Gets the index of the first item found by a filter
8184

8285
```javascript
8386
var array = ["item1", "item2", "item3", "item4", "no"];
@@ -119,9 +122,9 @@ array.ForEach("i => console.log(i)");
119122

120123
### Update & UpdateRange
121124

122-
Updates in Object in the array
125+
Updates object(s) in the array
123126

124-
By default this method uses the property **Id** to Identify the Objects. If The property is not set this methods tries to compare the objects directly.
127+
By default this method uses the property **Id** to identify the objects. If the property is not set this methods tries to compare the objects directly.
125128

126129
```javascript
127130
var array = [{Id: 1, Value: "item1"}, {Id: 2, Value: "item2"}];
@@ -130,7 +133,7 @@ var array = [{Id: 1, Value: "item1"}, {Id: 2, Value: "item2"}];
130133
array.Update({Id: 1, Value: "item3"});
131134
```
132135

133-
If you want this method to use other Fields for Identification define a selector function as second parameter.
136+
If you want this method to use other fields for identification define a selector function as second parameter.
134137

135138
```javascript
136139
var array = [{OtherId: 1, Value: "item1"}, {OtherId: 2, Value: "item2"}];
@@ -154,7 +157,7 @@ array.UpdateRange(
154157

155158
Removes item(s) from array
156159

157-
By default this method uses the property **Id** to Identify the Objects. If The property is not set this methods tries to compare the objects directly.
160+
By default this method uses the property **Id** to identify the objects. If the property is not set this methods tries to compare the objects directly.
158161

159162
```javascript
160163
var array = ["item1", "item2", "item3", "item4", "no"];
@@ -166,7 +169,7 @@ array.Remove("no");
166169
array.RemoveRange(["item4", "item3"]);
167170
```
168171

169-
If you want this method to use other Fields for Identification define a selector function as second parameter.
172+
If you want this method to use other fields for identification define a selector function as second parameter.
170173

171174
```javascript
172175
var array = [{OtherId: 1, Value: "item1"}, {OtherId: 2, Value: "item2"}];
@@ -202,7 +205,7 @@ array.Insert("item2.5", 2);
202205

203206
### Where
204207

205-
Search for all items in array that match the filter
208+
Searches for all items in array that match the given filter
206209

207210
```javascript
208211
var array = ["item1", "item2", "item3", "item4", "no"];
@@ -254,7 +257,7 @@ array.SequenceEqual(array3);
254257

255258
### Any
256259

257-
Tests if any item is in the array and if set matches the filter
260+
Tests if any item is in the array and if a filter is set if any item of the array matches the filter
258261

259262
```javascript
260263
var array = ["item1", "item2", "item3", "item4", "no"];
@@ -431,7 +434,7 @@ array2.Sum();
431434

432435
### First
433436

434-
Returns the First item of the array and if a filter was set the first item that matches the filter - Throws an Exception if no item was found
437+
Returns the first item of the array and if a filter was set the first item that matches the filter - Throws an exception if no item was found
435438

436439
```javascript
437440
var array = ["no", "item1", "item2", "item3", "item4", "no"];
@@ -448,7 +451,7 @@ array.First("i => i == 'notgiven'");
448451

449452
### FirstOrDefault
450453

451-
Returns the First item of the array and if a filter was set the first item that matches the filter - returns `null` if no suitable item was found
454+
Returns the first item of the array and if a filter was set the first item that matches the filter - returns `null` if no suitable item was found
452455

453456
```javascript
454457
var array = ["no", "item1", "item2", "item3", "item4", "no"];
@@ -481,7 +484,7 @@ array.Min("x => x.age");
481484

482485
### Last
483486

484-
Returns the Last item of the array and if a filter was set the last item that matches the filter - Throws an Exception if no item was found
487+
Returns the last item of the array and if a filter was set the last item that matches the filter - Throws an exception if no item was found
485488

486489
```javascript
487490
var array = ["no", "item1", "item2", "item3", "item4", "no"];
@@ -498,7 +501,7 @@ array.Last("i => i == 'notgiven'");
498501

499502
### LastOrDefault
500503

501-
Returns the Last item of the array and if a filter was set the last item that matches the filter - returns `null` if no suitable item was found
504+
Returns the last item of the array and if a filter was set the last item that matches the filter - returns `null` if no suitable item was found
502505

503506
```javascript
504507
var array = ["no", "item1", "item2", "item3", "item4", "no"];
@@ -545,7 +548,7 @@ array.Select("i => {Custom: i.Id, Name: i.Value}");
545548

546549
### Take
547550

548-
Limits the Number of entries taken
551+
Limits the number of entries taken
549552

550553
```javascript
551554
var array = ["item1", "item2", "item3", "item4"];
@@ -602,7 +605,7 @@ array.Skip(2);
602605

603606
### GroupBy
604607

605-
Group Array by Property
608+
Groups array by property
606609

607610
```javascript
608611
var array = [
@@ -621,7 +624,7 @@ array.GroupBy("i => i.name.toLowerCase()");
621624

622625
### OrderBy & OrderByDescending
623626

624-
Order Array by Property or Value
627+
Orders array by property or value
625628

626629
```javascript
627630
var array = ["item3", "item1", "item2", "item4"];
@@ -633,7 +636,7 @@ array.OrderByDescending("i => i");
633636
array.OrderBy("i => i");
634637
```
635638

636-
Also supports complex Properties
639+
Also supports complex properties
637640

638641
```javascript
639642
var array = [
@@ -655,7 +658,7 @@ array.OrderBy("i => i.Lastname");
655658

656659
### ThenBy & ThenByDescending
657660

658-
Order Array by additional Properties in combination with OrderBy/OrderByDescending
661+
Orders array by additional properties in combination with OrderBy/OrderByDescending
659662

660663
```javascript
661664
var array = [
@@ -690,15 +693,7 @@ var array = ["item1", "item2", "item2", "item3", "item4"];
690693

691694
//["item1", "item2", "item3", "item4"]
692695
array.Distinct("x => x");
693-
```
694-
695-
If you want to select the last value in the order set a second parameter to true
696-
697-
```javascript
698-
var array = ["item1", "item2", "item2", "item3", "item4"];
699-
700-
//["item1", "item2", "item3", "item4"]
701-
array.Distinct("x => x", true);
696+
array.Distinct();
702697
```
703698

704699
## Author

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"ignore": [
1919
".vscode",
2020
"node_modules",
21-
"lib",
21+
"bower_components",
2222
"test",
2323
"demo",
2424
".gitignore",

demo/demo.js

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"use strict";
12
var User = (function () {
23
function User(_id, _firstName, _name, _age) {
34
this.Id = _id;
@@ -33,29 +34,11 @@ window.onload = function () {
3334
};
3435
var test = [new User(1, "Max", "Mustermann", 18), new User(2, "John", "Doe", 89), new User(2, "John", "Doe", 18)];
3536
console.log(test.Where(function (x) { return x.Age > 10; }));
37+
test.Add(new User(5, "User", "Test", 12), true);
3638
var result = test.Aggregate(function (x, y) {
3739
return x += y.Age;
3840
});
3941
console.log(result);
4042
var array = ["item1", "item2", "item3", "item2", "item4"];
4143
var res2 = array.TakeWhile('(x, s) => x != "item2" || s.c < 1', 's => s.c = 0', '(x, s) => x == "item2" && s.c++');
4244
console.log(res2);
43-
//let test: Array<Linq4JS.Entity> = [new testClass("test", 5, 1), new testClass("test5", 3, 2)];
44-
//console.log(test);
45-
//console.log("Foreach");
46-
//test.ForEach(x => console.log(x.Name));
47-
//console.log("Foreach End");
48-
//console.log(test.Take(1));
49-
//console.log(test.Skip(1));
50-
//test.Update(new testClass("test1235234234234", 3, 1), "x => x.OtherId");
51-
//console.log(test);
52-
//console.log(test.Where(x => x.Id == 3));
53-
//console.log(test.Any(x => x.Id == 78));
54-
//console.log(test.First(x => x.Id == 3));
55-
//console.log(test.FirstOrDefault());
56-
//console.log(test.Last(x => x.Id == 3));
57-
//console.log(test.LastOrDefault(x => x.Id == 44));
58-
//console.log(test.Select(x => new displayClass(x)));
59-
//test.Remove(new testClass("test55", 3, 1), x => x.OtherId);
60-
//console.log(test);
61-
//console.log(test.Count(x => x.Id > 3));

demo/js/app.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ window.onload = function () {
4848
let test: Array<User> = [new User(1, "Max", "Mustermann", 18), new User(2, "John", "Doe", 89), new User(2, "John", "Doe", 18)];
4949
console.log(test.Where(x => x.Age > 10));
5050

51+
test.Add(new User(5, "User", "Test", 12), true);
52+
5153
let result = test.Aggregate((x, y) => {
5254
return x += y.Age;
5355
});
5456

5557
console.log(result);
5658

57-
5859
let array = ["item1", "item2", "item3", "item2", "item4"];
59-
6060
let res2 = array.TakeWhile('(x, s) => x != "item2" || s.c < 1', 's => s.c = 0', '(x, s) => x == "item2" && s.c++');
6161

6262
console.log(res2);

dev/Entity.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
namespace Linq4JS {
2-
export class Entity {
3-
constructor(_id: number) {
4-
this.Id = _id;
5-
}
6-
2+
export class GeneratedEntity{
3+
_GeneratedId_: number;
74
Id: number;
85
}
96
}

0 commit comments

Comments
 (0)