Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@santi100/coloring-lib

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@santi100/coloring-lib - npm Package Compare versions

Comparing version 1.0.7 to 1.1.0

cjs/index.js

133

cjs/index.d.ts

@@ -1,35 +0,110 @@

declare type Color = 'black' | 'red' | 'green' | 'yellow' | 'blue' | 'magenta' | 'cyan' | 'white' |
'bold' | 'blink' | 'conceal';
declare type Effect = 'bold' | 'blink' | 'conceal';
declare type Parameter = Color | Effect;
declare type ParameterArray = Parameter[];
type Color = 'black' | 'red' | 'green' | 'yellow' | 'blue' | 'magenta' | 'cyan' | 'white' | 'bold' | 'blink' | 'conceal';
type Effect = 'bold' | 'blink' | 'conceal';
type Parameter = Color | Effect;
type ParameterArray = Parameter[];
/**
*
* @param string The string to paint in color!
* @param color The color to paint the string in.
* Color `string` with color(s) `color`.
*
* @param string The string to paint in color!
* @param color The colors to paint the string in.
*/
declare function coloring(string: string, color: Color): string;
declare function coloring(str: string, color: ParameterArray | Parameter): string;
/**
*
* @param string The string to paint in color!
* @param color The colors to paint the string in.
* @class This is a colorizer class.
*/
declare function coloring(string: string, color: ParameterArray): string;
declare class Coloring {
black(text: string): Coloring;
red(text: string): Coloring;
green(text: string): Coloring;
yellow(text: string): Coloring;
blue(text: string): Coloring;
magenta(text: string): Coloring;
cyan(text: string): Coloring;
white(text: string): Coloring;
bold(text: string): Coloring;
blink(text: string): Coloring;
conceal(text: string): Coloring;
declare class Colorizer {
private _colors;
/**
* Paints `text` in black.
*
* @param text The text to paint in black.
* @returns `this` object for chaining.
*/
black(text: string): this;
/**
* Paints `text` in red.
*
* @param text The text to paint in red.
* @returns `this` object for chaining.
*/
red(text: string): this;
/**
* Paints `text` in green.
*
* @param text The text to paint in green.
* @returns `this` object for chaining.
*/
green(text: string): this;
/**
* Paints `text` in yellow.
*
* @param text The text to paint in yellow.
* @returns `this` object for chaining.
*/
yellow(text: string): this;
/**
* Paints `text` in blue.
*
* @param text The text to paint in blue.
* @returns `this` object for chaining.
*/
blue(text: string): this;
/**
* Paints `text` in magenta.
*
* @param text The text to paint in magenta.
* @returns `this` object for chaining.
*/
magenta(text: string): this;
/**
* Paints `text` in cyan.
*
* @param text The text to paint in cyan.
* @returns `this` object for chaining.
*/
cyan(text: string): this;
/**
* Paints `text` in white.
*
* @param text The text to paint in white.
* @returns `this` object for chaining.
*/
white(text: string): this;
/**
* Makes `text` **bold**.
*
* @param text The text to make **bold**.
* @returns `this` object for chaining.
*/
bold(text: string): this;
/**
* Makes `text` blink.
*
* @param text The text to make blink.
* @returns `this` object for chaining.
*/
blink(text: string): this;
/**
* Conceals `text`.
*
* @param text The text to conceal.
* @returns `this` object for chaining.
*/
conceal(text: string): this;
/**
* Turns this object into the final string.
*
* @returns The string with all colors in this object.
*/
toString(): string;
/**
* Resolves the object to the final string.
* @deprecated Use {@link Colorizer.prototype.toString} instead.
*/
resolve(): string;
}
export { coloring, Coloring, type Color, type Effect, type Parameter, type ParameterArray };
export default coloring;
/**
* @deprecated Use {@link Colorizer} instead.
*/
declare const Coloring: typeof Colorizer;
export { coloring, Colorizer, Coloring };
{
"name": "@santi100/coloring-lib",
"version": "1.0.5",
"repository": {
"url": "https://github.com/santi100a/coloring-lib"
},
"main": "index.cjs",
"license": "MIT",
"dependencies": {
"@santi100/assertion-lib": "^1.0.3"
}
"main": "index.js",
"type": "commonjs",
"license": "MIT"
}

@@ -1,35 +0,110 @@

declare type Color = 'black' | 'red' | 'green' | 'yellow' | 'blue' | 'magenta' | 'cyan' | 'white' |
'bold' | 'blink' | 'conceal';
declare type Effect = 'bold' | 'blink' | 'conceal';
declare type Parameter = Color | Effect;
declare type ParameterArray = Parameter[];
type Color = 'black' | 'red' | 'green' | 'yellow' | 'blue' | 'magenta' | 'cyan' | 'white' | 'bold' | 'blink' | 'conceal';
type Effect = 'bold' | 'blink' | 'conceal';
type Parameter = Color | Effect;
type ParameterArray = Parameter[];
/**
*
* @param string The string to paint in color!
* @param color The color to paint the string in.
* Color `string` with color(s) `color`.
*
* @param string The string to paint in color!
* @param color The colors to paint the string in.
*/
declare function coloring(string: string, color: Color): string;
declare function coloring(str: string, color: ParameterArray | Parameter): string;
/**
*
* @param string The string to paint in color!
* @param color The colors to paint the string in.
* @class This is a colorizer class.
*/
declare function coloring(string: string, color: ParameterArray): string;
declare class Coloring {
black(text: string): Coloring;
red(text: string): Coloring;
green(text: string): Coloring;
yellow(text: string): Coloring;
blue(text: string): Coloring;
magenta(text: string): Coloring;
cyan(text: string): Coloring;
white(text: string): Coloring;
bold(text: string): Coloring;
blink(text: string): Coloring;
conceal(text: string): Coloring;
declare class Colorizer {
private _colors;
/**
* Paints `text` in black.
*
* @param text The text to paint in black.
* @returns `this` object for chaining.
*/
black(text: string): this;
/**
* Paints `text` in red.
*
* @param text The text to paint in red.
* @returns `this` object for chaining.
*/
red(text: string): this;
/**
* Paints `text` in green.
*
* @param text The text to paint in green.
* @returns `this` object for chaining.
*/
green(text: string): this;
/**
* Paints `text` in yellow.
*
* @param text The text to paint in yellow.
* @returns `this` object for chaining.
*/
yellow(text: string): this;
/**
* Paints `text` in blue.
*
* @param text The text to paint in blue.
* @returns `this` object for chaining.
*/
blue(text: string): this;
/**
* Paints `text` in magenta.
*
* @param text The text to paint in magenta.
* @returns `this` object for chaining.
*/
magenta(text: string): this;
/**
* Paints `text` in cyan.
*
* @param text The text to paint in cyan.
* @returns `this` object for chaining.
*/
cyan(text: string): this;
/**
* Paints `text` in white.
*
* @param text The text to paint in white.
* @returns `this` object for chaining.
*/
white(text: string): this;
/**
* Makes `text` **bold**.
*
* @param text The text to make **bold**.
* @returns `this` object for chaining.
*/
bold(text: string): this;
/**
* Makes `text` blink.
*
* @param text The text to make blink.
* @returns `this` object for chaining.
*/
blink(text: string): this;
/**
* Conceals `text`.
*
* @param text The text to conceal.
* @returns `this` object for chaining.
*/
conceal(text: string): this;
/**
* Turns this object into the final string.
*
* @returns The string with all colors in this object.
*/
toString(): string;
/**
* Resolves the object to the final string.
* @deprecated Use {@link Colorizer.prototype.toString} instead.
*/
resolve(): string;
}
export { coloring, Coloring, type Color, type Effect, type Parameter, type ParameterArray };
export default coloring;
/**
* @deprecated Use {@link Colorizer} instead.
*/
declare const Coloring: typeof Colorizer;
export { coloring, Colorizer, Coloring };

@@ -1,83 +0,4 @@

// @ts-check
/// <reference path="index.d.ts" />
import { assert, assertType } from '@santi100/assertion-lib';
const COLORS = {
black: "\x1b[30m",
red: "\x1b[31m",
green: "\x1b[32m",
yellow: "\x1b[33m",
blue: "\x1b[34m",
magenta: "\x1b[35m",
cyan: "\x1b[36m",
white: "\x1b[37m",
bold: "\x1b[1m"
}
import def from './cjs/index.js';
function coloring(string, color) {
assert(typeof color === 'string' || Array.isArray(color), {
expected: true,
actual: typeof color === 'string' || Array.isArray(color),
operator: 'Array.isArray()'
});
if (typeof color === 'string')
return `${COLORS[color.toLowerCase()]}${string}\x1b[0m`;
else {
let str = '';
color.forEach(element => {
str = str.concat(COLORS[element.toLowerCase()])
});
str = str.concat('\x1b[0m');
return str;
}
}
class Coloring {
__colors__ = ''
black(text) {
this.__colors__ = `${this.__colors__}${COLORS.black}${text}`;
return this;
}
red(text) {
this.__colors__ = `${this.__colors__}${COLORS.red}${text}`;
return this;
}
green(text) {
this.__colors__ = `${this.__colors__}${COLORS.green}${text}`;
return this;
}
yellow(text) {
this.__colors__ = `${this.__colors__}${COLORS.yellow}${text}`;
return this;
}
blue(text) {
this.__colors__ = `${this.__colors__}${COLORS.blue}${text}`;
return this;
}
magenta(text) {
this.__colors__ = `${this.__colors__}${COLORS.magenta}${text}`;
return this;
}
cyan(text) {
this.__colors__ = `${this.__colors__}${COLORS.cyan}${text}`;
return this;
}
white(text) {
this.__colors__ = `${this.__colors__}${COLORS.white}${text}`;
return this;
}
bold(text) {
this.__colors__ = `${this.__colors__}${COLORS.bold}${text}`;
return this;
}
blink(text) {
this.__colors__ = `${this.__colors__}${COLORS.blink}${text}`;
return this;
}
conceal(text) {
this.__colors__ = `${this.__colors__}${COLORS.conceal}${text}`;
return this;
}
resolve() {
return `${this.__colors__}\x1b[0m`;
}
}
export { coloring, Coloring };
export const coloring = def.coloring;
export const Coloring = def.Coloring;
{
"name": "@santi100/coloring-lib",
"version": "1.0.7",
"version": "1.1.0",
"repository": {

@@ -8,7 +8,18 @@ "url": "https://github.com/santi100a/coloring-lib"

"main": "index.js",
"license": "Other",
"license": "MIT",
"dependencies": {
"@santi100/assertion-lib": "^1.0.3"
},
"type": "module"
"type": "module",
"devDependencies": {
"@types/jest": "^29.4.0",
"jest": "^29.4.2",
"typescript": "^4.9.5"
},
"scripts": {
"test": "jest",
"build": "tsc",
"test:watch": "jest --watchAll",
"dev": "tsc -w"
}
}
# Santi's Coloring Library (JavaScript)
[![Build Status](https://github.com/santi100a/coloring-lib/actions/workflows/main.yml/badge.svg)](https://github.com/santi100a/santitools-python/actions)
[![GitHub stars](https://img.shields.io/github/stars/santi100a/coloring-lib.svg)](https://github.com/santi100a/santitools-python)
[![License](https://img.shields.io/github/license/santi100a/coloring-lib.svg)](https://github.com/santi100a/santitools-python)

@@ -3,0 +6,0 @@ This is a coloring library that uses ANSI sequences to color text on a terminal.

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc