@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,5 +1,5 @@
1
- import type { PaFn, PipeAsyncTx, PipeSyncTx, PsFn } from '../internalTypes.js';
2
- import type { OperatorAsync, OperatorSync } from './types.js';
1
+ import type { PaFn, PipeAsyncTx, PipeSyncTx, PsFn } from '../internalTypes.mjs';
2
+ import type { OperatorAsync, OperatorSync } from './types.mjs';
3
3
  export declare function opCombineAsync<T>(): OperatorAsync<T>;
4
4
  export declare function opCombineAsync<T, T0>(...f: PipeAsyncTx<[T, T0]>): OperatorAsync<T0>;
5
5
  export declare function opCombineAsync<T, T0, T1>(...f: PipeAsyncTx<[T, T0, T1]>): OperatorAsync<T1>;
@@ -20,4 +20,4 @@ export declare function opCombineSync<T, T0, T1, T2, T3, T4, T5>(...f: PipeSyncT
20
20
  export declare function opCombineSync<T, T0, T1, T2, T3, T4, T5, T6>(...f: PipeSyncTx<[T, T0, T1, T2, T3, T4, T5, T6]>): OperatorSync<T6>;
21
21
  export declare function opCombineSync<T, T0, T1, T2, T3, T4, T5, T6, T7>(...f: PipeSyncTx<[T, T0, T1, T2, T3, T4, T5, T6, T7]>): OperatorSync<T7>;
22
22
  export declare function opCombineSync<T>(...fns: PsFn<T, T>[]): OperatorSync<T>;
23
- //# sourceMappingURL=combine.d.ts.map
23
+ //# sourceMappingURL=combine.d.mts.map
@@ -16,4 +16,3 @@ export function opCombineSync(...fns) {
16
16
  }
17
17
  return combine;
18
18
  }
19
- //# sourceMappingURL=combine.js.map
@@ -0,0 +1,18 @@
1
+ export function opCombineAsync(...fns) {
2
+ function combine(iter) {
3
+ for (const fn of fns) {
4
+ iter = fn(iter);
5
+ }
6
+ return iter;
7
+ }
8
+ return combine;
9
+ }
10
+ export function opCombineSync(...fns) {
11
+ function combine(iter) {
12
+ for (const fn of fns) {
13
+ iter = fn(iter);
14
+ }
15
+ return iter;
16
+ }
17
+ return combine;
18
+ }
@@ -1,4 +1,4 @@
1
1
  export declare function opConcatMapAsync<T, U = T>(mapFn: (v: T) => AsyncIterable<U> | Iterable<U>): (iter: AsyncIterable<T>) => AsyncIterable<U>;
2
2
  export declare function opConcatMapSync<T, U = T>(mapFn: (v: T) => Iterable<U>): (iter: Iterable<T>) => Iterable<U>;
3
3
  export declare const opConcatMap: <T, U>(fn: (v: T) => Iterable<U>) => import("../internalTypes.js").PipeFn<T, U>;
4
- //# sourceMappingURL=concatMap.d.ts.map
4
+ //# sourceMappingURL=concatMap.d.mts.map
@@ -16,4 +16,3 @@ export function opConcatMapSync(mapFn) {
16
16
  return fn;
17
17
  }
18
18
  export const opConcatMap = (fn) => toPipeFn(opConcatMapSync(fn), opConcatMapAsync(fn));
19
- //# sourceMappingURL=concatMap.js.map
@@ -0,0 +1,18 @@
1
+ import { toPipeFn } from '../helpers/util.mjs';
2
+ export function opConcatMapAsync(mapFn) {
3
+ async function* fn(iter) {
4
+ for await (const v of iter) {
5
+ yield* mapFn(v);
6
+ }
7
+ }
8
+ return fn;
9
+ }
10
+ export function opConcatMapSync(mapFn) {
11
+ function* fn(iter) {
12
+ for (const v of iter) {
13
+ yield* mapFn(v);
14
+ }
15
+ }
16
+ return fn;
17
+ }
18
+ export const opConcatMap = (fn) => toPipeFn(opConcatMapSync(fn), opConcatMapAsync(fn));
@@ -1,4 +1,4 @@
1
- import type { PipeFn } from '../internalTypes.js';
1
+ import type { PipeFn } from '../internalTypes.mjs';
2
2
  export declare function opFilterAsync<T, S extends T>(filterFn: (v: T) => v is S): (iter: AsyncIterable<T>) => AsyncIterable<S>;
