Files
renovate/lib/util/assign-keys.ts
RahulGautamSingh 76f911041a refactor: use named exports (#39196)
* use named exports

* fix test

* add missing imnport

* fix prettier
2025-11-10 12:00:35 +00:00

19 lines
498 B
TypeScript

import { isNullOrUndefined } 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 (!isNullOrUndefined(val)) {
left[key] = val as unknown as Left[typeof key];
}
}
return left;
}