1
0
mirror of https://github.com/thangisme/notes.git synced 2024-11-09 07:37:34 -05:00
notes/node_modules/array-unique/index.js
Patrick Marsceill b7b0d0d7bf
Initial commit
2017-03-09 13:16:08 -05:00

29 lines
512 B
JavaScript
Executable File

/*!
* array-unique <https://github.com/jonschlinkert/array-unique>
*
* Copyright (c) 2014-2015, Jon Schlinkert.
* Licensed under the MIT License.
*/
'use strict';
module.exports = function unique(arr) {
if (!Array.isArray(arr)) {
throw new TypeError('array-unique expects an array.');
}
var len = arr.length;
var i = -1;
while (i++ < len) {
var j = i + 1;
for (; j < arr.length; ++j) {
if (arr[i] === arr[j]) {
arr.splice(j--, 1);
}
}
}
return arr;
};