linqx 0.1.8 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +151 -151
  3. package/dist/linq.d.ts +255 -255
  4. package/dist/linq.js +3085 -3085
  5. package/package.json +3 -2
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2012 Yoshifumi Kawai, Mihai Ciuraru
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2012 Yoshifumi Kawai, Mihai Ciuraru
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md CHANGED
@@ -1,151 +1,151 @@
1
- # linqx
2
-
3
- Fork of the original [linq](https://github.com/mihaifm/linq) for JavaScript, updated with modern improvements and API changes.
4
-
5
- It contains all the original .NET methods plus a few additions.
6
-
7
- Written in pure JavaScript with no dependencies.
8
-
9
- ## Examples
10
-
11
- ```js
12
- // C# LINQ - delegate
13
- Enumerable.Range(1, 10)
14
- .Where(delegate(int i) { return i % 3 == 0; })
15
- .Select(delegate(int i) { return i * 10; });
16
-
17
- // linq.js - anonymous function
18
- Enumerable.range(1, 10)
19
- .where(function(i) { return i % 3 == 0; })
20
- .select(function(i) { return i * 10; });
21
- ```
22
-
23
- ```js
24
- // C# LINQ - lambda
25
- Enumerable.Range(1, 10).Where((i) => i % 3 == 0).Select((i) => i * 10);
26
-
27
- // linq.js - arrow function
28
- Enumerable.range(1, 10).where((i) => i % 3 == 0).select((i) => i * 10);
29
- ```
30
-
31
- ```js
32
- // C# LINQ - anonymous type
33
- array.Select((val, i) => new { Value: val, Index: i }());
34
-
35
- // linq.js - object literal
36
- Enumerable.from(array).select((val, i) => ({ value: val, index: i }));
37
- ```
38
-
39
- See [sample/tutorial.js](https://github.com/mihaifm/linq/blob/master/sample/tutorial.js) and the [test](https://github.com/mihaifm/linq/tree/master/test) folder for more examples.
40
-
41
- # Usage
42
-
43
- ## Node.js (ES modules)
44
-
45
- Install the latest version of the library with npm:
46
-
47
- npm install linq
48
-
49
- Load it in your code with the `import` syntax:
50
-
51
- ```js
52
- import Enumerable from 'linq'
53
-
54
- let result = Enumerable.range(1, 10).where(i => i % 3 == 0).select(i => i * 10)
55
- console.log(result.toArray()) // [ 30, 60, 90 ]
56
- ```
57
-
58
- Because the library is an ES module, this code will only work if your project is also configured as an ES module. Add the following line in your `package.json` to make it an ES module:
59
-
60
- ```json
61
- "type": "module"
62
- ```
63
-
64
- If you're not planning to use ES modules, check the CommonJS section below.
65
-
66
- ## Node.js (CommonJS modules)
67
-
68
- Install version 3 of this library:
69
-
70
- npm install linq@3
71
-
72
- Load it with the `require` syntax:
73
-
74
- ```js
75
- const Enumerable = require('linq')
76
-
77
- let count = Enumerable.range(1, 10).count(i => i < 5)
78
- console.log(count) // 4
79
- ```
80
-
81
- The [cjs](https://github.com/mihaifm/linq/tree/cjs) branch contains the source code for the CommonJS version of the library.
82
-
83
- ## TypeScript
84
-
85
- Install the latest version of the library with npm.
86
-
87
- Configure your compiler options in `tsconfig.json`
88
-
89
- ```json
90
- "compilerOptions": {
91
- "target": "ES2020",
92
- "moduleResolution": "node"
93
- }
94
- ```
95
-
96
- The library comes with a `d.ts` file containing type definitions for all the objects and methods, feel free to use them in your code:
97
-
98
- ```ts
99
- import Enumerable from 'linq';
100
-
101
- type tnum = Enumerable.IEnumerable<number>;
102
- let x: tnum = Enumerable.from([1, 2, 3]);
103
- ```
104
-
105
- ## Deno
106
-
107
- Import the library from deno.land. Use the `@deno-types` annotation to load type definitions:
108
-
109
- ```ts
110
- // @deno-types="https://deno.land/x/linq@4.0.0/linq.d.ts"
111
- import Enumerable from 'https://deno.land/x/linq@4.0.0/linq.js'
112
-
113
- let radius = Enumerable.toInfinity(1).where(r => r * r * Math.PI > 10000).first()
114
- ```
115
-
116
- You can also install locally with npm. Use the full file path when importing the library:
117
-
118
- ```ts
119
- // @deno-types="./node_modules/linq/linq.d.ts"
120
- import Enumerable from './node_modules/linq/linq.js'
121
- ```
122
-
123
- ## Browser
124
-
125
- The minified version of the library is available in the [release](https://github.com/mihaifm/linq/releases/latest) archive.
126
-
127
- Load it via `<script type="module">`:
128
-
129
- ```html
130
- <script type="module" src="./linq.min.js"></script>
131
- <script type="module">
132
- import Enumerable from './linq.min.js'
133
- Enumerable.from([1, 2, 3]).forEach(x => console.log(x))
134
- </script>
135
- ```
136
-
137
- You can also load the library via a CDN:
138
-
139
- | CDN | URL |
140
- | ---------: | :----------------------------------------- |
141
- | unpkg | <https://unpkg.com/linq/> |
142
- | jsDelivr | <https://jsdelivr.com/package/npm/linq> |
143
- | packd | <https://bundle.run/linq@latest?name=linq> |
144
-
145
- # Credits
146
-
147
- [Yoshifumi Kawai](https://github.com/neuecc) developed the [original version](https://github.com/neuecc/linq.js/) of this library.
148
-
149
- # License
150
-
151
- [MIT License](https://github.com/mihaifm/linq/blob/master/LICENSE)
1
+ # linqx
2
+
3
+ Fork of the original [linq](https://github.com/mihaifm/linq) for JavaScript, updated with modern improvements and API changes.
4
+
5
+ It contains all the original .NET methods plus a few additions.
6
+
7
+ Written in pure JavaScript with no dependencies.
8
+
9
+ ## Examples
10
+
11
+ ```js
12
+ // C# LINQ - delegate
13
+ Enumerable.Range(1, 10)
14
+ .Where(delegate(int i) { return i % 3 == 0; })
15
+ .Select(delegate(int i) { return i * 10; });
16
+
17
+ // linq.js - anonymous function
18
+ Enumerable.range(1, 10)
19
+ .where(function(i) { return i % 3 == 0; })
20
+ .select(function(i) { return i * 10; });
21
+ ```
22
+
23
+ ```js
24
+ // C# LINQ - lambda
25
+ Enumerable.Range(1, 10).Where((i) => i % 3 == 0).Select((i) => i * 10);
26
+
27
+ // linq.js - arrow function
28
+ Enumerable.range(1, 10).where((i) => i % 3 == 0).select((i) => i * 10);
29
+ ```
30
+
31
+ ```js
32
+ // C# LINQ - anonymous type
33
+ array.Select((val, i) => new { Value: val, Index: i }());
34
+
35
+ // linq.js - object literal
36
+ Enumerable.from(array).select((val, i) => ({ value: val, index: i }));
37
+ ```
38
+
39
+ See [sample/tutorial.js](https://github.com/mihaifm/linq/blob/master/sample/tutorial.js) and the [test](https://github.com/mihaifm/linq/tree/master/test) folder for more examples.
40
+
41
+ # Usage
42
+
43
+ ## Node.js (ES modules)
44
+
45
+ Install the latest version of the library with npm:
46
+
47
+ npm install linq
48
+
49
+ Load it in your code with the `import` syntax:
50
+
51
+ ```js
52
+ import Enumerable from 'linq'
53
+
54
+ let result = Enumerable.range(1, 10).where(i => i % 3 == 0).select(i => i * 10)
55
+ console.log(result.toArray()) // [ 30, 60, 90 ]
56
+ ```
57
+
58
+ Because the library is an ES module, this code will only work if your project is also configured as an ES module. Add the following line in your `package.json` to make it an ES module:
59
+
60
+ ```json
61
+ "type": "module"
62
+ ```
63
+
64
+ If you're not planning to use ES modules, check the CommonJS section below.
65
+
66
+ ## Node.js (CommonJS modules)
67
+
68
+ Install version 3 of this library:
69
+
70
+ npm install linq@3
71
+
72
+ Load it with the `require` syntax:
73
+
74
+ ```js
75
+ const Enumerable = require('linq')
76
+
77
+ let count = Enumerable.range(1, 10).count(i => i < 5)
78
+ console.log(count) // 4
79
+ ```
80
+
81
+ The [cjs](https://github.com/mihaifm/linq/tree/cjs) branch contains the source code for the CommonJS version of the library.
82
+
83
+ ## TypeScript
84
+
85
+ Install the latest version of the library with npm.
86
+
87
+ Configure your compiler options in `tsconfig.json`
88
+
89
+ ```json
90
+ "compilerOptions": {
91
+ "target": "ES2020",
92
+ "moduleResolution": "node"
93
+ }
94
+ ```
95
+
96
+ The library comes with a `d.ts` file containing type definitions for all the objects and methods, feel free to use them in your code:
97
+
98
+ ```ts
99
+ import Enumerable from 'linq';
100
+
101
+ type tnum = Enumerable.IEnumerable<number>;
102
+ let x: tnum = Enumerable.from([1, 2, 3]);
103
+ ```
104
+
105
+ ## Deno
106
+
107
+ Import the library from deno.land. Use the `@deno-types` annotation to load type definitions:
108
+
109
+ ```ts
110
+ // @deno-types="https://deno.land/x/linq@4.0.0/linq.d.ts"
111
+ import Enumerable from 'https://deno.land/x/linq@4.0.0/linq.js'
112
+
113
+ let radius = Enumerable.toInfinity(1).where(r => r * r * Math.PI > 10000).first()
114
+ ```
115
+
116
+ You can also install locally with npm. Use the full file path when importing the library:
117
+
118
+ ```ts
119
+ // @deno-types="./node_modules/linq/linq.d.ts"
120
+ import Enumerable from './node_modules/linq/linq.js'
121
+ ```
122
+
123
+ ## Browser
124
+
125
+ The minified version of the library is available in the [release](https://github.com/mihaifm/linq/releases/latest) archive.
126
+
127
+ Load it via `<script type="module">`:
128
+
129
+ ```html
130
+ <script type="module" src="./linq.min.js"></script>
131
+ <script type="module">
132
+ import Enumerable from './linq.min.js'
133
+ Enumerable.from([1, 2, 3]).forEach(x => console.log(x))
134
+ </script>
135
+ ```
136
+
137
+ You can also load the library via a CDN:
138
+
139
+ | CDN | URL |
140
+ | ---------: | :----------------------------------------- |
141
+ | unpkg | <https://unpkg.com/linq/> |
142
+ | jsDelivr | <https://jsdelivr.com/package/npm/linq> |
143
+ | packd | <https://bundle.run/linq@latest?name=linq> |
144
+
145
+ # Credits
146
+
147
+ [Yoshifumi Kawai](https://github.com/neuecc) developed the [original version](https://github.com/neuecc/linq.js/) of this library.
148
+
149
+ # License
150
+
151
+ [MIT License](https://github.com/mihaifm/linq/blob/master/LICENSE)