3
3
  export declare function opFilterAsync<T, S extends Awaited<T>>(filterFn: (v: Awaited<T>) => v is S): (iter: AsyncIterable<T>) => AsyncIterable<S>;
4
4
  export declare function opFilterAsync<T>(filterFn: (v: Awaited<T>) => boolean): (iter: AsyncIterable<T>) => AsyncIterable<Awaited<T>>;
@@ -7,4 +7,4 @@ export declare function opFilterSync<T, S extends T>(filterFn: (v: T) => v is S)
7
7
  export declare function opFilterSync<T>(filterFn: (v: T) => boolean): (iter: Iterable<T>) => Iterable<T>;
8
8
  export declare function opFilter<T, S extends T>(fn: (v: T) => v is S): PipeFn<T, S>;
9
9
  export declare function opFilter<T>(fn: (v: T) => boolean): PipeFn<T, T>;
10
- //# sourceMappingURL=filter.d.ts.map
10
+ //# sourceMappingURL=filter.d.mts.map
@@ -27,4 +27,3 @@ export function opFilter(fn) {
27
27
  }
28
28
  return _;
29
29
  }
30
- //# sourceMappingURL=filter.js.map
@@ -0,0 +1,29 @@
1
+ import { isAsyncIterable } from '../helpers/util.mjs';
2
+ // prettier-ignore
3
+ export function opFilterAsync(filterFn) {
4
+ async function* fn(iter) {
5
+ for await (const v of iter) {
6
+ const pass = await filterFn(v);
7
+ if (pass)
8
+ yield v;
9
+ }
10
+ }
11
+ return fn;
12
+ }
13
+ export function opFilterSync(filterFn) {
14
+ function* fn(iter) {
15
+ for (const v of iter) {
16
+ if (filterFn(v))
17
+ yield v;
18
+ }
19
+ }
20
+ return fn;
21
+ }
22
+ export function opFilter(fn) {
23
+ const asyncFn = opFilterAsync(fn);
24
+ const syncFn = opFilterSync(fn);
25
+ function _(i) {
26
+ return isAsyncIterable(i) ? asyncFn(i) : syncFn(i);
27
+ }
28
+ return _;
29
+ }
@@ -1,4 +1,4 @@
1
- import type { PipeFn } from '../internalTypes.js';
1
+ import type { PipeFn } from '../internalTypes.mjs';
2
2
  export declare function opFirstAsync<T, S extends T>(firstFn: (v: T) => v is S): (iter: AsyncIterable<T>) => AsyncIterable<S>;
3
3
  export declare function opFirstAsync<T, S extends Awaited<T>>(firstFn: (v: Awaited<T>) => v is S): (iter: AsyncIterable<T>) => AsyncIterable<S>;
4
4
  export declare function opFirstAsync<T>(firstFn: (v: Awaited<T>) => boolean): (iter: AsyncIterable<T>) => AsyncIterable<Awaited<T>>;
@@ -7,4 +7,4 @@ export declare function opFirstSync<T, S extends T>(firstFn: (v: T) => v is S):
7
7
  export declare function opFirstSync<T>(firstFn: (v: T) => boolean): (iter: Iterable<T>) => Iterable<T>;
8
8
  export declare function opFirst<T, S extends T>(fn: (v: T) => v is S): PipeFn<T, S>;
9
9
  export declare function opFirst<T>(fn: (v: T) => boolean): PipeFn<T, T>;
10
- //# sourceMappingURL=first.d.ts.map
10
+ //# sourceMappingURL=first.d.mts.map
@@ -31,4 +31,3 @@ export function opFirst(fn) {
31
31
  }
32
32
  return _;
33
33
  }
