@cspell/cspell-pipe 6.26.3 → 6.28.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 (179) hide show
  1. package/dist/cjs/helpers/distribute.js +37 -0
  2. package/dist/cjs/helpers/index.js +17 -0
  3. package/dist/cjs/helpers/interleave.js +22 -0
  4. package/dist/cjs/helpers/iteratorToIterable.js +18 -0
  5. package/dist/cjs/helpers/toArray.js +21 -0
  6. package/dist/cjs/helpers/toAsyncIterable.js +19 -0
  7. package/dist/cjs/helpers/util.js +15 -0
  8. package/dist/cjs/index.js +60 -0
  9. package/dist/cjs/internalTypes.js +3 -0
  10. package/dist/cjs/operators/{append.cjs → append.js} +8 -10
  11. package/dist/cjs/operators/await.js +13 -0
  12. package/dist/cjs/operators/{combine.cjs → combine.js} +5 -4
  13. package/dist/cjs/operators/{concatMap.cjs → concatMap.js} +8 -16
  14. package/dist/cjs/operators/{filter.cjs → filter.js} +8 -10
  15. package/dist/cjs/operators/{first.cjs → first.js} +8 -10
  16. package/dist/cjs/operators/{flatten.cjs → flatten.js} +8 -16
  17. package/dist/cjs/operators/index.js +60 -0
  18. package/dist/cjs/operators/joinStrings.js +28 -0
  19. package/dist/cjs/operators/{last.cjs → last.js} +8 -10
  20. package/dist/cjs/operators/{map.cjs → map.js} +8 -16
  21. package/dist/cjs/operators/{reduce.cjs → reduce.js} +9 -20
  22. package/dist/cjs/operators/{skip.cjs → skip.js} +8 -16
  23. package/dist/cjs/operators/{take.cjs → take.js} +8 -16
  24. package/dist/cjs/operators/{tap.cjs → tap.js} +8 -16
  25. package/dist/cjs/operators/types.js +3 -0
  26. package/dist/cjs/operators/{unique.cjs → unique.js} +8 -16
  27. package/dist/cjs/pipe.js +15 -0
  28. package/dist/cjs/reduce.js +27 -0
  29. package/dist/cjs/sync/index.js +26 -0
  30. package/dist/{cjs/operators/helpers/distribute.d.ts → esm/helpers/distribute.d.mts} +1 -1
  31. package/dist/esm/helpers/distribute.js +0 -1
  32. package/dist/esm/helpers/distribute.mjs +32 -0
  33. package/dist/esm/helpers/index.d.mts +7 -0
  34. package/dist/esm/helpers/index.js +0 -1
  35. package/dist/esm/helpers/index.mjs +6 -0
  36. package/dist/{cjs/operators/helpers/interleave.d.ts → esm/helpers/interleave.d.mts} +1 -1
  37. package/dist/esm/helpers/interleave.js +0 -1
  38. package/dist/esm/helpers/interleave.mjs +17 -0
  39. package/dist/{cjs/operators/helpers/iteratorToIterable.d.ts → esm/helpers/iteratorToIterable.d.mts} +1 -1
  40. package/dist/esm/helpers/iteratorToIterable.js +0 -1
  41. package/dist/esm/helpers/iteratorToIterable.mjs +12 -0
  42. package/dist/{cjs/operators/helpers/toArray.d.ts → esm/helpers/toArray.d.mts} +1 -1
  43. package/dist/esm/helpers/toArray.js +0 -1
  44. package/dist/esm/helpers/toArray.mjs +14 -0
  45. package/dist/{cjs/sync/helpers/toAsyncIterable.d.ts → esm/helpers/toAsyncIterable.d.mts} +2 -2
  46. package/dist/esm/helpers/toAsyncIterable.js +0 -1
  47. package/dist/esm/helpers/toAsyncIterable.mjs +14 -0
  48. package/dist/{cjs/operators/helpers/util.d.ts → esm/helpers/util.d.mts} +2 -2
  49. package/dist/esm/helpers/util.js +0 -1
  50. package/dist/esm/helpers/util.mjs +9 -0
  51. package/dist/esm/index.d.mts +9 -0
  52. package/dist/esm/index.js +0 -1
  53. package/dist/esm/index.mjs +10 -0
  54. package/dist/{cjs/operators/internalTypes.d.ts → esm/internalTypes.d.mts} +1 -1
  55. package/dist/esm/internalTypes.js +0 -1
  56. package/dist/esm/internalTypes.mjs +1 -0
  57. package/dist/{cjs/sync/operators/append.d.ts → esm/operators/append.d.mts} +2 -2
  58. package/dist/esm/operators/append.js +0 -1
  59. package/dist/esm/operators/append.mjs +35 -0
  60. package/dist/{cjs/operators/operators/await.d.ts → esm/operators/await.d.mts} +1 -1
  61. package/dist/esm/operators/await.js +0 -1
  62. package/dist/{cjs/operators/await.cjs → esm/operators/await.mjs} +1 -5
  63. package/dist/{cjs/operators/operators/combine.d.ts → esm/operators/combine.d.mts} +3 -3
  64. package/dist/esm/operators/combine.js +0 -1
  65. package/dist/esm/operators/combine.mjs +18 -0
  66. package/dist/{cjs/operators/operators/concatMap.d.ts → esm/operators/concatMap.d.mts} +1 -1
  67. package/dist/esm/operators/concatMap.js +0 -1
  68. package/dist/esm/operators/concatMap.mjs +18 -0
  69. package/dist/{cjs/operators/operators/filter.d.ts → esm/operators/filter.d.mts} +2 -2
  70. package/dist/esm/operators/filter.js +0 -1
  71. package/dist/esm/operators/filter.mjs +29 -0
  72. package/dist/{cjs/operators/operators/first.d.ts → esm/operators/first.d.mts} +2 -2
  73. package/dist/esm/operators/first.js +0 -1
  74. package/dist/esm/operators/first.mjs +33 -0
  75. package/dist/{cjs/operators/operators/flatten.d.ts → esm/operators/flatten.d.mts} +1 -1
  76. package/dist/esm/operators/flatten.js +0 -1
  77. package/dist/esm/operators/flatten.mjs +18 -0
  78. package/dist/esm/operators/index.d.mts +17 -0
  79. package/dist/esm/operators/index.js +0 -1
  80. package/dist/esm/operators/index.mjs +15 -0
  81. package/dist/{cjs/operators/operators/joinStrings.d.ts → esm/operators/joinStrings.d.mts} +1 -1
  82. package/dist/esm/operators/joinStrings.js +0 -1
  83. package/dist/esm/operators/joinStrings.mjs +21 -0
  84. package/dist/{cjs/operators/operators/last.d.ts → esm/operators/last.d.mts} +2 -2
  85. package/dist/esm/operators/last.js +0 -1
  86. package/dist/esm/operators/last.mjs +38 -0
  87. package/dist/{cjs/operators/operators/map.d.ts → esm/operators/map.d.mts} +1 -1
  88. package/dist/esm/operators/map.js +0 -1
  89. package/dist/esm/operators/map.mjs +18 -0
  90. package/dist/{cjs/operators/operators/reduce.d.ts → esm/operators/reduce.d.mts} +1 -1
  91. package/dist/esm/operators/reduce.js +0 -1
  92. package/dist/esm/operators/reduce.mjs +48 -0
  93. package/dist/{cjs/operators/operators/skip.d.ts → esm/operators/skip.d.mts} +1 -1
  94. package/dist/esm/operators/skip.js +0 -1
  95. package/dist/esm/operators/skip.mjs +26 -0
  96. package/dist/{operators/take.d.ts → esm/operators/take.d.mts} +1 -1
  97. package/dist/esm/operators/take.js +0 -1
  98. package/dist/esm/operators/take.mjs +30 -0
  99. package/dist/{cjs/sync/operators/tap.d.ts → esm/operators/tap.d.mts} +1 -1
  100. package/dist/esm/operators/tap.js +0 -1
  101. package/dist/esm/operators/tap.mjs +35 -0
  102. package/dist/{cjs/operators/operators/types.d.ts → esm/operators/types.d.mts} +1 -1
  103. package/dist/esm/operators/types.js +0 -1
  104. package/dist/esm/operators/types.mjs +1 -0
  105. package/dist/{operators/unique.d.ts → esm/operators/unique.d.mts} +1 -1
  106. package/dist/esm/operators/unique.js +0 -1
  107. package/dist/esm/operators/unique.mjs +52 -0
  108. package/dist/{cjs/operators/pipe.d.ts → esm/pipe.d.mts} +2 -2
  109. package/dist/esm/pipe.js +0 -1
  110. package/dist/esm/pipe.mjs +9 -0
  111. package/dist/{cjs/sync/reduce.d.ts → esm/reduce.d.mts} +2 -2
  112. package/dist/esm/reduce.js +0 -1
  113. package/dist/esm/reduce.mjs +20 -0
  114. package/dist/{cjs/operators/sync/index.d.ts → esm/sync/index.d.mts} +6 -6
  115. package/dist/esm/sync/index.js +0 -1
  116. package/dist/{cjs/sync/sync/index.d.ts → esm/sync/index.mjs} +4 -6
  117. package/package.json +42 -61
  118. package/dist/cjs/index.cjs +0 -644
  119. package/dist/cjs/operators/helpers/index.d.ts +0 -7
  120. package/dist/cjs/operators/helpers/toAsyncIterable.d.ts +0 -11
  121. package/dist/cjs/operators/index.cjs +0 -508
  122. package/dist/cjs/operators/joinStrings.cjs +0 -49
  123. package/dist/cjs/operators/operators/append.d.ts +0 -15
  124. package/dist/cjs/operators/operators/index.d.ts +0 -17
  125. package/dist/cjs/operators/operators/take.d.ts +0 -8
  126. package/dist/cjs/operators/operators/tap.d.ts +0 -19
  127. package/dist/cjs/operators/operators/unique.d.ts +0 -4
  128. package/dist/cjs/operators/types.cjs +0 -2
  129. package/dist/cjs/sync/helpers/distribute.d.ts +0 -13
  130. package/dist/cjs/sync/helpers/index.d.ts +0 -7
  131. package/dist/cjs/sync/helpers/interleave.d.ts +0 -2
  132. package/dist/cjs/sync/helpers/iteratorToIterable.d.ts +0 -3
  133. package/dist/cjs/sync/helpers/toArray.d.ts +0 -6
  134. package/dist/cjs/sync/helpers/util.d.ts +0 -4
  135. package/dist/cjs/sync/index.cjs +0 -245
  136. package/dist/cjs/sync/internalTypes.d.ts +0 -17
  137. package/dist/cjs/sync/operators/await.d.ts +0 -2
  138. package/dist/cjs/sync/operators/combine.d.ts +0 -23
  139. package/dist/cjs/sync/operators/concatMap.d.ts +0 -4
  140. package/dist/cjs/sync/operators/filter.d.ts +0 -10
  141. package/dist/cjs/sync/operators/first.d.ts +0 -10
  142. package/dist/cjs/sync/operators/flatten.d.ts +0 -4
  143. package/dist/cjs/sync/operators/index.d.ts +0 -17
  144. package/dist/cjs/sync/operators/joinStrings.d.ts +0 -4
  145. package/dist/cjs/sync/operators/last.d.ts +0 -10
  146. package/dist/cjs/sync/operators/map.d.ts +0 -4
  147. package/dist/cjs/sync/operators/reduce.d.ts +0 -7
  148. package/dist/cjs/sync/operators/skip.d.ts +0 -4
  149. package/dist/cjs/sync/operators/take.d.ts +0 -8
  150. package/dist/cjs/sync/operators/types.d.ts +0 -4
  151. package/dist/cjs/sync/operators/unique.d.ts +0 -4
  152. package/dist/cjs/sync/pipe.d.ts +0 -20
  153. package/dist/helpers/distribute.d.ts +0 -13
  154. package/dist/helpers/index.d.ts +0 -7
  155. package/dist/helpers/interleave.d.ts +0 -2
  156. package/dist/helpers/iteratorToIterable.d.ts +0 -3
  157. package/dist/helpers/toArray.d.ts +0 -6
  158. package/dist/helpers/toAsyncIterable.d.ts +0 -11
  159. package/dist/helpers/util.d.ts +0 -4
  160. package/dist/index.d.ts +0 -9
  161. package/dist/internalTypes.d.ts +0 -17
  162. package/dist/operators/append.d.ts +0 -15
  163. package/dist/operators/await.d.ts +0 -2
  164. package/dist/operators/combine.d.ts +0 -23
  165. package/dist/operators/concatMap.d.ts +0 -4
  166. package/dist/operators/filter.d.ts +0 -10
  167. package/dist/operators/first.d.ts +0 -10
  168. package/dist/operators/flatten.d.ts +0 -4
  169. package/dist/operators/index.d.ts +0 -17
  170. package/dist/operators/joinStrings.d.ts +0 -4
  171. package/dist/operators/last.d.ts +0 -10
  172. package/dist/operators/map.d.ts +0 -4
  173. package/dist/operators/reduce.d.ts +0 -7
  174. package/dist/operators/skip.d.ts +0 -4
  175. package/dist/operators/tap.d.ts +0 -19
  176. package/dist/operators/types.d.ts +0 -4
  177. package/dist/pipe.d.ts +0 -20
  178. package/dist/reduce.d.ts +0 -16
  179. package/dist/sync/index.d.ts +0 -6
