mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-07-31 19:20:25 +00:00
22 lines
426 B
JavaScript
22 lines
426 B
JavaScript
import {
|
|
findIndex,
|
|
isPlainObject,
|
|
} from 'lodash';
|
|
|
|
export function removeFromArray (array, element) {
|
|
let elementIndex;
|
|
|
|
if (isPlainObject(element)) {
|
|
elementIndex = findIndex(array, element);
|
|
} else {
|
|
elementIndex = array.indexOf(element);
|
|
}
|
|
|
|
if (elementIndex !== -1) {
|
|
let removedElement = array[elementIndex];
|
|
array.splice(elementIndex, 1);
|
|
return removedElement;
|
|
}
|
|
|
|
return false;
|
|
}
|