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.
22 lines • 811 B
JavaScript
import { _Debug } from "../../debug/_debug.js";
import { arrayIsArray } from "../../array/impl/array-is-array.js";
/**
* @public
* Modifies an object to include the keys and values of another.
* @param base - The object to be modified, must be a superset of extension.
* @param extension - The object to be applied to `base`.
*
* @remarks
* See {@link dictionaryOverwrite}.
*/
export function dictionaryOverwrite(base, extension) {
_BUILD.DEBUG && _Debug.runBlock(() => {
_Debug.assert(!arrayIsArray(base) && !arrayIsArray(extension), "should not be used with arrays");
});
const keys = Object.keys(extension);
for (let i = 0, l = keys.length; i < l; ++i) {
const key = keys[i];
base[key] = extension[key];
}
}
//# sourceMappingURL=dictionary-overwrite.js.map