joplin/ReactNativeClient/lib/ArrayUtils.js

16 lines
354 B
JavaScript
Raw Normal View History

2017-11-22 18:35:31 +00:00
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;
}
2017-11-22 18:35:31 +00:00
module.exports = ArrayUtils;