3 // there's 3 implementations written in increasing order of efficiency
5 // 1 - no Set type is defined
6 function uniqNoSet(arr) {
9 for (var i = 0; i < arr.length; i++) {
10 if (ret.indexOf(arr[i]) === -1) {
18 // 2 - a simple Set type is defined
19 function uniqSet(arr) {
21 return arr.filter(function (el) {
31 // 3 - a standard Set type is defined and it has a forEach method
32 function uniqSetWithForEach(arr) {
35 (new Set(arr)).forEach(function (el) {
42 // V8 currently has a broken implementation
43 // https://github.com/joyent/node/issues/8449
44 function doesForEachActuallyWork() {
47 (new Set([true])).forEach(function (el) {
54 if ('Set' in global) {
55 if (typeof Set.prototype.forEach === 'function' && doesForEachActuallyWork()) {
56 module.exports = uniqSetWithForEach;
58 module.exports = uniqSet;
61 module.exports = uniqNoSet;