UNPKG

@nent/core

Version:

Functional elements to add routing, data-binding, dynamic HTML, declarative actions, audio, video, and so much more. Supercharge static HTML files into web apps without script or builds.

101 lines (99 loc) 3.19 kB
/*! * NENT 2022 */ /* istanbul ignore file */ const prefix = '%cnent%c '; const colors = { log: [ 'color: white; background:#7566A0;font-weight: bold; font-size:10px; padding:2px 6px; border-radius: 5px', 'color: inherit; background:none;font-weight:normal', ], debug: [ 'color: white; background:#44883E;font-weight: bold; font-size:10px; padding:2px 6px; border-radius: 5px', 'color: inherit; background:none;font-weight:normal', ], warn: [ 'color: white; background:#ffc409;font-weight: bold; font-size:10px; padding:2px 6px; border-radius: 5px', 'color: inherit; background:none;font-weight:normal;color:#FDD757;', ], error: [ 'color: white; background:#eb445a;font-weight: bold; font-size:10px; padding:2px 6px; border-radius: 5px', 'color: inherit; background:none;font-weight:normal;color:red;', ], }; /** * It logs a message to the console with a prefix and a color * @param {string} message - The message to log. */ function log(message) { console.log(prefix + message, ...colors.log); } /** * It takes a string, prepends a prefix, and logs it to the console * @param {string} message - The message to be logged. */ function debug(message) { console.debug(prefix + message, ...colors.debug); } /** * It takes a string, prefixes it with a warning message, and prints it to the console * @param {string} warning - The warning message to be displayed. */ function warn(warning) { console.warn(prefix + warning, ...colors.warn); } /** * It takes an array of arguments and prints them to the console as a table * @param {any[]} args - any[] - The arguments to be logged. */ function table(args) { console.table(args); } /** * `dir` is a function that takes an array of arguments and logs them to the console * @param {any[]} args - any[] - The arguments passed to the function. */ function dir(args) { console.dir(args); } /** * It logs a message to the console, and if an error is passed in, it logs that too * @param {string} message - The message to be logged. * @param {Error} [error_] - The error object to be logged. */ function error(message, error_) { console.error(prefix + message, ...colors.error, error_); } /** * If the value is true, then warn the user with the message * @param {boolean} value - boolean * @param {any} message - The message to be logged. */ function warnIf(value, message) { if (value) { warn(message); } } /** * "If the value is true, log the message." * * The first parameter is a boolean value. The second parameter is a value of any type * @param {boolean} value - boolean - The value to check. If it's true, the message will be logged. * @param {any} message - The message to log. */ function logIf(value, message) { if (value) { log(message); } } /** * If the value is true, then log the message * @param {boolean} value - boolean - The value to check. If it's true, the message will be logged. * @param {any} message - The message to log. */ function debugIf(value, message) { if (value) { debug(message); } } export { dir as a, warnIf as b, logIf as c, debug as d, error as e, debugIf as f, log as l, table as t, warn as w };