mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2025-08-04 13:20:40 +08:00
18 lines
442 B
JavaScript
18 lines
442 B
JavaScript
export function findByName(list, name) {
|
|
return list.find((item) => item.name === name);
|
|
}
|
|
|
|
export function findIndexByName(list, name) {
|
|
return list.findIndex((item) => item.name === name);
|
|
}
|
|
|
|
export function deleteByName(list, name) {
|
|
const idx = findIndexByName(list, name);
|
|
list.splice(idx, 1);
|
|
}
|
|
|
|
export function updateByName(list, name, newItem) {
|
|
const idx = findIndexByName(list, name);
|
|
list[idx] = newItem;
|
|
}
|