refactor: replace nullish .find() checks with .some()
This commit is contained in:
parent
1782e68984
commit
3782f7b4fe
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user