rambdax
Version:
Extended version of Rambda - a lightweight, faster alternative to Ramda
18 lines (14 loc) • 375 B
JavaScript
export function intersperse(separator, list){
if (arguments.length === 1) return _list => intersperse(separator, _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
}