mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
Deprecate API v2 (#7761)
* deprecate api-v2 * remove v2 test helpers * remove unused string
This commit is contained in:
22
website/server/libs/collectionManipulators.js
Normal file
22
website/server/libs/collectionManipulators.js
Normal file
@@ -0,0 +1,22 @@
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user