feat: remove lodash dependency (#743)
Co-authored-by: Dominik Pschenitschni <mail@celement.de> Reviewed-on: https://kolaente.dev/vikunja/frontend/pulls/743 Reviewed-by: konrad <k@knt.li> Co-authored-by: dpschen <dpschen@noreply.kolaente.de> Co-committed-by: dpschen <dpschen@noreply.kolaente.de>
This commit is contained in:
@ -1,3 +0,0 @@
|
||||
export function findIndexById(array : [], id : string | number) {
|
||||
return array.findIndex(({id: currentId}) => currentId === id)
|
||||
}
|
22
src/helpers/utils.ts
Normal file
22
src/helpers/utils.ts
Normal file
@ -0,0 +1,22 @@
|
||||
export function findIndexById(array : [], id : string | number) {
|
||||
return array.findIndex(({id: currentId}) => currentId === id)
|
||||
}
|
||||
|
||||
export function includesById(array: [], id: string | number) {
|
||||
return array.some(({id: currentId}) => currentId === id)
|
||||
}
|
||||
|
||||
// https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_isnil
|
||||
export function isNil(value: any) {
|
||||
return value == null
|
||||
}
|
||||
|
||||
export function omitBy(obj: {}, check: (value: any) => Boolean): {} {
|
||||
if (isNil(obj)) {
|
||||
return {}
|
||||
}
|
||||
|
||||
return Object.fromEntries(
|
||||
Object.entries(obj).filter(([, value]) => !check(value)),
|
||||
)
|
||||
}
|
Reference in New Issue
Block a user