UNPKG

downtimer

Version:
47 lines 1.49 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.defaultOptions = void 0; exports.mergeDeepPartial = mergeDeepPartial; /** Default options for Downtimer */ exports.defaultOptions = { useColor: true, logConfig: { schedule: 'off', execute: { before: 'off', onError: 'full', }, clear: { notFound: 'minimal', success: 'off', allOutstanding: 'off', }, exitWithOutstandingTimers: 'minimal', }, }; /** * Merge a `DeepPartial<T>` object with a collection of defaults of type `T` * * If `T extends object`, then all properties are optional, and any value that is `undefined` in the * `options` will be replaced with the corresponding value in `defaults`. * * Otherwise, the object is considered to be a complete type, and so is only checked for * undefined-ness. */ function mergeDeepPartial(defaults, options) { if (options === undefined || options === null) { return defaults; } else if (typeof options !== 'object') { // `options` is definitely a value return options; } const result = structuredClone(defaults); for (const k of Object.keys(options)) { const key = k; // `options[key]` is a real value, despite TypeScript's protests result[key] = mergeDeepPartial(defaults[key], options[key]); } return result; } //# sourceMappingURL=options.js.map