0
0
Fork 0
mirror of https://github.com/renovatebot/renovate.git synced 2025-03-15 08:34:54 +00:00
renovatebot_renovate/lib/util/assign-keys.ts
renovate[bot] 55845508b6
chore(deps): update eslint monorepo to v9 (major) (#33573)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2025-02-20 11:31:13 +00:00

18 lines
480 B
TypeScript

import is from '@sindresorhus/is';
/**
* Assigns non-nullish values from `right` to `left` for the given `keys`.
*/
export function assignKeys<
Left extends Partial<Record<K, unknown>>,
Right extends { [key in K]?: Left[key] },
K extends keyof Right,
>(left: Left, right: Right, keys: K[]): Left {
for (const key of keys) {
const val = right[key];
if (!is.nullOrUndefined(val)) {
left[key] = val as unknown as Left[typeof key];
}
}
return left;
}