UNPKG

rambda

Version:

Lightweight and faster alternative to Ramda with included TS definitions

32 lines (24 loc) 569 B
function includesWith(predicate, target, list) { let willReturn = false let index = -1 while (++index < list.length && !willReturn) { const value = list[index] if (predicate(target, value)) { willReturn = true } } return willReturn } export function uniqWith(predicate) { return list => { let index = -1 const willReturn = [] while (++index < list.length) { const value = list[index] if (!includesWith(predicate, value, willReturn)) { willReturn.push(value) } } return willReturn } }