mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-03 08:35:29 +02:00
16 lines
354 B
JavaScript
16 lines
354 B
JavaScript
const ArrayUtils = {};
|
|
|
|
ArrayUtils.unique = function(array) {
|
|
return array.filter(function(elem, index, self) {
|
|
return index === self.indexOf(elem);
|
|
});
|
|
}
|
|
|
|
ArrayUtils.removeElement = function(array, element) {
|
|
const index = array.indexOf(element);
|
|
if (index < 0) return array;
|
|
array.splice(index, 1);
|
|
return array;
|
|
}
|
|
|
|
module.exports = ArrayUtils; |