blob: 62fffe7ccf8d7a5297a1392fe729bae9ad48f019 [file] [log] [blame] [edit]
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
}