UNPKG

lenye_base

Version:

基础方法

12 lines (9 loc) 256 B
'use strict'; /** * Returns all unique values of an array, based on a provided comparator function. */ var uniqueBy = (arr, fn) => arr.reduce((acc, v) => { if (!acc.some(x => fn(v, x))) acc.push(v); return acc; }, []); module.exports = uniqueBy;