Hanging protocol improvements on matching process and other improvements

This commit is contained in:
Eloízio Salgado committed 2017-03-02 10:18:11 -03:00
1 parent 744a0bd76e
commit 35b855de56
18 files changed
+881 -793

No files matched your search

@@ -0,0 +1,33 @@
import { _ } from 'meteor/underscore';
/**
* Removes the first instance of an element from an array, if an equal value exists
*
* @param array
* @param input
*
* @returns {boolean} Whether or not the element was found and removed
*/
const removeFromArray = (array, input) => {
// If the array is empty, stop here
if (!array ||
!array.length) {
return false;
}
array.forEach((value, index) => {
if (_.isEqual(value, input)) {
indexToRemove = index;
return false;
}
});
if (indexToRemove === void 0) {
return false;
}
array.splice(indexToRemove, 1);
return true;
};
export { removeFromArray };