blob: 157d1cd3800b5af9049203e5b1f254ec732bbc63 [file] [log] [blame]
Yang Guo4fd355c2019-09-19 08:59:031var baseUniq = require('./_baseUniq');
2
3/**
4 * Creates a duplicate-free version of an array, using
5 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
6 * for equality comparisons, in which only the first occurrence of each element
7 * is kept. The order of result values is determined by the order they occur
8 * in the array.
9 *
10 * @static
11 * @memberOf _
12 * @since 0.1.0
13 * @category Array
14 * @param {Array} array The array to inspect.
15 * @returns {Array} Returns the new duplicate free array.
16 * @example
17 *
18 * _.uniq([2, 1, 2]);
19 * // => [2, 1]
20 */
21function uniq(array) {
22 return (array && array.length) ? baseUniq(array) : [];
23}
24
25module.exports = uniq;