-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
48 lines (44 loc) · 924 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import * as functions from './src/index.js';
import { Enumerable } from './src/Enumerable.js';
const valueFunctions = [
'aggregate',
'aggregateBy',
'all',
'any',
'average',
'contains',
'count',
'countBy',
'elementAt',
'elementAtOrDefault',
'first',
'firstOrDefault',
'last',
'lastOrDefault',
'longCount',
'max',
'maxBy',
'min',
'minBy',
'sequenceEqual',
'single',
'singleOrDefault',
'sum',
'toArray',
'toDictionary',
'toHashSet',
'toList',
'toLookup',
];
for (const name of valueFunctions) {
Enumerable.prototype[name] = function (...args) {
return functions[name](this.sequence, ...args);
};
}
for (const [name, fn] of Object.entries(functions)) {
if (!Enumerable[name] && !Enumerable.prototype[name])
Enumerable.prototype[name] = function (...args) {
return new Enumerable(fn(this.sequence, ...args));
};
}
export { Enumerable as jinq };