34
- //# sourceMappingURL=first.js.map
@@ -0,0 +1,33 @@
1
+ import { isAsyncIterable } from '../helpers/util.mjs';
2
+ // prettier-ignore
3
+ export function opFirstAsync(firstFn) {
4
+ async function* fn(iter) {
5
+ for await (const v of iter) {
6
+ const pass = await firstFn(v);
7
+ if (pass) {
8
+ yield v;
9
+ break;
10
+ }
11
+ }
12
+ }
13
+ return fn;
14
+ }
15
+ export function opFirstSync(firstFn) {
16
+ function* fn(iter) {
17
+ for (const v of iter) {
18
+ if (firstFn(v)) {
19
+ yield v;
20
+ break;
21
+ }
22
+ }
23
+ }
24
+ return fn;
25
+ }
26
+ export function opFirst(fn) {
27
+ const asyncFn = opFirstAsync(fn);
28
+ const syncFn = opFirstSync(fn);
29
+ function _(i) {
30
+ return isAsyncIterable(i) ? asyncFn(i) : syncFn(i);
31
+ }
32
+ return _;
33
+ }
@@ -1,4 +1,4 @@
1
1
  export declare function opFlattenAsync<T>(): (iter: AsyncIterable<AsyncIterable<T> | Iterable<T>>) => AsyncIterable<T>;
2
2
  export declare function opFlattenSync<T>(): (iter: Iterable<Iterable<T>>) => Iterable<T>;
3
3
  export declare const opFlatten: <T>() => import("../internalTypes.js").PipeFn<Iterable<T>, T>;
4
- //# sourceMappingURL=flatten.d.ts.map
4
+ //# sourceMappingURL=flatten.d.mts.map
@@ -16,4 +16,3 @@ export function opFlattenSync() {
16
16
  return fn;
17
17
  }
18
18
  export const opFlatten = () => toPipeFn(opFlattenSync(), opFlattenAsync());
19
- //# sourceMappingURL=flatten.js.map
@@ -0,0 +1,18 @@
1
+ import { toPipeFn } from '../helpers/util.mjs';
2
+ export function opFlattenAsync() {
3
+ async function* fn(iter) {
4
+ for await (const v of iter) {
5
+ yield* v;
6
+ }
7
+ }
8
+ return fn;
9
+ }
10
+ export function opFlattenSync() {
11
+ function* fn(iter) {
12
+ for (const v of iter) {
13
+ yield* v;
14
+ }
15
+ }
16
+ return fn;
17
+ }
18
+ export const opFlatten = () => toPipeFn(opFlattenSync(), opFlattenAsync());
@@ -0,0 +1,17 @@
1
+ export { opAppend, opAppendAsync, opAppendSync } from './append.mjs';
2
+ export { opAwaitAsync } from './await.mjs';
3
+ export { opCombineAsync, opCombineSync } from './combine.mjs';
4
+ export { opConcatMap, opConcatMapAsync, opConcatMapSync } from './concatMap.mjs';
5
+ export { opFilter, opFilterAsync, opFilterSync } from './filter.mjs';
6
+ export { opFirst, opFirstAsync, opFirstSync } from './first.mjs';
7
+ export { opFlatten, opFlattenAsync, opFlattenSync } from './flatten.mjs';
8
+ export { opJoinStrings, opJoinStringsAsync, opJoinStringsSync } from './joinStrings.mjs';
9
+ export { opLast, opLastAsync, opLastSync } from './last.mjs';
10
+ export { opMap, opMapAsync, opMapSync } from './map.mjs';
11
+ export { opReduceAsync, opReduceSync } from './reduce.mjs';
12
+ export { opSkip, opSkipAsync, opSkipSync } from './skip.mjs';
13
+ export { opTake, opTakeAsync, opTakeSync } from './take.mjs';
14
+ export { opTap, opTapAsync, opTapSync } from './tap.mjs';
15
+ export type { OperatorAsync, OperatorSync, OperatorSyncToAsync } from './types.mjs';
16
+ export { opUnique, opUniqueAsync, opUniqueSync } from './unique.mjs';
17
+ //# sourceMappingURL=index.d.mts.map
@@ -13,4 +13,3 @@ export { opSkip, opSkipAsync, opSkipSync } from './skip.js';
13
13
  export { opTake, opTakeAsync, opTakeSync } from './take.js';
14
14
  export { opTap, opTapAsync, opTapSync } from './tap.js';
15
15
  export { opUnique, opUniqueAsync, opUniqueSync } from './unique.js';
