Skip to main content

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' ] ]

windowConcur(options)

windowConcur<Size>(options): <Value>(concurIterable) => ConcurIterable<Value[]>

Returns a concur iterable containing a rolling window of the values of concurIterable as arrays of length size.

Type Parameters

Size extends number

Parameters

options: WindowOptions<Size>

Returns

Function

Type Parameters

Value

Parameters

concurIterable: ConcurIterable<Value>

Returns

ConcurIterable<Value[]>

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' ] ]

Defined in

splices.d.ts:1094

windowConcur(options, concurIterable)

windowConcur<Size, Value>(options, concurIterable): ConcurIterable<Value[]>

Returns a concur iterable containing a rolling window of the values of concurIterable as arrays of length size.

Type Parameters

Size extends number

Value

Parameters

options: WindowOptions<Size>

concurIterable: ConcurIterable<Value>

Returns

ConcurIterable<Value[]>

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' ] ]

Defined in

splices.d.ts:1097