Function: windowConcur()
Returns a concur iterable containing a rolling window of the values of
concurIterable
as arrays of length size
.
Throws
if size
is not a positive integer.
Example
console.log(
await pipe(
asConcur([1, 2, 3, 4, 5, 6, `sloth`]),
windowConcur(3),
reduceConcur(toArray()),
),
)
//=> [ [ 1, 2, 3 ], [ 2, 3, 4 ], [ 3, 4, 5 ], [ 4, 5, 6 ], [ 5, 6, 'sloth' ] ]
console.log(
await pipe(
asConcur([1, 2, 3, 4, 5, 6, `sloth`]),
windowConcur({ size: 3, partialStart: true }),
reduceConcur(toArray()),
),
)
//=> [ [ 1 ], [ 1, 2 ], [ 1, 2, 3 ], [ 2, 3, 4 ], [ 3, 4, 5 ], [ 4, 5, 6 ], [ 5, 6, 'sloth' ] ]
console.log(
await pipe(
asConcur([1, 2, 3, 4, 5, 6, `sloth`]),
windowConcur({ size: 3, partialStart: true, partialEnd: true }),
reduceConcur(toArray()),
),
)
//=> [ [ 1 ], [ 1, 2 ], [ 1, 2, 3 ], [ 2, 3, 4 ], [ 3, 4, 5 ], [ 4, 5, 6 ], [ 5, 6, 'sloth' ], [ 6, 'sloth' ], [ 'sloth' ] ]
Since
v2.0.0
Call Signature
windowConcur<
Size
>(options
): <Value
>(concurIterable
) =>ConcurIterable
<Value
[]>
Type Parameters
• Size extends number
Parameters
options
WindowOptions
<Size
>
Returns
Function
Type Parameters
• Value
Parameters
concurIterable
ConcurIterable
<Value
>
Returns
ConcurIterable
<Value
[]>
Defined in
Call Signature
windowConcur<
Size
,Value
>(options
,concurIterable
):ConcurIterable
<Value
[]>
Type Parameters
• Size extends number
• Value
Parameters
options
WindowOptions
<Size
>
concurIterable
ConcurIterable
<Value
>
Returns
ConcurIterable
<Value
[]>