(src)
| 1285 | * @ignore |
| 1286 | */ |
| 1287 | var _unique = function (src) { |
| 1288 | if (Array.from && Set) { |
| 1289 | return Array.from(new Set(src)) |
| 1290 | } |
| 1291 | |
| 1292 | if (_areAllUnique(src)) { |
| 1293 | return src.slice() |
| 1294 | } |
| 1295 | |
| 1296 | // A faster unique method is to use object keys to identify used values, |
| 1297 | // but this doesn't work with arrays or objects, which we must also |
| 1298 | // consider. See jsperf.app/compare-array-unique-versions/4 for more |
| 1299 | // information. |
| 1300 | var out = [], |
| 1301 | val, |
| 1302 | i, |
| 1303 | ien = src.length, |
| 1304 | j, |
| 1305 | k = 0 |
| 1306 | |
| 1307 | again: for (i = 0; i < ien; i++) { |
| 1308 | val = src[i] |
| 1309 | |
| 1310 | for (j = 0; j < k; j++) { |
| 1311 | if (out[j] === val) { |
| 1312 | continue again |
| 1313 | } |
| 1314 | } |
| 1315 | |
| 1316 | out.push(val) |
| 1317 | k++ |
| 1318 | } |
| 1319 | |
| 1320 | return out |
| 1321 | } |
| 1322 | |
| 1323 | // Surprisingly this is faster than [].concat.apply |
| 1324 | // https://jsperf.com/flatten-an-array-loop-vs-reduce/2 |
no test coverage detected