16
- //# sourceMappingURL=index.js.map
@@ -0,0 +1,15 @@
1
+ export { opAppend, opAppendAsync, opAppendSync } from './append.mjs';
2
+ export { opAwaitAsync } from './await.mjs';
3
+ export { opCombineAsync, opCombineSync } from './combine.mjs';
4
+ export { opConcatMap, opConcatMapAsync, opConcatMapSync } from './concatMap.mjs';
5
+ export { opFilter, opFilterAsync, opFilterSync } from './filter.mjs';
6
+ export { opFirst, opFirstAsync, opFirstSync } from './first.mjs';
7
+ export { opFlatten, opFlattenAsync, opFlattenSync } from './flatten.mjs';
8
+ export { opJoinStrings, opJoinStringsAsync, opJoinStringsSync } from './joinStrings.mjs';
9
+ export { opLast, opLastAsync, opLastSync } from './last.mjs';
10
+ export { opMap, opMapAsync, opMapSync } from './map.mjs';
11
+ export { opReduceAsync, opReduceSync } from './reduce.mjs';
12
+ export { opSkip, opSkipAsync, opSkipSync } from './skip.mjs';
13
+ export { opTake, opTakeAsync, opTakeSync } from './take.mjs';
14
+ export { opTap, opTapAsync, opTapSync } from './tap.mjs';
15
+ export { opUnique, opUniqueAsync, opUniqueSync } from './unique.mjs';
@@ -1,4 +1,4 @@
1
1
  export declare function opJoinStringsAsync(joinCharacter?: string): (iter: AsyncIterable<AsyncIterable<string> | Iterable<string>>) => AsyncIterable<string>;
2
2
  export declare function opJoinStringsSync(joinCharacter?: string): (iter: Iterable<Iterable<string>>) => Iterable<string>;
3
3
  export declare const opJoinStrings: (joinCharacter?: string) => import("../internalTypes.js").PipeFn<Iterable<string>, string>;
4
- //# sourceMappingURL=joinStrings.d.ts.map
4
+ //# sourceMappingURL=joinStrings.d.mts.map
@@ -19,4 +19,3 @@ export function opJoinStringsSync(joinCharacter = ',') {
19
19
  return fn;
20
20
  }
21
21
  export const opJoinStrings = (joinCharacter) => toPipeFn(opJoinStringsSync(joinCharacter), opJoinStringsAsync(joinCharacter));
22
- //# sourceMappingURL=joinStrings.js.map
@@ -0,0 +1,21 @@
1
+ import { toArray } from '../helpers/toArray.mjs';
2
+ import { toPipeFn } from '../helpers/util.mjs';
3
+ export function opJoinStringsAsync(joinCharacter = ',') {
4
+ async function* fn(iter) {
5
+ for await (const v of iter) {
6
+ const a = await toArray(v);
7
+ yield a.join(joinCharacter);
8
+ }
9
+ }
10
+ return fn;
11
+ }
12
+ export function opJoinStringsSync(joinCharacter = ',') {
13
+ function* fn(iter) {
14
+ for (const v of iter) {
15
+ const a = toArray(v);
16
+ yield a.join(joinCharacter);
17
+ }
18
+ }
19
+ return fn;
20
+ }
21
+ export const opJoinStrings = (joinCharacter) => toPipeFn(opJoinStringsSync(joinCharacter), opJoinStringsAsync(joinCharacter));
@@ -1,4 +1,4 @@
1
- import type { PipeFn } from '../internalTypes.js';
1
+ import type { PipeFn } from '../internalTypes.mjs';
2
2
  export declare function opLastAsync<T, S extends T>(lastFn: (v: T) => v is S): (iter: AsyncIterable<T>) => AsyncIterable<S>;
3
3
  export declare function opLastAsync<T, S extends Awaited<T>>(lastFn: (v: Awaited<T>) => v is S): (iter: AsyncIterable<T>) => AsyncIterable<S>;
4
4
  export declare function opLastAsync<T>(lastFn: (v: Awaited<T>) => boolean): (iter: AsyncIterable<T>) => AsyncIterable<Awaited<T>>;
@@ -7,4 +7,4 @@ export declare function opLastSync<T, S extends T>(lastFn: (v: T) => v is S): (i
7
7
  export declare function opLastSync<T>(lastFn: (v: T) => boolean): (iter: Iterable<T>) => Iterable<T>;
8
8
  export declare function opLast<T, S extends T>(fn: (v: T) => v is S): PipeFn<T, S>;
9
9
  export declare function opLast<T>(fn: (v: T) => boolean): PipeFn<T, T>;
10
- //# sourceMappingURL=last.d.ts.map
10
+ //# sourceMappingURL=last.d.mts.map
@@ -36,4 +36,3 @@ export function opLast(fn) {
36
36
  }
37
37
  return _;
38
38
  }
