refactor: replace nullish .find() checks with .some()

This commit is contained in:
axel 2025-04-21 00:39:05 +02:00
parent 1782e68984
commit 3782f7b4fe
3 changed files with 4 additions and 4 deletions

View File

@ -21,7 +21,7 @@ export class LowDeviceRepo implements IDeviceRepo {
} }
async create(device: New<Device>): Promise<DeviceError | undefined> { async create(device: New<Device>): Promise<DeviceError | undefined> {
if (this.db.data.devices.find((d) => d.name === device.name)) { if (this.db.data.devices.some((d) => d.name === device.name)) {
return DeviceErrors.DUPLICATE_NAME; return DeviceErrors.DUPLICATE_NAME;
} }
@ -33,7 +33,7 @@ export class LowDeviceRepo implements IDeviceRepo {
} }
async update(device: Updated<Device>): Promise<DeviceError | undefined> { async update(device: Updated<Device>): Promise<DeviceError | undefined> {
if (this.db.data.devices.find((d) => d.name === device.name && d.id !== device.id)) { if (this.db.data.devices.some((d) => d.name === device.name && d.id !== device.id)) {
return DeviceErrors.DUPLICATE_NAME; return DeviceErrors.DUPLICATE_NAME;
} }

View File

@ -21,7 +21,7 @@ export class LowGroupRepo implements IGroupRepo {
} }
async create(group: New<Group>): Promise<GroupError | undefined> { async create(group: New<Group>): Promise<GroupError | undefined> {
if (this.db.data.groups.find((g) => g.name === group.name)) { if (this.db.data.groups.some((g) => g.name === group.name)) {
return GroupErrors.DUPLICATE_NAME; return GroupErrors.DUPLICATE_NAME;
} }

View File

@ -51,7 +51,7 @@ export class LowUserRepo implements IUserRepo {
} }
async update(user: Updated<User>) { async update(user: Updated<User>) {
if (this.db.data.users.find((u) => u.name == user.name && u.id != user.id)) { if (this.db.data.users.some((u) => u.name == user.name && u.id != user.id)) {
return UserErrors.DUPLICATE_NAME; return UserErrors.DUPLICATE_NAME;
} }