Skip to main content

Function: sliceConcur()

Returns a concur iterable containing the values of concurIterable between start and end (exclusive) of concurIterable in iteration order.

If any part of the range between start and end is outside the bounds of the concur iterable, then that part is excluded from the returned concur iterable. Thus, the returned concur iterable may be empty.

WARNING: This function linearly iterates up to end because concur iterables do not support random access.

Throws

if either start or end is not a non-negative integer, or if start is greater than end.

Example

const concurIterable = asConcur([`sloth`, `more sloth`, `even more sloth`])

console.log(
await pipe(
concurIterable,
sliceConcur(0, 3),
reduceConcur(toArray()),
),
)
//=> [ 'sloth', 'more sloth', 'even more sloth' ]

console.log(
await pipe(
concurIterable,
sliceConcur(0, 42),
reduceConcur(toArray()),
),
)
//=> [ 'sloth', 'more sloth', 'even more sloth' ]

console.log(
await pipe(
concurIterable,
sliceConcur(1, 3),
reduceConcur(toArray()),
),
)
//=> [ 'more sloth', 'even more sloth' ]

console.log(
await pipe(
concurIterable,
sliceConcur(3, 5),
reduceConcur(toArray()),
),
)
//=> []

Since

v3.5.0

Call Signature

sliceConcur<Start>(start): <End>(End) => <Value>(concurIterable) => ConcurIterable<Value><End, Value>(End, concurIterable) => ConcurIterable<Value>

Type Parameters

Start extends number

Parameters

start

NonNegativeInteger<Start>

Returns

Function

Type Parameters

End extends number

Parameters

End

NonNegativeInteger<End>

Returns

Function

Type Parameters

Value

Parameters
concurIterable

ConcurIterable<Value>

Returns

ConcurIterable<Value>

Type Parameters

End extends number

Value

Parameters

End

NonNegativeInteger<End>

concurIterable

ConcurIterable<Value>

Returns

ConcurIterable<Value>

Defined in

splices.d.ts:721

Call Signature

sliceConcur<Start, End>(start, End): <Value>(concurIterable) => ConcurIterable<Value>

Type Parameters

Start extends number

End extends number

Parameters

start

NonNegativeInteger<Start>

End

NonNegativeInteger<End>

Returns

Function

Type Parameters

Value

Parameters

concurIterable

ConcurIterable<Value>

Returns

ConcurIterable<Value>

Defined in

splices.d.ts:733

Call Signature

sliceConcur<Start, End, Value>(start, End, concurIterable): ConcurIterable<Value>

Type Parameters

Start extends number

End extends number

Value

Parameters

start

NonNegativeInteger<Start>

End

NonNegativeInteger<End>

concurIterable

ConcurIterable<Value>

Returns

ConcurIterable<Value>

Defined in

splices.d.ts:738