39
- //# sourceMappingURL=last.js.map
@@ -0,0 +1,38 @@
1
+ import { isAsyncIterable } from '../helpers/util.mjs';
2
+ const symNotFound = Symbol('LastNotFound');
3
+ // prettier-ignore
4
+ export function opLastAsync(lastFn) {
5
+ async function* fn(iter) {
6
+ let last = symNotFound;
7
+ for await (const v of iter) {
8
+ const pass = await lastFn(v);
9
+ if (pass) {
10
+ last = v;
11
+ }
12
+ }
13
+ if (last !== symNotFound)
14
+ yield last;
15
+ }
16
+ return fn;
17
+ }
18
+ export function opLastSync(lastFn) {
19
+ function* fn(iter) {
20
+ let last = symNotFound;
21
+ for (const v of iter) {
22
+ if (lastFn(v)) {
23
+ last = v;
24
+ }
25
+ }
26
+ if (last !== symNotFound)
27
+ yield last;
28
+ }
29
+ return fn;
30
+ }
31
+ export function opLast(fn) {
32
+ const asyncFn = opLastAsync(fn);
33
+ const syncFn = opLastSync(fn);
34
+ function _(i) {
35
+ return isAsyncIterable(i) ? asyncFn(i) : syncFn(i);
36
+ }
37
+ return _;
38
+ }
@@ -1,4 +1,4 @@
1
1
  export declare function opMapAsync<T, U = T>(mapFn: (v: T) => U): (iter: AsyncIterable<T>) => AsyncIterable<U>;
2
2
  export declare function opMapSync<T, U = T>(mapFn: (v: T) => U): (iter: Iterable<T>) => Iterable<U>;
3
3
  export declare const opMap: <T, U>(fn: (v: T) => U) => import("../internalTypes.js").PipeFn<T, U>;
4
- //# sourceMappingURL=map.d.ts.map
4
+ //# sourceMappingURL=map.d.mts.map
@@ -16,4 +16,3 @@ export function opMapSync(mapFn) {
16
16
  return fn;
17
17
  }
18
18
  export const opMap = (fn) => toPipeFn(opMapSync(fn), opMapAsync(fn));
