Initial commit
[yaffs-website] / node_modules / grunt-contrib-watch / node_modules / lodash / internal / sortedUniq.js
1 /**
2  * An implementation of `_.uniq` optimized for sorted arrays without support
3  * for callback shorthands and `this` binding.
4  *
5  * @private
6  * @param {Array} array The array to inspect.
7  * @param {Function} [iteratee] The function invoked per iteration.
8  * @returns {Array} Returns the new duplicate free array.
9  */
10 function sortedUniq(array, iteratee) {
11   var seen,
12       index = -1,
13       length = array.length,
14       resIndex = -1,
15       result = [];
16
17   while (++index < length) {
18     var value = array[index],
19         computed = iteratee ? iteratee(value, index, array) : value;
20
21     if (!index || seen !== computed) {
22       seen = computed;
23       result[++resIndex] = value;
24     }
25   }
26   return result;
27 }
28
29 module.exports = sortedUniq;