1-liners
Version:
Useful oneliners and shorthand functions
16 lines (15 loc) • 319 B
JavaScript
/**
* @module 1-liners/uniq
*
* @description
*
* Creates a duplicate-free version of an array.
*
* @example
*
* const uniq = require('1-liners/uniq');
*
* uniq([1, 2, 2]); // => [1, 2]
*
*/
export default (array) => array.filter((value, index, self) => index === self.findIndex(other => other === value));