19
- //# sourceMappingURL=map.js.map
@@ -0,0 +1,18 @@
1
+ import { toPipeFn } from '../helpers/util.mjs';
2
+ export function opMapAsync(mapFn) {
3
+ async function* fn(iter) {
4
+ for await (const v of iter) {
5
+ yield mapFn(v);
6
+ }
7
+ }
8
+ return fn;
9
+ }
10
+ export function opMapSync(mapFn) {
11
+ function* fn(iter) {
12
+ for (const v of iter) {
13
+ yield mapFn(v);
14
+ }
15
+ }
16
+ return fn;
17
+ }
18
+ export const opMap = (fn) => toPipeFn(opMapSync(fn), opMapAsync(fn));
@@ -4,4 +4,4 @@ export declare function opReduceAsync<T, U>(reduceFn: (previousValue: U, current
4
4
  export declare function opReduceSync<T>(reduceFn: (previousValue: T, currentValue: T) => T): (iter: Iterable<T>) => Iterable<T>;
5
5
  export declare function opReduceSync<T>(reduceFn: (previousValue: T, currentValue: T) => T, initialValue: T): (iter: Iterable<T>) => Iterable<T>;
6
6
  export declare function opReduceSync<T, U>(reduceFn: (previousValue: U, currentValue: T) => U, initialValue: U): (iter: Iterable<T>) => Iterable<U>;
7
- //# sourceMappingURL=reduce.d.ts.map
7
+ //# sourceMappingURL=reduce.d.mts.map
@@ -46,4 +46,3 @@ async function headTailAsync(iter) {
46
46
  function isIterable(i) {
47
47
  return typeof i[Symbol.iterator] === 'function';
48
48
  }
49
- //# sourceMappingURL=reduce.js.map
@@ -0,0 +1,48 @@
1
+ import { asyncIteratorToAsyncIterable, iteratorToIterable } from '../helpers/index.mjs';
2
+ export function opReduceAsync(reduceFn, initialValue) {
3
+ async function* reduce(head, tail) {
4
+ for await (const v of tail) {
5
+ head = reduceFn(head, v);
6
+ }
7
+ yield head;
8
+ }
9
+ async function* fn(iter) {
10
+ const ht = initialValue === undefined ? await headTailAsync(iter) : { head: await initialValue, tail: iter };
11
+ if (!ht)
12
+ return;
13
+ yield* reduce(ht.head, ht.tail);
14
+ }
15
+ return fn;
16
+ }
17
+ export function opReduceSync(reduceFn, initialValue) {
18
+ function* reduce(head, tail) {
19
+ for (const v of tail) {
20
+ head = reduceFn(head, v);
21
+ }
22
+ yield head;
23
+ }
24
+ function* fn(iter) {
25
+ const ht = initialValue === undefined ? headTail(iter) : { head: initialValue, tail: iter };
26
+ if (!ht)
27
+ return;
28
+ yield* reduce(ht.head, ht.tail);
29
+ }
30
+ return fn;
31
+ }
32
+ function headTail(iter) {
33
+ const iterator = iter[Symbol.iterator]();
34
+ const first = iterator.next();
35
+ if (first.done)
36
+ return undefined;
37
+ return { head: first.value, tail: iteratorToIterable(iterator) };
38
+ }
39
+ async function headTailAsync(iter) {
40
+ const iterator = isIterable(iter) ? iter[Symbol.iterator]() : iter[Symbol.asyncIterator]();
41
+ const first = await iterator.next();
42
+ if (first.done)
43
+ return undefined;
44
+ return { head: first.value, tail: asyncIteratorToAsyncIterable(iterator) };
45
+ }
46
+ function isIterable(i) {
47
+ return typeof i[Symbol.iterator] === 'function';
48
+ }
@@ -1,4 +1,4 @@
1
1
  export declare function opSkipAsync<T>(count: number): (iter: AsyncIterable<T> | Iterable<T>) => AsyncIterable<T>;
2
2
  export declare function opSkipSync<T>(count: number): (iter: Iterable<T>) => Iterable<T>;
3
3
  export declare const opSkip: <T>(count: number) => import("../internalTypes.js").PipeFn<T, T>;
4
- //# sourceMappingURL=skip.d.ts.map
4
+ //# sourceMappingURL=skip.d.mts.map
@@ -24,4 +24,3 @@ export function opSkipSync(count) {
24
24
  return fn;
25
25
  }
26
26
  export const opSkip = (count) => toPipeFn(opSkipSync(count), opSkipAsync(count));
27
- //# sourceMappingURL=skip.js.map
@@ -0,0 +1,26 @@
1
+ import { toPipeFn } from '../helpers/util.mjs';
2
+ export function opSkipAsync(count) {
3
+ async function* fn(iter) {
4
+ for await (const v of iter) {
5
+ if (count > 0) {
6
+ --count;
7
+ continue;
8
+ }
9
+ yield v;
10
+ }
11
+ }
12
+ return fn;
13
+ }
14
+ export function opSkipSync(count) {
15
+ function* fn(iter) {
16
+ for (const v of iter) {
17
+ if (count > 0) {
18
+ --count;
19
+ continue;
20
+ }
21
+ yield v;
22
+ }
23
+ }
24
+ return fn;
25
+ }
26
+ export const opSkip = (count) => toPipeFn(opSkipSync(count), opSkipAsync(count));
@@ -5,4 +5,4 @@ export declare function opTakeSync<T>(count: number): (iter: Iterable<T>) => Ite
5
5
  * @param count - number to take
6
6
  */
7
7
  export declare const opTake: <T>(count: number) => import("../internalTypes.js").PipeFn<T, T>;
8
- //# sourceMappingURL=take.d.ts.map
8
+ //# sourceMappingURL=take.d.mts.map
@@ -28,4 +28,3 @@ export function opTakeSync(count) {
28
28
  * @param count - number to take
29
29
  */
30
30
  export const opTake = (count) => toPipeFn(opTakeSync(count), opTakeAsync(count));
31
- //# sourceMappingURL=take.js.map
@@ -0,0 +1,30 @@
1
+ import { toPipeFn } from '../helpers/util.mjs';
2
+ export function opTakeAsync(count) {
3
+ async function* fn(iter) {
4
+ if (count <= 0)
5
+ return;
6
+ for await (const v of iter) {
7
+ yield v;
8
+ if (--count <= 0)
9
+ return;
10
+ }
11
+ }
12
+ return fn;
13
+ }
14
+ export function opTakeSync(count) {
15
+ function* fn(iter) {
16
+ if (count <= 0)
17
+ return;
18
+ for (const v of iter) {
19
+ yield v;
20
+ if (--count <= 0)
21
+ return;
22
+ }
23
+ }
24
+ return fn;
25
+ }
26
+ /**
27
+ * Consume only the first `count` number from the iterable.
28
+ * @param count - number to take
29
+ */
30
+ export const opTake = (count) => toPipeFn(opTakeSync(count), opTakeAsync(count));
@@ -16,4 +16,4 @@ export declare function opTapSync<T>(tapFn: (v: T) => void): (iter: Iterable<T>)
16
16
  * @param fn - function to call for each value.
17
17
  */
18
18
  export declare const opTap: <T>(fn: (v: T) => void) => import("../internalTypes.js").PipeFn<T, T>;
19
- //# sourceMappingURL=tap.d.ts.map
19
+ //# sourceMappingURL=tap.d.mts.map
@@ -33,4 +33,3 @@ export function opTapSync(tapFn) {
33
33
  * @param fn - function to call for each value.
34
34
  */
35
35
  export const opTap = (fn) => toPipeFn(opTapSync(fn), opTapAsync(fn));
36
- //# sourceMappingURL=tap.js.map
@@ -0,0 +1,35 @@
1
+ import { toPipeFn } from '../helpers/util.mjs';
2
+ /**
3
+ * Tap allows you to listen on values, without modifying them.
4
+ *
5
+ * @param fn - function to call for each value.
6
+ */
7
+ export function opTapAsync(tapFn) {
8
+ async function* fn(iter) {
9
+ for await (const v of iter) {
10
+ tapFn(v);
11
+ yield v;
12
+ }
13
+ }
14
+ return fn;
15
+ }
16
+ /**
17
+ * Tap allows you to listen on values, without modifying them.
18
+ *
19
+ * @param fn - function to call for each value.
20
+ */
21
+ export function opTapSync(tapFn) {
22
+ function* fn(iter) {
23
+ for (const v of iter) {
24
+ tapFn(v);
25
+ yield v;
26
+ }
27
+ }
28
+ return fn;
29
+ }
30
+ /**
31
+ * Tap allows you to listen on values, without modifying them.
32
+ *
33
+ * @param fn - function to call for each value.
34
+ */
35
+ export const opTap = (fn) => toPipeFn(opTapSync(fn), opTapAsync(fn));
@@ -1,4 +1,4 @@
1
1
  export type OperatorSync<T, U = T> = (i: Iterable<T>) => Iterable<U>;
2
2
  export type OperatorAsync<T, U = T> = (i: AsyncIterable<T>) => AsyncIterable<U>;
3
3
  export type OperatorSyncToAsync<T, U = T> = (i: Iterable<T>) => AsyncIterable<U>;
4
- //# sourceMappingURL=types.d.ts.map
4
+ //# sourceMappingURL=types.d.mts.map
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,4 @@
1
1
  export declare function opUniqueAsync<T, U>(k?: (v: T) => U): (iter: AsyncIterable<T>) => AsyncIterable<T>;
2
2
  export declare function opUniqueSync<T, U>(k?: (v: T) => U): (iter: Iterable<T>) => Iterable<T>;
3
3
  export declare const opUnique: <T, U = T>(getKey?: ((v: T) => U) | undefined) => import("../internalTypes.js").PipeFn<T, T>;
4
- //# sourceMappingURL=unique.d.ts.map
4
+ //# sourceMappingURL=unique.d.mts.map
@@ -50,4 +50,3 @@ export function opUniqueSync(k) {
50
50
  return k ? fnK(k) : fn;
51
51
  }
52
52
  export const opUnique = (getKey) => toPipeFn(opUniqueSync(getKey), opUniqueAsync(getKey));
53
- //# sourceMappingURL=unique.js.map