UNPKG

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.

26 lines 1.06 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.dictionaryOverwrite = void 0; const _debug_js_1 = require("../../debug/_debug.js"); const array_is_array_js_1 = require("../../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}. */ function dictionaryOverwrite(base, extension) { _BUILD.DEBUG && _debug_js_1._Debug.runBlock(() => { _debug_js_1._Debug.assert(!(0, array_is_array_js_1.arrayIsArray)(base) && !(0, array_is_array_js_1.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]; } } exports.dictionaryOverwrite = dictionaryOverwrite; //# sourceMappingURL=dictionary-overwrite.js.map