UNPKG

downtimer

Version:
43 lines 1.34 kB
/** Default options for Downtimer */ export const 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. */ export 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