Home > @thi.ng/transducers > padSides
Returns iterator of src
padded with value x
, repeated numLeft
/numRight
times (default: 1). By default both sides are padded, but can be adjusted by setting either of them to zero. numRight
defaults to same value as numLeft
.
Signature:
padSides: <T>(src: Iterable<T>, x: T, numLeft?: number, numRight?: number) => IterableIterator<T>
Essentially, syntax sugar for:
// default
concat(repeat(x, numLeft), src, repeat(x, numRight))
// left only
concat(repeat(x, numLeft), src)
// right only
concat(src, repeat(x, numRight))