rc-js-util
Version:
A collection of TS and C++ utilities to help writing performant and correct applications, achieved through strict typing and (removable) invariant checking.
24 lines (22 loc) • 577 B
text/typescript
import { dictionaryOverwrite } from "./dictionary-overwrite.js";
/**
* @public
* Creates an object which is extended sequentially by two additional objects.
* @param base - The object to apply first.
* @param extension - The object to apply second.
*
* @remarks
* See {@link dictionaryCloneExtend}.
*/
export function dictionaryCloneExtend<T extends object, U extends object>
(
base: T,
extension: U
)
: T & U
{
const extended = {} as T & U;
dictionaryOverwrite(extended, base);
dictionaryOverwrite(extended, extension);
return extended;
}