linqx 0.2.1 → 0.3.3

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 (279) hide show
  1. package/README.md +143 -3
  2. package/dist/core/dictionary.d.ts +15 -0
  3. package/dist/core/dictionary.d.ts.map +1 -0
  4. package/dist/core/enumerable.d.ts +10 -0
  5. package/dist/core/enumerable.d.ts.map +1 -0
  6. package/dist/core/enumerator.d.ts +11 -0
  7. package/dist/core/enumerator.d.ts.map +1 -0
  8. package/dist/core/grouping.d.ts +12 -0
  9. package/dist/core/grouping.d.ts.map +1 -0
  10. package/dist/core/lookup.d.ts +13 -0
  11. package/dist/core/lookup.d.ts.map +1 -0
  12. package/dist/core/memoized-enumerable.d.ts +13 -0
  13. package/dist/core/memoized-enumerable.d.ts.map +1 -0
  14. package/dist/core/ordered-enumerable.d.ts +15 -0
  15. package/dist/core/ordered-enumerable.d.ts.map +1 -0
  16. package/dist/core/shared-enumerable.d.ts +11 -0
  17. package/dist/core/shared-enumerable.d.ts.map +1 -0
  18. package/dist/extensions.d.ts +19 -0
  19. package/dist/extensions.d.ts.map +1 -0
  20. package/dist/extensions.js +13 -0
  21. package/dist/factories/choice.d.ts +9 -0
  22. package/dist/factories/choice.d.ts.map +1 -0
  23. package/dist/factories/cycle.d.ts +9 -0
  24. package/dist/factories/cycle.d.ts.map +1 -0
  25. package/dist/factories/defer.d.ts +9 -0
  26. package/dist/factories/defer.d.ts.map +1 -0
  27. package/dist/factories/empty.d.ts +4 -0
  28. package/dist/factories/empty.d.ts.map +1 -0
  29. package/dist/factories/from.d.ts +47 -0
  30. package/dist/factories/from.d.ts.map +1 -0
  31. package/dist/factories/generate.d.ts +10 -0
  32. package/dist/factories/generate.d.ts.map +1 -0
  33. package/dist/factories/make.d.ts +9 -0
  34. package/dist/factories/make.d.ts.map +1 -0
  35. package/dist/factories/matches.d.ts +15 -0
  36. package/dist/factories/matches.d.ts.map +1 -0
  37. package/dist/factories/range-down.d.ts +11 -0
  38. package/dist/factories/range-down.d.ts.map +1 -0
  39. package/dist/factories/range-to.d.ts +13 -0
  40. package/dist/factories/range-to.d.ts.map +1 -0
  41. package/dist/factories/range.d.ts +11 -0
  42. package/dist/factories/range.d.ts.map +1 -0
  43. package/dist/factories/repeat-with-finalize.d.ts +10 -0
  44. package/dist/factories/repeat-with-finalize.d.ts.map +1 -0
  45. package/dist/factories/repeat.d.ts +10 -0
  46. package/dist/factories/repeat.d.ts.map +1 -0
  47. package/dist/factories/to-infinity.d.ts +10 -0
  48. package/dist/factories/to-infinity.d.ts.map +1 -0
  49. package/dist/factories/to-negative-infinity.d.ts +10 -0
  50. package/dist/factories/to-negative-infinity.d.ts.map +1 -0
  51. package/dist/factories/unfold.d.ts +10 -0
  52. package/dist/factories/unfold.d.ts.map +1 -0
  53. package/dist/index.d.ts +88 -3
  54. package/dist/index.d.ts.map +1 -0
  55. package/dist/index.js +2 -4
  56. package/dist/internal/create-enumerable.d.ts +4 -0
  57. package/dist/internal/create-enumerable.d.ts.map +1 -0
  58. package/dist/internal/functions.d.ts +7 -0
  59. package/dist/internal/functions.d.ts.map +1 -0
  60. package/dist/internal/to-iterable.d.ts +3 -0
  61. package/dist/internal/to-iterable.d.ts.map +1 -0
  62. package/dist/operators/aggregate-by.d.ts +3 -0
  63. package/dist/operators/aggregate-by.d.ts.map +1 -0
  64. package/dist/operators/aggregate.d.ts +3 -0
  65. package/dist/operators/aggregate.d.ts.map +1 -0
  66. package/dist/operators/all.d.ts +3 -0
  67. package/dist/operators/all.d.ts.map +1 -0
  68. package/dist/operators/alternate.d.ts +3 -0
  69. package/dist/operators/alternate.d.ts.map +1 -0
  70. package/dist/operators/any.d.ts +3 -0
  71. package/dist/operators/any.d.ts.map +1 -0
  72. package/dist/operators/append.d.ts +3 -0
  73. package/dist/operators/append.d.ts.map +1 -0
  74. package/dist/operators/as-enumerable.d.ts +3 -0
  75. package/dist/operators/as-enumerable.d.ts.map +1 -0
  76. package/dist/operators/average.d.ts +3 -0
  77. package/dist/operators/average.d.ts.map +1 -0
  78. package/dist/operators/buffer.d.ts +3 -0
  79. package/dist/operators/buffer.d.ts.map +1 -0
  80. package/dist/operators/cast.d.ts +3 -0
  81. package/dist/operators/cast.d.ts.map +1 -0
  82. package/dist/operators/catch-error.d.ts +3 -0
  83. package/dist/operators/catch-error.d.ts.map +1 -0
  84. package/dist/operators/choose.d.ts +3 -0
  85. package/dist/operators/choose.d.ts.map +1 -0
  86. package/dist/operators/chunk.d.ts +3 -0
  87. package/dist/operators/chunk.d.ts.map +1 -0
  88. package/dist/operators/concat.d.ts +3 -0
  89. package/dist/operators/concat.d.ts.map +1 -0
  90. package/dist/operators/contains.d.ts +3 -0
  91. package/dist/operators/contains.d.ts.map +1 -0
  92. package/dist/operators/count-by.d.ts +3 -0
  93. package/dist/operators/count-by.d.ts.map +1 -0
  94. package/dist/operators/count.d.ts +3 -0
  95. package/dist/operators/count.d.ts.map +1 -0
  96. package/dist/operators/create-ordered-enumerable.d.ts +3 -0
  97. package/dist/operators/create-ordered-enumerable.d.ts.map +1 -0
  98. package/dist/operators/default-if-empty.d.ts +3 -0
  99. package/dist/operators/default-if-empty.d.ts.map +1 -0
  100. package/dist/operators/distinct-by.d.ts +3 -0
  101. package/dist/operators/distinct-by.d.ts.map +1 -0
  102. package/dist/operators/distinct-until-changed.d.ts +3 -0
  103. package/dist/operators/distinct-until-changed.d.ts.map +1 -0
  104. package/dist/operators/distinct.d.ts +3 -0
  105. package/dist/operators/distinct.d.ts.map +1 -0
  106. package/dist/operators/do-action.d.ts +4 -0
  107. package/dist/operators/do-action.d.ts.map +1 -0
  108. package/dist/operators/element-at-or-default.d.ts +3 -0
  109. package/dist/operators/element-at-or-default.d.ts.map +1 -0
  110. package/dist/operators/element-at.d.ts +3 -0
  111. package/dist/operators/element-at.d.ts.map +1 -0
  112. package/dist/operators/except-by.d.ts +3 -0
  113. package/dist/operators/except-by.d.ts.map +1 -0
  114. package/dist/operators/except.d.ts +3 -0
  115. package/dist/operators/except.d.ts.map +1 -0
  116. package/dist/operators/finally-action.d.ts +3 -0
  117. package/dist/operators/finally-action.d.ts.map +1 -0
  118. package/dist/operators/first-or-default.d.ts +3 -0
  119. package/dist/operators/first-or-default.d.ts.map +1 -0
  120. package/dist/operators/first.d.ts +3 -0
  121. package/dist/operators/first.d.ts.map +1 -0
  122. package/dist/operators/flatten.d.ts +3 -0
  123. package/dist/operators/flatten.d.ts.map +1 -0
  124. package/dist/operators/for-each.d.ts +4 -0
  125. package/dist/operators/for-each.d.ts.map +1 -0
  126. package/dist/operators/force.d.ts +3 -0
  127. package/dist/operators/force.d.ts.map +1 -0
  128. package/dist/operators/group-by.d.ts +3 -0
  129. package/dist/operators/group-by.d.ts.map +1 -0
  130. package/dist/operators/group-join.d.ts +3 -0
  131. package/dist/operators/group-join.d.ts.map +1 -0
  132. package/dist/operators/index-of.d.ts +3 -0
  133. package/dist/operators/index-of.d.ts.map +1 -0
  134. package/dist/operators/index.d.ts +3 -0
  135. package/dist/operators/index.d.ts.map +1 -0
  136. package/dist/operators/insert.d.ts +3 -0
  137. package/dist/operators/insert.d.ts.map +1 -0
  138. package/dist/operators/intersect-by.d.ts +3 -0
  139. package/dist/operators/intersect-by.d.ts.map +1 -0
  140. package/dist/operators/intersect.d.ts +3 -0
  141. package/dist/operators/intersect.d.ts.map +1 -0
  142. package/dist/operators/is-empty.d.ts +3 -0
  143. package/dist/operators/is-empty.d.ts.map +1 -0
  144. package/dist/operators/join-with.d.ts +3 -0
  145. package/dist/operators/join-with.d.ts.map +1 -0
  146. package/dist/operators/join.d.ts +3 -0
  147. package/dist/operators/join.d.ts.map +1 -0
  148. package/dist/operators/last-index-of.d.ts +3 -0
  149. package/dist/operators/last-index-of.d.ts.map +1 -0
  150. package/dist/operators/last-or-default.d.ts +3 -0
  151. package/dist/operators/last-or-default.d.ts.map +1 -0
  152. package/dist/operators/last.d.ts +3 -0
  153. package/dist/operators/last.d.ts.map +1 -0
  154. package/dist/operators/left-join.d.ts +3 -0
  155. package/dist/operators/left-join.d.ts.map +1 -0
  156. package/dist/operators/let-bind.d.ts +3 -0
  157. package/dist/operators/let-bind.d.ts.map +1 -0
  158. package/dist/operators/log.d.ts +3 -0
  159. package/dist/operators/log.d.ts.map +1 -0
  160. package/dist/operators/map.d.ts +3 -0
  161. package/dist/operators/map.d.ts.map +1 -0
  162. package/dist/operators/max-by.d.ts +3 -0
  163. package/dist/operators/max-by.d.ts.map +1 -0
  164. package/dist/operators/max.d.ts +3 -0
  165. package/dist/operators/max.d.ts.map +1 -0
  166. package/dist/operators/memoize.d.ts +3 -0
  167. package/dist/operators/memoize.d.ts.map +1 -0
  168. package/dist/operators/merge.d.ts +3 -0
  169. package/dist/operators/merge.d.ts.map +1 -0
  170. package/dist/operators/min-by.d.ts +3 -0
  171. package/dist/operators/min-by.d.ts.map +1 -0
  172. package/dist/operators/min.d.ts +3 -0
  173. package/dist/operators/min.d.ts.map +1 -0
  174. package/dist/operators/of-type.d.ts +3 -0
  175. package/dist/operators/of-type.d.ts.map +1 -0
  176. package/dist/operators/operators.d.ts +209 -0
  177. package/dist/operators/operators.d.ts.map +1 -0
  178. package/dist/operators/order-by-descending.d.ts +3 -0
  179. package/dist/operators/order-by-descending.d.ts.map +1 -0
  180. package/dist/operators/order-by.d.ts +3 -0
  181. package/dist/operators/order-by.d.ts.map +1 -0
  182. package/dist/operators/page.d.ts +3 -0
  183. package/dist/operators/page.d.ts.map +1 -0
  184. package/dist/operators/pairwise.d.ts +3 -0
  185. package/dist/operators/pairwise.d.ts.map +1 -0
  186. package/dist/operators/partition-by.d.ts +3 -0
  187. package/dist/operators/partition-by.d.ts.map +1 -0
  188. package/dist/operators/position.d.ts +3 -0
  189. package/dist/operators/position.d.ts.map +1 -0
  190. package/dist/operators/prepend.d.ts +3 -0
  191. package/dist/operators/prepend.d.ts.map +1 -0
  192. package/dist/operators/reverse.d.ts +3 -0
  193. package/dist/operators/reverse.d.ts.map +1 -0
  194. package/dist/operators/right-join.d.ts +3 -0
  195. package/dist/operators/right-join.d.ts.map +1 -0
  196. package/dist/operators/scan.d.ts +3 -0
  197. package/dist/operators/scan.d.ts.map +1 -0
  198. package/dist/operators/select-many.d.ts +3 -0
  199. package/dist/operators/select-many.d.ts.map +1 -0
  200. package/dist/operators/select.d.ts +3 -0
  201. package/dist/operators/select.d.ts.map +1 -0
  202. package/dist/operators/sequence-equal.d.ts +3 -0
  203. package/dist/operators/sequence-equal.d.ts.map +1 -0
  204. package/dist/operators/share.d.ts +3 -0
  205. package/dist/operators/share.d.ts.map +1 -0
  206. package/dist/operators/shuffle.d.ts +3 -0
  207. package/dist/operators/shuffle.d.ts.map +1 -0
  208. package/dist/operators/single-or-default.d.ts +3 -0
  209. package/dist/operators/single-or-default.d.ts.map +1 -0
  210. package/dist/operators/single.d.ts +3 -0
  211. package/dist/operators/single.d.ts.map +1 -0
  212. package/dist/operators/skip-last.d.ts +3 -0
  213. package/dist/operators/skip-last.d.ts.map +1 -0
  214. package/dist/operators/skip-while.d.ts +3 -0
  215. package/dist/operators/skip-while.d.ts.map +1 -0
  216. package/dist/operators/skip.d.ts +3 -0
  217. package/dist/operators/skip.d.ts.map +1 -0
  218. package/dist/operators/sum.d.ts +3 -0
  219. package/dist/operators/sum.d.ts.map +1 -0
  220. package/dist/operators/take-except-last.d.ts +3 -0
  221. package/dist/operators/take-except-last.d.ts.map +1 -0
  222. package/dist/operators/take-from-last.d.ts +3 -0
  223. package/dist/operators/take-from-last.d.ts.map +1 -0
  224. package/dist/operators/take-last.d.ts +3 -0
  225. package/dist/operators/take-last.d.ts.map +1 -0
  226. package/dist/operators/take-while.d.ts +3 -0
  227. package/dist/operators/take-while.d.ts.map +1 -0
  228. package/dist/operators/take.d.ts +3 -0
  229. package/dist/operators/take.d.ts.map +1 -0
  230. package/dist/operators/then-by-descending.d.ts +3 -0
  231. package/dist/operators/then-by-descending.d.ts.map +1 -0
  232. package/dist/operators/then-by.d.ts +3 -0
  233. package/dist/operators/then-by.d.ts.map +1 -0
  234. package/dist/operators/to-array.d.ts +3 -0
  235. package/dist/operators/to-array.d.ts.map +1 -0
  236. package/dist/operators/to-dictionary.d.ts +3 -0
  237. package/dist/operators/to-dictionary.d.ts.map +1 -0
  238. package/dist/operators/to-joined-string.d.ts +3 -0
  239. package/dist/operators/to-joined-string.d.ts.map +1 -0
  240. package/dist/operators/to-json-string.d.ts +3 -0
  241. package/dist/operators/to-json-string.d.ts.map +1 -0
  242. package/dist/operators/to-lookup.d.ts +3 -0
  243. package/dist/operators/to-lookup.d.ts.map +1 -0
  244. package/dist/operators/to-map.d.ts +3 -0
  245. package/dist/operators/to-map.d.ts.map +1 -0
  246. package/dist/operators/to-object.d.ts +3 -0
  247. package/dist/operators/to-object.d.ts.map +1 -0
  248. package/dist/operators/to-set.d.ts +3 -0
  249. package/dist/operators/to-set.d.ts.map +1 -0
  250. package/dist/operators/trace.d.ts +3 -0
  251. package/dist/operators/trace.d.ts.map +1 -0
  252. package/dist/operators/traverse-breadth-first.d.ts +3 -0
  253. package/dist/operators/traverse-breadth-first.d.ts.map +1 -0
  254. package/dist/operators/traverse-depth-first.d.ts +3 -0
  255. package/dist/operators/traverse-depth-first.d.ts.map +1 -0
  256. package/dist/operators/union-by.d.ts +3 -0
  257. package/dist/operators/union-by.d.ts.map +1 -0
  258. package/dist/operators/union.d.ts +3 -0
  259. package/dist/operators/union.d.ts.map +1 -0
  260. package/dist/operators/weighted-sample.d.ts +3 -0
  261. package/dist/operators/weighted-sample.d.ts.map +1 -0
  262. package/dist/operators/where-if.d.ts +3 -0
  263. package/dist/operators/where-if.d.ts.map +1 -0
  264. package/dist/operators/where.d.ts +3 -0
  265. package/dist/operators/where.d.ts.map +1 -0
  266. package/dist/operators/with-neighbors.d.ts +3 -0
  267. package/dist/operators/with-neighbors.d.ts.map +1 -0
  268. package/dist/operators/zip.d.ts +3 -0
  269. package/dist/operators/zip.d.ts.map +1 -0
  270. package/dist/src-D_Mk3oMP.js +1597 -0
  271. package/dist/types.d.ts +1155 -0
  272. package/dist/types.d.ts.map +1 -0
  273. package/dist/utils.d.ts +57 -0
  274. package/dist/utils.d.ts.map +1 -0
  275. package/package.json +21 -11
  276. package/dist/linq.d.ts +0 -256
  277. package/dist/linq.js +0 -3085
  278. package/dist/linqx.d.ts +0 -36
  279. package/dist/linqx.js +0 -153
