modern-api.styledlog
Version:
log content in custom css style based on
36 lines (32 loc) • 755 B
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
// index.ts
var output = (level, texts) => {
const text = texts.reduce(
(acc, [t]) => `${acc}${t}`,
""
);
console[level](text, ...texts.map(([_, style]) => style));
};
var styled = (styles) => {
return (text) => {
return [`%c${text}`, Object.keys(styles).reduce((acc, key) => `${key}:${styles[key]};${acc}`, "")];
};
};
var log = (...texts) => {
output("log", texts);
};
var warn = (...texts) => {
output("warn", texts);
};
var error = (...texts) => {
output("error", texts);
};
var debug = (...texts) => {
output("debug", texts);
};
exports.debug = debug;
exports.error = error;
exports.log = log;
exports.styled = styled;
exports.warn = warn;