UNPKG

topkat-utils

Version:

A comprehensive collection of TypeScript/JavaScript utility functions for common programming tasks. Includes validation, object manipulation, date handling, string formatting, and more. Zero dependencies, fully typed, and optimized for performance.

66 lines 2.46 kB
"use strict"; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.registerConfig = exports.configFn = void 0; var isset_1 = require("../isset"); var config = { env: 'development', isProd: false, nbOfLogsToKeep: 25, customTypes: {}, terminal: { noColor: false, theme: { primary: [0, 149, 250], shade1: [0, 90, 250], shade2: [0, 208, 245], paddingX: 2, paddingY: 2, pageWidth: 53, debugModeColor: [201, 27, 169], } }, }; /** Allow dynamic changing of config */ function configFn() { return config; } exports.configFn = configFn; /** Register custom config * @param {object} customConfig { 'email': email => /.+@.+/.test(email), type2 : myTestFunction() } * * env: 'development', * * customTypes: {}, * * terminal: { * * noColor: false, // disable colored escape sequences like /mOO35...etc * * theme: { * * primary: [61, 167, 32], // main color (title font) * * shade1: [127, 192, 39], // gradient shade 1 * * shade2: [194, 218, 47], // gradient shade 2 * * bgColor: false, // background color * * paddingX: 2, // nb spaces added before an outputted str * * paddingY: 2, // * * fontColor: false, // default font color * * pageWidth: 53, // page size in character * * debugModeColor: [147, 212, 6], // usually orange * * } * * }, */ function registerConfig(customConfig) { if (!(0, isset_1.isset)(customConfig.terminal)) customConfig.terminal = {}; var newconfig = __assign(__assign({}, config), customConfig); newconfig.terminal = __assign(__assign({}, config.terminal), customConfig.terminal); newconfig.terminal.theme = __assign(__assign({}, config.terminal.theme), (customConfig.terminal.theme || {})); config = newconfig; config.isProd = config.env.includes('prod'); } exports.registerConfig = registerConfig; //# sourceMappingURL=config.js.map