We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
toLength
1 parent 2f75a25 commit 8e66ca7Copy full SHA for 8e66ca7
src/toLength.ts
@@ -1,21 +1,5 @@
1
-import { isAsyncIterable } from './utils/iterator'
2
-import { pipe } from './pipe'
3
-import { toArray } from './toArray'
4
-import { LazyIterable } from './shared-types'
+import { reduce } from './reduce'
5
6
export function toLength() {
7
- return function toLengthFn(data: LazyIterable<any>) {
8
- if (isAsyncIterable(data) || data instanceof Promise) {
9
- return (async () => {
10
- let stream = data instanceof Promise ? await data : data
11
-
12
- let program = pipe(toArray())
13
- let array = await program(stream)
14
15
- return array.length
16
- })()
17
- }
18
19
- return Array.from(data).length
20
+ return reduce((_value, acc) => acc + 1, 0)
21
}
0 commit comments