@inquirer/core
Advanced tools
Comparing version 8.1.0 to 8.2.0
@@ -5,7 +5,31 @@ "use strict"; | ||
const theme_mjs_1 = require('./theme.js'); | ||
function isPlainObject(value) { | ||
if (typeof value !== 'object' || value === null) | ||
return false; | ||
let proto = value; | ||
while (Object.getPrototypeOf(proto) !== null) { | ||
proto = Object.getPrototypeOf(proto); | ||
} | ||
return Object.getPrototypeOf(value) === proto; | ||
} | ||
function deepMerge(...objects) { | ||
const output = {}; | ||
for (const obj of objects) { | ||
for (const [key, value] of Object.entries(obj)) { | ||
const prevValue = output[key]; | ||
output[key] = | ||
isPlainObject(prevValue) && isPlainObject(value) | ||
? deepMerge(prevValue, value) | ||
: value; | ||
} | ||
} | ||
return output; | ||
} | ||
function makeTheme(...themes) { | ||
return Object.assign({}, theme_mjs_1.defaultTheme, ...themes, { | ||
style: Object.assign({}, theme_mjs_1.defaultTheme.style, ...themes.map((theme) => theme === null || theme === void 0 ? void 0 : theme.style)), | ||
}); | ||
const themesToMerge = [ | ||
theme_mjs_1.defaultTheme, | ||
...themes.filter((theme) => theme != null), | ||
]; | ||
return deepMerge(...themesToMerge); | ||
} | ||
exports.makeTheme = makeTheme; |
{ | ||
"name": "@inquirer/core", | ||
"version": "8.1.0", | ||
"version": "8.2.0", | ||
"engines": { | ||
@@ -63,3 +63,3 @@ "node": ">=18" | ||
"@types/mute-stream": "^0.0.4", | ||
"@types/node": "^20.12.7", | ||
"@types/node": "^20.12.11", | ||
"@types/wrap-ansi": "^3.0.0", | ||
@@ -76,3 +76,3 @@ "ansi-escapes": "^4.3.2", | ||
"devDependencies": { | ||
"@inquirer/testing": "^2.1.18" | ||
"@inquirer/testing": "^2.1.19" | ||
}, | ||
@@ -100,3 +100,3 @@ "scripts": { | ||
}, | ||
"gitHead": "d0e92901ebb7eb77d027786a2e1ac41fc15326b6" | ||
"gitHead": "27d1c0ae9e88edbc9bebcf58901a5104022074a9" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
85108
1681
Updated@types/node@^20.12.11