mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-22 14:39:34 +01:00
refactor: cleanup tags related code
This commit is contained in:
@@ -2,6 +2,13 @@ export function findItemAndDelete(array, predicate) {
|
||||
return deleteAtIndex(array, array.findIndex(predicate));
|
||||
}
|
||||
|
||||
export function addItem(array, item) {
|
||||
const index = array.indexOf(item);
|
||||
if (index > -1) return false;
|
||||
array.push(item);
|
||||
return true;
|
||||
}
|
||||
|
||||
export function deleteItem(array, item) {
|
||||
return deleteAtIndex(array, array.indexOf(item));
|
||||
}
|
||||
@@ -16,6 +23,10 @@ export function findById(array, id) {
|
||||
return array.find((item) => item.id === id);
|
||||
}
|
||||
|
||||
export function hasItem(array, item) {
|
||||
return array.indexOf(item) > -1;
|
||||
}
|
||||
|
||||
function deleteAtIndex(array, index) {
|
||||
if (index === -1) return false;
|
||||
array.splice(index, 1);
|
||||
|
||||
Reference in New Issue
Block a user