@@ -1,18 +1,7 @@
1
- 'use strict';
2
-
3
- function* iteratorToIterable(iterator) {
4
- let n;
5
- while (!(n = iterator.next()).done) {
6
- yield n.value;
7
- }
8
- }
9
- async function* asyncIteratorToAsyncIterable(iterator) {
10
- let n;
11
- while (!(n = await iterator.next()).done) {
12
- yield n.value;
13
- }
14
- }
15
-
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.opReduceSync = exports.opReduceAsync = void 0;
4
+ const index_js_1 = require("../helpers/index.js");
16
5
  function opReduceAsync(reduceFn, initialValue) {
17
6
  async function* reduce(head, tail) {
18
7
  for await (const v of tail) {
@@ -28,6 +17,7 @@ function opReduceAsync(reduceFn, initialValue) {
28
17
  }
29
18
  return fn;
30
19
  }
20
+ exports.opReduceAsync = opReduceAsync;
31
21
  function opReduceSync(reduceFn, initialValue) {
32
22
  function* reduce(head, tail) {
33
23
  for (const v of tail) {
@@ -43,23 +33,22 @@ function opReduceSync(reduceFn, initialValue) {
43
33
  }
44
34
  return fn;
45
35
  }
36
+ exports.opReduceSync = opReduceSync;
46
37
  function headTail(iter) {
47
38
  const iterator = iter[Symbol.iterator]();
48
39
  const first = iterator.next();
49
40
  if (first.done)
50
41
  return undefined;
51
- return { head: first.value, tail: iteratorToIterable(iterator) };
42
+ return { head: first.value, tail: (0, index_js_1.iteratorToIterable)(iterator) };
52
43
  }
53
44
  async function headTailAsync(iter) {
54
45
  const iterator = isIterable(iter) ? iter[Symbol.iterator]() : iter[Symbol.asyncIterator]();
55
46
  const first = await iterator.next();
56
47
  if (first.done)
57
48
  return undefined;
58
- return { head: first.value, tail: asyncIteratorToAsyncIterable(iterator) };
49
+ return { head: first.value, tail: (0, index_js_1.asyncIteratorToAsyncIterable)(iterator) };
59
50
  }
60
51
  function isIterable(i) {
61
52
  return typeof i[Symbol.iterator] === 'function';
62
53
  }
63
-
64
- exports.opReduceAsync = opReduceAsync;
65
- exports.opReduceSync = opReduceSync;
54
+ //# sourceMappingURL=reduce.js.map
@@ -1,15 +1,7 @@
1
- 'use strict';
2
-
3
- function toPipeFn(syncFn, asyncFn) {
4
- function _(i) {
5
- return isAsyncIterable(i) ? asyncFn(i) : syncFn(i);
6
- }
7
- return _;
8
- }
9
- function isAsyncIterable(i) {
10
- return typeof i[Symbol.asyncIterator] === 'function';
11
- }
12
-
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.opSkip = exports.opSkipSync = exports.opSkipAsync = void 0;
4
+ const util_js_1 = require("../helpers/util.js");
13
5
  function opSkipAsync(count) {
14
6
  async function* fn(iter) {
15
7
  for await (const v of iter) {
@@ -22,6 +14,7 @@ function opSkipAsync(count) {
22
14
  }
23
15
  return fn;
24
16
  }
17
+ exports.opSkipAsync = opSkipAsync;
25
18
  function opSkipSync(count) {
26
19
  function* fn(iter) {
27
20
  for (const v of iter) {
@@ -34,8 +27,7 @@ function opSkipSync(count) {
34
27
  }
35
28
  return fn;
36
29
  }
37
- const opSkip = (count) => toPipeFn(opSkipSync(count), opSkipAsync(count));
38
-
39
- exports.opSkip = opSkip;
40
- exports.opSkipAsync = opSkipAsync;
41
30
  exports.opSkipSync = opSkipSync;
31
+ const opSkip = (count) => (0, util_js_1.toPipeFn)(opSkipSync(count), opSkipAsync(count));
32
+ exports.opSkip = opSkip;
33
+ //# sourceMappingURL=skip.js.map
@@ -1,15 +1,7 @@
1
- 'use strict';
2
-
3
- function toPipeFn(syncFn, asyncFn) {
4
- function _(i) {
5
- return isAsyncIterable(i) ? asyncFn(i) : syncFn(i);
6
- }
7
- return _;
8
- }
9
- function isAsyncIterable(i) {
10
- return typeof i[Symbol.asyncIterator] === 'function';
11
- }
12
-
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.opTake = exports.opTakeSync = exports.opTakeAsync = void 0;
4
+ const util_js_1 = require("../helpers/util.js");
13
5
  function opTakeAsync(count) {
14
6
  async function* fn(iter) {
15
7
  if (count <= 0)
@@ -22,6 +14,7 @@ function opTakeAsync(count) {
22
14
  }
23
15
  return fn;
24
16
  }
17
+ exports.opTakeAsync = opTakeAsync;
25
18
  function opTakeSync(count) {
26
19
  function* fn(iter) {
27
20
  if (count <= 0)
@@ -34,12 +27,11 @@ function opTakeSync(count) {
34
27
  }
35
28
  return fn;
36
29
  }
30
+ exports.opTakeSync = opTakeSync;
37
31
  /**
38
32
  * Consume only the first `count` number from the iterable.
39
33
  * @param count - number to take
40
34
  */
41
- const opTake = (count) => toPipeFn(opTakeSync(count), opTakeAsync(count));
42
-
35
+ const opTake = (count) => (0, util_js_1.toPipeFn)(opTakeSync(count), opTakeAsync(count));
43
36
  exports.opTake = opTake;
44
- exports.opTakeAsync = opTakeAsync;
45
- exports.opTakeSync = opTakeSync;
37
+ //# sourceMappingURL=take.js.map
@@ -1,15 +1,7 @@
1
- 'use strict';
2
-
3
- function toPipeFn(syncFn, asyncFn) {
4
- function _(i) {
5
- return isAsyncIterable(i) ? asyncFn(i) : syncFn(i);
6
- }
7
- return _;
8
- }
9
- function isAsyncIterable(i) {
10
- return typeof i[Symbol.asyncIterator] === 'function';
11
- }
12
-
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.opTap = exports.opTapSync = exports.opTapAsync = void 0;
4
+ const util_js_1 = require("../helpers/util.js");
13
5
  /**
14
6
  * Tap allows you to listen on values, without modifying them.
15
7
  *
@@ -24,6 +16,7 @@ function opTapAsync(tapFn) {
24
16
  }
25
17
  return fn;
26
18
  }
19
+ exports.opTapAsync = opTapAsync;
27
20
  /**
28
21
  * Tap allows you to listen on values, without modifying them.
29
22
  *
@@ -38,13 +31,12 @@ function opTapSync(tapFn) {
38
31
  }
39
32
  return fn;
40
33
  }
34
+ exports.opTapSync = opTapSync;
41
35
  /**
42
36
  * Tap allows you to listen on values, without modifying them.
43
37
  *
44
38
  * @param fn - function to call for each value.
45
39
  */
46
- const opTap = (fn) => toPipeFn(opTapSync(fn), opTapAsync(fn));
47
-
40
+ const opTap = (fn) => (0, util_js_1.toPipeFn)(opTapSync(fn), opTapAsync(fn));
48
41
  exports.opTap = opTap;
49
- exports.opTapAsync = opTapAsync;
50
- exports.opTapSync = opTapSync;
42
+ //# sourceMappingURL=tap.js.map
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -1,15 +1,7 @@
1
- 'use strict';
2
-
3
- function toPipeFn(syncFn, asyncFn) {
4
- function _(i) {
5
- return isAsyncIterable(i) ? asyncFn(i) : syncFn(i);
6
- }
7
- return _;
8
- }
9
- function isAsyncIterable(i) {
10
- return typeof i[Symbol.asyncIterator] === 'function';
11
- }
12
-
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.opUnique = exports.opUniqueSync = exports.opUniqueAsync = void 0;
4
+ const util_js_1 = require("../helpers/util.js");
13
5
  function opUniqueAsync(k) {
14
6
  function fnK(k) {
15
7
  async function* fn(iter) {
@@ -35,6 +27,7 @@ function opUniqueAsync(k) {
35
27
  }
36
28
  return k ? fnK(k) : fn;
37
29
  }
30
+ exports.opUniqueAsync = opUniqueAsync;
38
31
  function opUniqueSync(k) {
39
32
  function fnK(key) {
40
33
  function* fn(iter) {
@@ -60,8 +53,7 @@ function opUniqueSync(k) {
60
53
  }
61
54
  return k ? fnK(k) : fn;
62
55
  }
63
- const opUnique = (getKey) => toPipeFn(opUniqueSync(getKey), opUniqueAsync(getKey));
64
-
65
- exports.opUnique = opUnique;
66
- exports.opUniqueAsync = opUniqueAsync;
67
56
  exports.opUniqueSync = opUniqueSync;
57
+ const opUnique = (getKey) => (0, util_js_1.toPipeFn)(opUniqueSync(getKey), opUniqueAsync(getKey));
58
+ exports.opUnique = opUnique;
59
+ //# sourceMappingURL=unique.js.map
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pipeSync = exports.pipeAsync = void 0;
4
+ const index_js_1 = require("./helpers/index.js");
5
+ const index_js_2 = require("./operators/index.js");
6
+ function pipeAsync(i, ...fns) {
7
+ const iter = (0, index_js_1.toAsyncIterable)(i);
8
+ return (0, index_js_2.opCombineAsync)(...fns)(iter);
9
+ }
10
+ exports.pipeAsync = pipeAsync;
11
+ function pipeSync(i, ...fns) {
12
+ return (0, index_js_2.opCombineSync)(...fns)(i);
13
+ }
14
+ exports.pipeSync = pipeSync;
15
+ //# sourceMappingURL=pipe.js.map
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.reduce = exports.reduceAsync = exports.reduceSync = void 0;
4
+ const index_js_1 = require("./helpers/index.js");
5
+ const toArray_js_1 = require("./helpers/toArray.js");
6
+ const index_js_2 = require("./operators/index.js");
7
+ const pipe_js_1 = require("./pipe.js");
8
+ function reduceSync(iter, reduceFn, initialValue) {
9
+ const i = initialValue === undefined
10
+ ? (0, pipe_js_1.pipeSync)(iter, (0, index_js_2.opReduceSync)(reduceFn))
11
+ : (0, pipe_js_1.pipeSync)(iter, (0, index_js_2.opReduceSync)(reduceFn, initialValue));
12
+ return [...i][0];
13
+ }
14
+ exports.reduceSync = reduceSync;
15
+ async function reduceAsync(iter, reduceFn, initialValue) {
16
+ const i = initialValue === undefined
17
+ ? (0, pipe_js_1.pipeAsync)(iter, (0, index_js_2.opReduceAsync)(reduceFn))
18
+ : (0, pipe_js_1.pipeAsync)(iter, (0, index_js_2.opReduceAsync)(reduceFn, initialValue));
19
+ const arr = await (0, toArray_js_1.toArrayAsync)(i);
20
+ return arr[0];
21
+ }
22
+ exports.reduceAsync = reduceAsync;
23
+ function reduce(iter, reduceFn, initialValue) {
24
+ return (0, index_js_1.isAsyncIterable)(iter) ? reduceAsync(iter, reduceFn, initialValue) : reduceSync(iter, reduceFn, initialValue);
25
+ }
26
+ exports.reduce = reduce;
27
+ //# sourceMappingURL=reduce.js.map
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.reduce = exports.pipeSync = exports.pipe = exports.opUnique = exports.opTap = exports.opTake = exports.opSkip = exports.opReduce = exports.opMap = exports.opLast = exports.opJoinStrings = exports.opFlatten = exports.opFirst = exports.opFilter = exports.opConcatMap = exports.opCombine = exports.opAppend = exports.toArray = void 0;
4
+ var toArray_js_1 = require("../helpers/toArray.js");
5
+ Object.defineProperty(exports, "toArray", { enumerable: true, get: function () { return toArray_js_1.toArraySync; } });
6
+ var index_js_1 = require("../operators/index.js");
7
+ Object.defineProperty(exports, "opAppend", { enumerable: true, get: function () { return index_js_1.opAppendSync; } });
8
+ Object.defineProperty(exports, "opCombine", { enumerable: true, get: function () { return index_js_1.opCombineSync; } });
9
+ Object.defineProperty(exports, "opConcatMap", { enumerable: true, get: function () { return index_js_1.opConcatMapSync; } });
10
+ Object.defineProperty(exports, "opFilter", { enumerable: true, get: function () { return index_js_1.opFilterSync; } });
11
+ Object.defineProperty(exports, "opFirst", { enumerable: true, get: function () { return index_js_1.opFirstSync; } });
12
+ Object.defineProperty(exports, "opFlatten", { enumerable: true, get: function () { return index_js_1.opFlattenSync; } });
13
+ Object.defineProperty(exports, "opJoinStrings", { enumerable: true, get: function () { return index_js_1.opJoinStringsSync; } });
14
+ Object.defineProperty(exports, "opLast", { enumerable: true, get: function () { return index_js_1.opLastSync; } });
15
+ Object.defineProperty(exports, "opMap", { enumerable: true, get: function () { return index_js_1.opMapSync; } });
16
+ Object.defineProperty(exports, "opReduce", { enumerable: true, get: function () { return index_js_1.opReduceSync; } });
17
+ Object.defineProperty(exports, "opSkip", { enumerable: true, get: function () { return index_js_1.opSkipSync; } });
18
+ Object.defineProperty(exports, "opTake", { enumerable: true, get: function () { return index_js_1.opTakeSync; } });
19
+ Object.defineProperty(exports, "opTap", { enumerable: true, get: function () { return index_js_1.opTapSync; } });
20
+ Object.defineProperty(exports, "opUnique", { enumerable: true, get: function () { return index_js_1.opUniqueSync; } });
21
+ var pipe_js_1 = require("../pipe.js");
22
+ Object.defineProperty(exports, "pipe", { enumerable: true, get: function () { return pipe_js_1.pipeSync; } });
23
+ Object.defineProperty(exports, "pipeSync", { enumerable: true, get: function () { return pipe_js_1.pipeSync; } });
24
+ var reduce_js_1 = require("../reduce.js");
25
+ Object.defineProperty(exports, "reduce", { enumerable: true, get: function () { return reduce_js_1.reduceSync; } });
26
+ //# sourceMappingURL=index.js.map
@@ -10,4 +10,4 @@ export declare function toDistributableIterableSync<T>(iterable: Iterable<T>): I
10
10
  * @param iterable - the iterable to share
11
11
  */
12
12
  export declare const toDistributableIterable: typeof toDistributableIterableSync;
13
- //# sourceMappingURL=distribute.d.ts.map
13
+ //# sourceMappingURL=distribute.d.mts.map
@@ -30,4 +30,3 @@ export function toDistributableIterableSync(iterable) {
30
30
  * @param iterable - the iterable to share
31
31
  */
32
32
  export const toDistributableIterable = toDistributableIterableSync;
33
- //# sourceMappingURL=distribute.js.map
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Allows an iterable to be shared by multiple consumers.
3
+ * Each consumer takes from the iterable.
4
+ * @param iterable - the iterable to share
5
+ */
6
+ export function toDistributableIterableSync(iterable) {
7
+ let lastValue;
8
+ let iter;
9
+ function getNext() {
10
+ if (lastValue && lastValue.done) {
11
+ return { ...lastValue };
12
+ }
13
+ iter = iter || iterable[Symbol.iterator]();
14
+ lastValue = iter.next();
15
+ return lastValue;
16
+ }
17
+ function* iterableFn() {
18
+ let next;
19
+ while (!(next = getNext()).done) {
20
+ yield next.value;
21
+ }
22
+ }
23
+ return {
24
+ [Symbol.iterator]: iterableFn,
25
+ };
26
+ }
27
+ /**
28
+ * Allows an iterable to be shared by multiple consumers.
29
+ * Each consumer takes from the iterable.
30
+ * @param iterable - the iterable to share
31
+ */
32
+ export const toDistributableIterable = toDistributableIterableSync;
@@ -0,0 +1,7 @@
1
+ export { toDistributableIterable } from './distribute.mjs';
2
+ export { interleave } from './interleave.mjs';
3
+ export { asyncIteratorToAsyncIterable, iteratorToIterable } from './iteratorToIterable.mjs';
4
+ export { toArray } from './toArray.mjs';
5
+ export { toAsyncIterable } from './toAsyncIterable.mjs';
6
+ export { isAsyncIterable } from './util.mjs';
7
+ //# sourceMappingURL=index.d.mts.map
@@ -4,4 +4,3 @@ export { asyncIteratorToAsyncIterable, iteratorToIterable } from './iteratorToIt
4
4
  export { toArray } from './toArray.js';
5
5
  export { toAsyncIterable } from './toAsyncIterable.js';
6
6
  export { isAsyncIterable } from './util.js';
7
- //# sourceMappingURL=index.js.map
@@ -0,0 +1,6 @@
1
+ export { toDistributableIterable } from './distribute.mjs';
2
+ export { interleave } from './interleave.mjs';
3
+ export { asyncIteratorToAsyncIterable, iteratorToIterable } from './iteratorToIterable.mjs';
4
+ export { toArray } from './toArray.mjs';
5
+ export { toAsyncIterable } from './toAsyncIterable.mjs';
6
+ export { isAsyncIterable } from './util.mjs';
@@ -1,2 +1,2 @@
1
1
  export declare function interleave<T>(a: Iterable<T>, b: Iterable<T>): Iterable<T>;
2
- //# sourceMappingURL=interleave.d.ts.map
2
+ //# sourceMappingURL=interleave.d.mts.map
@@ -15,4 +15,3 @@ export function* interleave(a, b) {
15
15
  yield bNext.value;
16
16
  }
17
17
  }
18
- //# sourceMappingURL=interleave.js.map
@@ -0,0 +1,17 @@
1
+ export function* interleave(a, b) {
2
+ const ai = a[Symbol.iterator]();
3
+ const bi = b[Symbol.iterator]();
4
+ for (let aNext = ai.next(); !aNext.done; aNext = ai.next()) {
5
+ yield aNext.value;
6
+ const bNext = bi.next();
7
+ if (bNext.done)
8
+ break;
9
+ yield bNext.value;
10
+ }
11
+ for (let aNext = ai.next(); !aNext.done; aNext = ai.next()) {
12
+ yield aNext.value;
13
+ }
14
+ for (let bNext = bi.next(); !bNext.done; bNext = bi.next()) {
15
+ yield bNext.value;
16
+ }
17
+ }
@@ -1,3 +1,3 @@
1
1
  export declare function iteratorToIterable<T>(iterator: Iterator<T>): Iterable<T>;
2
2
  export declare function asyncIteratorToAsyncIterable<T>(iterator: AsyncIterator<T> | Iterator<T>): AsyncIterable<T>;
3
- //# sourceMappingURL=iteratorToIterable.d.ts.map
3
+ //# sourceMappingURL=iteratorToIterable.d.mts.map
@@ -10,4 +10,3 @@ export async function* asyncIteratorToAsyncIterable(iterator) {
10
10
  yield n.value;
11
11
  }
12
12
  }
13
- //# sourceMappingURL=iteratorToIterable.js.map
@@ -0,0 +1,12 @@
1
+ export function* iteratorToIterable(iterator) {
2
+ let n;
3
+ while (!(n = iterator.next()).done) {
4
+ yield n.value;
5
+ }
6
+ }
7
+ export async function* asyncIteratorToAsyncIterable(iterator) {
8
+ let n;
9
+ while (!(n = await iterator.next()).done) {
10
+ yield n.value;
11
+ }
12
+ }
@@ -3,4 +3,4 @@ export declare function toArray<T>(i: Iterable<T>): T[];
3
3
  export declare function toArray<T>(i: Iterable<T> | AsyncIterable<T>): T[] | Promise<Awaited<T>[]>;
4
4
  export declare function toArraySync<T>(iter: Iterable<T>): T[];
5
5
  export declare function toArrayAsync<T>(iter: AsyncIterable<T>): Promise<Awaited<T>[]>;
6
- //# sourceMappingURL=toArray.d.ts.map
6
+ //# sourceMappingURL=toArray.d.mts.map
@@ -12,4 +12,3 @@ export async function toArrayAsync(iter) {
12
12
  }
13
13
  return collection;
14
14
  }
15
- //# sourceMappingURL=toArray.js.map
@@ -0,0 +1,14 @@
1
+ import { isAsyncIterable } from './util.mjs';
2
+ export function toArray(i) {
3
+ return isAsyncIterable(i) ? toArrayAsync(i) : toArraySync(i);
4
+ }
5
+ export function toArraySync(iter) {
6
+ return [...iter];
7
+ }
8
+ export async function toArrayAsync(iter) {
9
+ const collection = [];
10
+ for await (const i of iter) {
11
+ collection.push(i);
12
+ }
13
+ return collection;
14
+ }
@@ -1,4 +1,4 @@
1
- import type { AnyIterable } from '../internalTypes.js';
1
+ import type { AnyIterable } from '../internalTypes.mjs';
2
2
  export declare function mergeAsyncIterables<T>(iter: Iterable<T>): AsyncIterable<T>;
3
3
  export declare function mergeAsyncIterables<T>(iter: AsyncIterable<T>): AsyncIterable<T>;
4
4
  export declare function mergeAsyncIterables<T>(iter: Promise<Iterable<T>>): AsyncIterable<T>;
@@ -8,4 +8,4 @@ export declare function mergeAsyncIterables<T>(iter: AnyIterable<T>, ...rest: An
8
8
  * Convert one or more iterables to an AsyncIterable
9
9
  */
10
10
  export declare const toAsyncIterable: typeof mergeAsyncIterables;
11
- //# sourceMappingURL=toAsyncIterable.d.ts.map
11
+ //# sourceMappingURL=toAsyncIterable.d.mts.map
@@ -12,4 +12,3 @@ export async function* mergeAsyncIterables(iter, ...rest) {
12
12
  * Convert one or more iterables to an AsyncIterable
13
13
  */
14
14
  export const toAsyncIterable = mergeAsyncIterables;
15
- //# sourceMappingURL=toAsyncIterable.js.map
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Merge multiple iterables into an AsyncIterable
3
+ * @param iter - initial iterable.
4
+ * @param rest - iterables to merge.
5
+ */
6
+ export async function* mergeAsyncIterables(iter, ...rest) {
7
+ for await (const i of [iter, ...rest]) {
8
+ yield* i;
9
+ }
10
+ }
11
+ /**
12
+ * Convert one or more iterables to an AsyncIterable
13
+ */
14
+ export const toAsyncIterable = mergeAsyncIterables;
@@ -1,4 +1,4 @@
1
- import type { AnyIterable, PipeFn, PipeFnAsync, PipeFnSync } from '../internalTypes.js';
1
+ import type { AnyIterable, PipeFn, PipeFnAsync, PipeFnSync } from '../internalTypes.mjs';
2
2
  export declare function toPipeFn<T, U = T>(syncFn: PipeFnSync<T, U>, asyncFn: PipeFnAsync<T, U>): PipeFn<T, U>;
3
3
  export declare function isAsyncIterable<T>(i: AnyIterable<T>): i is AsyncIterable<T>;
4
- //# sourceMappingURL=util.d.ts.map
4
+ //# sourceMappingURL=util.d.mts.map
@@ -7,4 +7,3 @@ export function toPipeFn(syncFn, asyncFn) {
7
7
  export function isAsyncIterable(i) {
8
8
  return typeof i[Symbol.asyncIterator] === 'function';
9
9
  }
10
- //# sourceMappingURL=util.js.map
@@ -0,0 +1,9 @@
1
+ export function toPipeFn(syncFn, asyncFn) {
2
+ function _(i) {
3
+ return isAsyncIterable(i) ? asyncFn(i) : syncFn(i);
4
+ }
5
+ return _;
6
+ }
7
+ export function isAsyncIterable(i) {
8
+ return typeof i[Symbol.asyncIterator] === 'function';
9
+ }
@@ -0,0 +1,9 @@
1
+ import * as _helpers from './helpers/index.mjs';
2
+ import * as _operators from './operators/index.mjs';
3
+ export { interleave, isAsyncIterable, toArray, toAsyncIterable, toDistributableIterable } from './helpers/index.mjs';
4
+ export { opAppend, opAwaitAsync, opConcatMap, opFilter, opFirst, opFlatten, opJoinStrings, opLast, opMap, opSkip, opTake, opTap, opUnique, } from './operators/index.mjs';
5
+ export { pipeAsync, pipeSync } from './pipe.mjs';
6
+ export { reduce, reduceAsync, reduceSync } from './reduce.mjs';
7
+ export declare const operators: typeof _operators;
8
+ export declare const helpers: typeof _helpers;
9
+ //# sourceMappingURL=index.d.mts.map
package/dist/esm/index.js CHANGED
@@ -8,4 +8,3 @@ export { reduce, reduceAsync, reduceSync } from './reduce.js';
8
8
  export const operators = _operators;
9
9
  // eslint-disable-next-line unicorn/prefer-export-from
10
10
  export const helpers = _helpers;
11
- //# sourceMappingURL=index.js.map
@@ -0,0 +1,10 @@
1
+ import * as _helpers from './helpers/index.mjs';
2
+ import * as _operators from './operators/index.mjs';
3
+ export { interleave, isAsyncIterable, toArray, toAsyncIterable, toDistributableIterable } from './helpers/index.mjs';
4
+ export { opAppend, opAwaitAsync, opConcatMap, opFilter, opFirst, opFlatten, opJoinStrings, opLast, opMap, opSkip, opTake, opTap, opUnique, } from './operators/index.mjs';
5
+ export { pipeAsync, pipeSync } from './pipe.mjs';
6
+ export { reduce, reduceAsync, reduceSync } from './reduce.mjs';
7
+ // eslint-disable-next-line unicorn/prefer-export-from
8
+ export const operators = _operators;
9
+ // eslint-disable-next-line unicorn/prefer-export-from
10
+ export const helpers = _helpers;
@@ -14,4 +14,4 @@ export type AnyIterable<T> = Iterable<T> | AsyncIterable<T> | Promise<Iterable<T
14
14
  export type PaFn<T, U> = PipeFnAsync<T, U> | ((i: AsyncIterable<T>) => AsyncIterable<U>);
15
15
  export type PipeAsyncTx<T extends [...any]> = T extends [infer Left, infer Right, ...infer Rest] ? Rest extends [any, ...any] ? [PaFn<Left, Right>, ...PipeAsyncTx<[Right, ...Rest]>] : [PaFn<Left, Right>] : never;
16
16
  export type PipeSyncTx<T extends [...any]> = T extends [infer Left, infer Right, ...infer Rest] ? Rest extends [any, ...any] ? [PsFn<Left, Right>, ...PipeSyncTx<[Right, ...Rest]>] : [PsFn<Left, Right>] : never;
17
- //# sourceMappingURL=internalTypes.d.ts.map
17
+ //# sourceMappingURL=internalTypes.d.mts.map
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=internalTypes.js.map
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,4 @@
1
- import type { PipeFn } from '../internalTypes.js';
1
+ import type { PipeFn } from '../internalTypes.mjs';
2
2
  /**
3
3
  * Append values onto the end of an iterable.
4
4
  * @param iterablesToAppend - the iterables in the order to be appended.
@@ -12,4 +12,4 @@ export declare function opAppendAsync<T>(...iterablesToAppend: (AsyncIterable<T>
12
12
  */
13
13
  export declare function opAppendSync<T>(...iterablesToAppend: Iterable<T>[]): (iter: Iterable<T>) => Iterable<T>;
14
14
  export declare function opAppend<T>(...iterablesToAppend: Iterable<T>[]): PipeFn<T, T>;
15
- //# sourceMappingURL=append.d.ts.map
15
+ //# sourceMappingURL=append.d.mts.map
@@ -33,4 +33,3 @@ export function opAppend(...iterablesToAppend) {
33
33
  }
34
34
  return _;
35
35
  }
36
- //# sourceMappingURL=append.js.map
@@ -0,0 +1,35 @@
1
+ import { isAsyncIterable } from '../helpers/index.mjs';
2
+ /**
3
+ * Append values onto the end of an iterable.
4
+ * @param iterablesToAppend - the iterables in the order to be appended.
5
+ * @returns
6
+ */
7
+ export function opAppendAsync(...iterablesToAppend) {
8
+ async function* fn(iter) {
9
+ yield* iter;
10
+ for (const i of iterablesToAppend) {
11
+ yield* i;
12
+ }
13
+ }
14
+ return fn;
15
+ }
16
+ /**
17
+ * Append values onto the end of an iterable.
18
+ * @param iterablesToAppend - the iterables in the order to be appended.
19
+ * @returns
20
+ */
21
+ export function opAppendSync(...iterablesToAppend) {
22
+ function* fn(iter) {
23
+ yield* iter;
24
+ for (const i of iterablesToAppend) {
25
+ yield* i;
26
+ }
27
+ }
28
+ return fn;
29
+ }
30
+ export function opAppend(...iterablesToAppend) {
31
+ function _(i) {
32
+ return isAsyncIterable(i) ? opAppendAsync(...iterablesToAppend)(i) : opAppendSync(...iterablesToAppend)(i);
33
+ }
34
+ return _;
35
+ }
@@ -1,2 +1,2 @@
1
1
  export declare function opAwaitAsync<T>(): (iter: AsyncIterable<T>) => AsyncIterable<Awaited<T>>;
2
- //# sourceMappingURL=await.d.ts.map
2
+ //# sourceMappingURL=await.d.mts.map
@@ -6,4 +6,3 @@ async function* _asyncAwait(iter) {
6
6
  export function opAwaitAsync() {
7
7
  return _asyncAwait;
8
8
  }
9
- //# sourceMappingURL=await.js.map
@@ -1,12 +1,8 @@
1
- 'use strict';
2
-
3
1
  async function* _asyncAwait(iter) {
4
2
  for await (const v of iter) {
5
3
  yield v;
6
4
  }
7
5
  }
8
- function opAwaitAsync() {
6
+ export function opAwaitAsync() {
9
7
  return _asyncAwait;
10
8
  }
11
-
12
- exports.opAwaitAsync = opAwaitAsync;