Skip to main content
Module

x/rambda/source/intersperse.js

Faster and smaller alternative to Ramda
Go to Latest
File
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}