Server IP : 162.213.251.212 / Your IP : 3.15.18.198 [ Web Server : LiteSpeed System : Linux business55.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64 User : allssztx ( 535) PHP Version : 8.1.31 Disable Function : NONE Domains : 1 Domains MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /proc/self/root/proc/self/root/home/allssztx/www/easybuyer/node_modules/array-uniq/ |
Upload File : |
'use strict'; // there's 3 implementations written in increasing order of efficiency // 1 - no Set type is defined function uniqNoSet(arr) { var ret = []; for (var i = 0; i < arr.length; i++) { if (ret.indexOf(arr[i]) === -1) { ret.push(arr[i]); } } return ret; } // 2 - a simple Set type is defined function uniqSet(arr) { var seen = new Set(); return arr.filter(function (el) { if (!seen.has(el)) { seen.add(el); return true; } return false; }); } // 3 - a standard Set type is defined and it has a forEach method function uniqSetWithForEach(arr) { var ret = []; (new Set(arr)).forEach(function (el) { ret.push(el); }); return ret; } // V8 currently has a broken implementation // https://github.com/joyent/node/issues/8449 function doesForEachActuallyWork() { var ret = false; (new Set([true])).forEach(function (el) { ret = el; }); return ret === true; } if ('Set' in global) { if (typeof Set.prototype.forEach === 'function' && doesForEachActuallyWork()) { module.exports = uniqSetWithForEach; } else { module.exports = uniqSet; } } else { module.exports = uniqNoSet; }