package/dist/linqx.d.ts DELETED
@@ -1,36 +0,0 @@
1
- declare module './linq.js' {
2
- type IEnumerable<T> = Enumerable.IEnumerable<T>;
3
- namespace Enumerable {
4
- interface IPageInfo {
5
- pageNumber: number;
6
- pageSize: number;
7
- }
8
- interface IndexedItem<T> {
9
- index: number;
10
- item: T;
11
- }
12
- interface PositionedItem<T> extends IndexedItem<T> {
13
- isFirst: boolean;
14
- isLast: boolean;
15
- }
16
- interface ItemWithNeighbors<T> {
17
- prev: T | null;
18
- item: T;
19
- next: T | null;
20
- }
21
- const prototype: any;
22
- interface IEnumerable<T> {
23
- whereIf(flag: boolean | string | undefined | null, filter: (t: T) => boolean): IEnumerable<T>;
24
- page(pageNumber: number, pageSize: number): IEnumerable<T>;
25
- page(info: IPageInfo): IEnumerable<T>;
26
- joinWith(separator: string): string;
27
- joinWith<T>(this: IEnumerable<T>, separator: (t: T) => T): IEnumerable<T>;
28
- toMap<K, V>(keySelector: (element: T) => K, valueSelector: (element: T) => V): Map<K, V>;
29
- chunk(size: number): IEnumerable<T[]>;
30
- index(): IEnumerable<IndexedItem<T>>;
31
- position(): IEnumerable<PositionedItem<T>>;
32
- withNeighbors(): IEnumerable<ItemWithNeighbors<T>>;
33
- }
34
- }
35
- }
36
- export {};
package/dist/linqx.js DELETED
@@ -1,153 +0,0 @@
1
- import { Enumerable } from "./linq.js";
2
- Enumerable.prototype.whereIf = function (flag, filter) {
3
- return flag ? this.where(filter) : this;
4
- };
5
- function page(...args) {
6
- let number = 0;
7
- let size = 0;
8
- if (args.length === 1) {
9
- const info = args[0];
10
- number = info.pageNumber;
11
- size = info.pageSize;
12
- }
13
- else {
14
- number = args[0];
15
- size = args[1];
16
- }
17
- return this.skip((number - 1) * size).take(size);
18
- }
19
- Enumerable.prototype.page = page;
20
- Enumerable.prototype.map = function (selector) {
21
- return this.select(selector).toArray();
22
- };
23
- function joinWith(separator) {
24
- if (typeof separator === 'string') {
25
- return this.toArray().join(separator);
26
- }
27
- return Enumerable.from(joinWithIterator(this, separator));
28
- function* joinWithIterator(enumerable, sep) {
29
- for (const { index, item, isFirst, isLast } of enumerable.position()) {
30
- yield item;
31
- if (!isLast) {
32
- yield sep(item);
33
- }
34
- }
35
- }
36
- }
37
- Enumerable.prototype.joinWith = joinWith;
38
- Enumerable.prototype.toMap = function (keySelector, valueSelector) {
39
- const map = new Map();
40
- for (const m of this) {
41
- const k = keySelector(m);
42
- const v = valueSelector(m);
43
- map.set(k, v);
44
- }
45
- return map;
46
- };
47
- function* chunkIterator(enumerable, size) {
48
- const e = enumerable.getEnumerator();
49
- // Before allocating anything, make sure there's at least one element.
50
- if (e.moveNext()) {
51
- // Now that we know we have at least one item, allocate an initial storage array. This is not
52
- // the array we'll yield. It starts out small in order to avoid significantly overallocating
53
- // when the source has many fewer elements than the chunk size.
54
- let arraySize = Math.min(size, 4);
55
- let i;
56
- do {
57
- const array = new Array(arraySize);
58
- // Store the first item.
59
- array[0] = e.current();
60
- i = 1;
61
- if (size != array.length) {
62
- // This is the first chunk. As we fill the array, grow it as needed.
63
- for (; i < size && e.moveNext(); i++) {
64
- if (i >= array.length) {
65
- arraySize = Math.min(size, 2 * array.length);
66
- resize(array, arraySize);
67
- }
68
- array[i] = e.current();
69
- }
70
- }
71
- else {
72
- // For all but the first chunk, the array will already be correctly sized.
73
- // We can just store into it until either it's full or MoveNext returns false.
74
- const local = array; // avoid bounds checks by using cached local (`array` is lifted to iterator object as a field)
75
- for (; i < local.length && e.moveNext(); i++) {
76
- local[i] = e.current();
77
- }
78
- }
79
- if (i != array.length) {
80
- resize(array, i);
81
- }
82
- yield array;
83
- } while (i >= size && e.moveNext());
84
- }
85
- }
86
- Enumerable.prototype.chunk = function (size) {
87
- if (size < 1)
88
- throw new Error('size cannot be less than 1');
89
- const e = chunkIterator(this, size);
90
- return Enumerable.from(e);
91
- };
92
- function* positionIterator(enumerable) {
93
- const e = enumerable.getEnumerator();
94
- if (!e.moveNext()) {
95
- return;
96
- }
97
- let i = 0;
98
- let current = e.current();
99
- while (e.moveNext()) {
100
- yield {
101
- index: i,
102
- item: current,
103
- isFirst: i === 0,
104
- isLast: false
105
- };
106
- current = e.current();
107
- ++i;
108
- }
109
- yield {
110
- index: i,
111
- item: current,
112
- isFirst: i === 0,
113
- isLast: true
114
- };
115
- }
116
- Enumerable.prototype.position = function () {
117
- const e = positionIterator(this);
118
- return Enumerable.from(e);
119
- };
120
- Enumerable.prototype.index = function () {
121
- const e = positionIterator(this);
122
- return this.select((m, i) => ({ index: i, item: m }));
123
- };
124
- function* withNeighborsIterator(enumerable) {
125
- const e = enumerable.getEnumerator();
126
- if (!e.moveNext()) {
127
- return;
128
- }
129
- let previous = null;
130
- let current = e.current();
131
- while (e.moveNext()) {
132
- const next = e.current();
133
- yield { prev: previous, item: current, next: next };
134
- previous = current;
135
- current = next;
136
- }
137
- yield { prev: previous, item: current, next: null };
138
- }
139
- Enumerable.prototype.withNeighbors = function () {
140
- const e = withNeighborsIterator(this);
141
- return Enumerable.from(e);
142
- };
143
- function resize(array, newSize) {
144
- const oldSize = array.length;
145
- if (newSize > oldSize) {
146
- array.length = newSize;
147
- array.fill(undefined, oldSize, newSize);
148
- }
149
- else if (newSize < oldSize) {
150
- array.length = newSize;
151
- }
152
- }
153
- ;