Skip to content

keift/utils

Repository files navigation


Utils

Contents

About

Many useful tools.

Features

  • Colorful logs that include the time
  • Get Tailwind CSS's color palette in multiple formats
  • ANSI codes for colors in your terminals
  • Strict version of the Omit type

Installation

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/utils

Documentation

Tree

Briefly as follows.

@keift/utils

├── new Logger(options?)
   
   ├── info(message)
   ├── warn(message)
   └── error(message)

├── Colors

├── Styles

├── type LoggerOptions
└── type StrictOmit

Import

Briefly as follows.

import { Logger, Colors, Styles, type StrictOmit } from '@keift/utils';

Constructors

new Logger(options?)

Colorful logs that include the time.

Parameter Type Default Description
options? LoggerOptions LoggerOptionsDefault Constructor's options.

returns String

Example:

const Log = new Logger();
const ScopedLog = new Logger({ scope: 'Keift' });

Log.info('This is a info.'); // [2025-01-01 00:00:00 INF] This is a info.
Log.warn('This is a warn.'); // [2025-01-01 00:00:00 WRN] This is a warn.
Log.error('This is a error.'); // [2025-01-01 00:00:00 ERR] This is a error.

ScopedLog.info('This is a info.'); // Keift » [2025-01-01 00:00:00 INF] This is a info.
ScopedLog.warn('This is a warn.'); // Keift » [2025-01-01 00:00:00 WRN] This is a warn.
ScopedLog.error('This is a error.'); // Keift » [2025-01-01 00:00:00 ERR] This is a error.

Constants

Colors

Get 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

Use ANSI codes for colors in your terminals.

Example:

console.log(`${Styles.fg.red}This text is red`, Styles.reset);

Types

Type
LoggerOptions
StrictOmit

Links

License

MIT License

Copyright (c) 2025 Keift

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

Many useful tools.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors