Many useful tools.
- Colorful logs that include the time
- Tailwind CSS's color palette in multiple formats
- ANSI codes for colors in your terminals
- Strict version of the Omit type
You can install it as follows.
# NPM
npm add @keift/utils
# PNPM
pnpm add @keift/utils
# Yarn
yarn add @keift/utils
# Bun
bun add @keift/utils
# Deno
deno add @keift/utilsBriefly as follows.
@keift/utils
│
├── new Logger(options?)
│ │
│ ├── info(message)
│ ├── warn(message)
│ └── error(message)
│
├── colors
│
└── styles
@keift/utils/types
│
├── type LoggerOptions
└── type StrictOmitBriefly as follows.
import { Logger, colors, styles } from '@keift/utils';
import type { StrictOmit } from '@keift/utils/types';new Logger(options?)
Colorful logs that include the time.
Parameter Type Default Description options?LoggerOptions logger_options Constructor's options. Example:
const logger = new Logger(); const scoped_logger = new Logger({ scope: 'Keift' }); logger.info('This is a info.'); // [2025-01-01 00:00:00 INF] This is a info. logger.warn('This is a warn.'); // [2025-01-01 00:00:00 WRN] This is a warn. logger.error('This is a error.'); // [2025-01-01 00:00:00 ERR] This is a error. scoped_logger.info('This is a info.'); // Keift » [2025-01-01 00:00:00 INF] This is a info. scoped_logger.warn('This is a warn.'); // Keift » [2025-01-01 00:00:00 WRN] This is a warn. scoped_logger.error('This is a error.'); // Keift » [2025-01-01 00:00:00 ERR] This is a error.
colors
Tailwind CSS's color palette in multiple formats.
Example:
console.log(colors.red['500']); /* { dec: 16460854, hex: 'fb2c36', hex8: 'fb2c36ff', rgb: '251, 44, 54', hsl: '356.95, 95.9%, 57.72%', oklch: '0.637, 0.237, 25.331' } */
styles
ANSI codes for colors in your terminals.
Example:
console.log(`${styles.fg.red}This text is red`, styles.reset);
| Type |
|---|
| LoggerOptions |
| StrictOmit |
