UNPKG

@microsoft.azure/autorest.incubator

Version:
32 lines 1.2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const dictionary_1 = require("../common/dictionary"); /** inheriting from Initializer adds an apply<T> method to the class, allowing you to accept an object initalizer, and applying it to the class in the constructor. */ class Initializer { applyTo(source, target) { for (const i of dictionary_1.keys(source)) { switch (typeof source[i]) { // case 'function': // don't copy functions. //continue; case 'object': // merge objects if (source[i] != null && source[i] != undefined && typeof target[i] === 'object') { this.applyTo(source[i], target[i]); continue; } default: // everything else just replace. target[i] = source[i]; continue; } } } apply(initializer) { if (initializer) { this.applyTo(initializer, this); } } } exports.Initializer = Initializer; //# sourceMappingURL=initializer.js.map