UNPKG

rambda

Version:

Lightweight and faster alternative to Ramda with included TS definitions

18 lines (15 loc) 336 B
export function intersperse(separator) { return list => { let index = -1 const len = list.length const willReturn = [] while (++index < len) { if (index === len - 1) { willReturn.push(list[index]) } else { willReturn.push(list[index], separator) } } return willReturn } }