import { ensureArray } from "@thi.ng/arrays/ensure-array" ; import { illegalArgs } from "@thi.ng/errors/illegal-arguments" ; import { inRange } from "@thi.ng/math/interval" ; remarks `numLeft` defaults to 1 and `numRight` defaults to same value as
 * `numLeft`, therefore wraps both sides by default and throws error if
 * either `nXXX < 0` or larger than `src.length`.
 *
 * See also:
 * -  extendSides * -  padSides param src param numLeft param numRight export function * wrapSides < T > ( src , numLeft = 1 , numRight = numLeft ) { const _src = ensureArray ( src ) ; ! ( inRange ( numLeft , 0 , _src . length ) && inRange ( numRight , 0 , _src . length ) ) && illegalArgs ( `allowed wrap range: [0..${ _src . length }]` ) ; if ( numLeft > 0 ) { for ( let m = _src . length , i = m - numLeft ; i < m ; i ++ ) { yield _src [ i ] ; } } yield * _src ; if ( numRight > 0 ) { for ( let i = 0 ; i < numRight ; i ++ ) { yield _src [ i ] ; } } }