parent
768ef98f51
commit
8154fd4dbd
1 changed files with 10 additions and 6 deletions
@ -1,9 +1,13 @@ |
|||||||
const buildObjectStateSetterCallback = |
const buildObjectStateSetterCallback = |
||||||
<S extends Record<string, unknown>>(key: keyof S, value: S[keyof S]) => |
<S extends Record<string, unknown>>(key: keyof S, value?: S[keyof S]) => |
||||||
({ [key]: toReplace, ...restPrevious }: S): S => |
({ [key]: toReplace, ...restPrevious }: S): S => { |
||||||
({ |
const result = { ...restPrevious } as S; |
||||||
...restPrevious, |
|
||||||
[key]: value, |
if (value !== undefined) { |
||||||
} as S); |
result[key] = value; |
||||||
|
} |
||||||
|
|
||||||
|
return result; |
||||||
|
}; |
||||||
|
|
||||||
export default buildObjectStateSetterCallback; |
export default buildObjectStateSetterCallback; |
||||||
|
Loading…
Reference in new issue