@santi100/coloring-lib
Advanced tools
Comparing version 1.1.1 to 1.1.2
# Changelog | ||
# Version 1.1.1 | ||
- Modified and refined many things. | ||
## Version 1.1.1 | ||
- Modified and refined many things. | ||
## Version 1.1.2 | ||
- Added effects `italic` and `underline`. | ||
- Splitted the code into multiple modules (namely `colorize`, `colorizer`, `colorize-template`, `core`, `rainbowify`). | ||
- First introduced our brand-new `rainbowify` and `colorizeTemplate` functions! |
@@ -1,137 +0,6 @@ | ||
/** | ||
* A color to paint a string in. | ||
*/ | ||
declare type Color = 'black' | 'red' | 'green' | 'yellow' | 'blue' | 'magenta' | 'cyan' | 'white' | 'bold' | 'blink' | 'conceal'; | ||
/** | ||
* An effect you can give to a string. | ||
*/ | ||
declare type Effect = 'bold' | 'blink' | 'conceal'; | ||
/** | ||
* A valid color or effect. | ||
*/ | ||
declare type ColorOrEffect = Color | Effect; | ||
/** | ||
* An array of valid colors or effects. | ||
*/ | ||
declare type ArrayOfColorsOrEffects = ColorOrEffect[]; | ||
/** | ||
* Color `str` with color `color`. | ||
* | ||
* @param str The string to paint in color! | ||
* @param color The color to paint the string in. | ||
*/ | ||
export declare function coloring(str: string, color: ColorOrEffect): string; | ||
/** | ||
* Color `str` with colors `colors`. | ||
* | ||
* @param str The string to paint in color! | ||
* @param colors The colors to paint the string in. | ||
*/ | ||
export declare function coloring(str: string, colors: ArrayOfColorsOrEffects): string; | ||
/** | ||
* Colors `text` in a rainbow pattern. | ||
* | ||
* @param str The string to paint in color! | ||
* @returns The colored string. | ||
*/ | ||
export declare function rainbowify(str: string): string; | ||
/** | ||
* @class This is a colorizer class. | ||
*/ | ||
export declare class Colorizer { | ||
private __string; | ||
constructor(); | ||
/** | ||
* 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; | ||
} | ||
/** | ||
* @deprecated This is a deprecated alias for the `Colorizer` class. Use {@link Colorizer} instead. | ||
*/ | ||
export declare const Coloring: typeof Colorizer; | ||
export type { ArrayOfColorsOrEffects, ColorOrEffect, Color, Effect }; | ||
export * from './core'; | ||
export * from './colorize'; | ||
export * from './colorizer'; | ||
export * from './colorize-template'; | ||
export * from './rainbowify'; | ||
export { default } from './colorize'; |
246
cjs/index.js
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
exports.__esModule = true; | ||
exports.Coloring = exports.Colorizer = exports.rainbowify = exports.coloring = void 0; | ||
var assertion_lib_1 = require("@santi100/assertion-lib"); | ||
var 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', | ||
blink: '\x1b[5m', | ||
conceal: '\x1b[8m' | ||
}; | ||
function __keys(o) { | ||
if (Object === null || Object === void 0 ? void 0 : Object.keys) | ||
return Object.keys(o); | ||
else { | ||
var keys = []; | ||
for (var key in o) { | ||
keys.push(key); | ||
} | ||
return keys; | ||
} | ||
} | ||
/** | ||
* Color `str` with color(s) `color`. | ||
* | ||
* @param str The string to paint in color! | ||
* @param color The color(s) to paint the string in. | ||
*/ | ||
function coloring(str, color) { | ||
(0, assertion_lib_1.assertTypeOf)(str, 'string', 'str'); | ||
(0, assertion_lib_1.assertTypeOf)(color, 'string', 'color'); | ||
(0, assertion_lib_1.assertOneOf)(color, 'color', __keys(COLORS)); | ||
function generateFromArray(color) { | ||
var j = ''; | ||
for (var _i = 0, color_1 = color; _i < color_1.length; _i++) { | ||
var item = color_1[_i]; | ||
j += COLORS[item]; | ||
} | ||
j += "".concat(str, "\u001B[0m"); | ||
return j; | ||
} | ||
return typeof color === 'string' | ||
? "".concat(COLORS[color]).concat(str, "\u001B[0m") | ||
: generateFromArray(color); | ||
} | ||
exports.coloring = coloring; | ||
/** | ||
* Colors `text` in a rainbow pattern. | ||
* | ||
* @param str The string to paint in color! | ||
* @returns The colored string. | ||
*/ | ||
function rainbowify(str) { | ||
(0, assertion_lib_1.assertTypeOf)(str, 'string', 'text'); | ||
var colors = [ | ||
COLORS.red, | ||
COLORS.yellow, | ||
COLORS.green, | ||
COLORS.cyan, | ||
COLORS.blue, | ||
COLORS.magenta | ||
]; // red, orange, yellow, green, blue, magenta | ||
var letters = ''.concat(str).split(''); | ||
var coloredText = ''; | ||
var colorIndex = 0; | ||
for (var _i = 0, letters_1 = letters; _i < letters_1.length; _i++) { | ||
var element = letters_1[_i]; | ||
var letter = element; | ||
var color = colors[colorIndex]; | ||
coloredText += "".concat(color).concat(letter, "\u001B[0m"); | ||
colorIndex = (colorIndex + 1) % colors.length; | ||
} | ||
return coloredText; | ||
} | ||
exports.rainbowify = rainbowify; | ||
/** | ||
* @class This is a colorizer class. | ||
*/ | ||
var Colorizer = /** @class */ (function () { | ||
function Colorizer() { | ||
var _a; | ||
this.__string = ''; | ||
(_a = Object === null || Object === void 0 ? void 0 : Object.defineProperty) === null || _a === void 0 ? void 0 : _a.call(Object, this, '__string', { | ||
enumerable: false | ||
}); | ||
} | ||
/** | ||
* Paints `text` in black. | ||
* | ||
* @param text The text to paint in black. | ||
* @returns `this` object for chaining. | ||
*/ | ||
Colorizer.prototype.black = function (text) { | ||
this.__string = "".concat(this.__string).concat(COLORS.black).concat(text); | ||
return this; | ||
}; | ||
/** | ||
* Paints `text` in red. | ||
* | ||
* @param text The text to paint in red. | ||
* @returns `this` object for chaining. | ||
*/ | ||
Colorizer.prototype.red = function (text) { | ||
this.__string = "".concat(this.__string).concat(COLORS.red).concat(text); | ||
return this; | ||
}; | ||
/** | ||
* Paints `text` in green. | ||
* | ||
* @param text The text to paint in green. | ||
* @returns `this` object for chaining. | ||
*/ | ||
Colorizer.prototype.green = function (text) { | ||
this.__string = "".concat(this.__string).concat(COLORS.green).concat(text); | ||
return this; | ||
}; | ||
/** | ||
* Paints `text` in yellow. | ||
* | ||
* @param text The text to paint in yellow. | ||
* @returns `this` object for chaining. | ||
*/ | ||
Colorizer.prototype.yellow = function (text) { | ||
this.__string = "".concat(this.__string).concat(COLORS.yellow).concat(text); | ||
return this; | ||
}; | ||
/** | ||
* Paints `text` in blue. | ||
* | ||
* @param text The text to paint in blue. | ||
* @returns `this` object for chaining. | ||
*/ | ||
Colorizer.prototype.blue = function (text) { | ||
this.__string = "".concat(this.__string).concat(COLORS.blue).concat(text); | ||
return this; | ||
}; | ||
/** | ||
* Paints `text` in magenta. | ||
* | ||
* @param text The text to paint in magenta. | ||
* @returns `this` object for chaining. | ||
*/ | ||
Colorizer.prototype.magenta = function (text) { | ||
this.__string = "".concat(this.__string).concat(COLORS.magenta).concat(text); | ||
return this; | ||
}; | ||
/** | ||
* Paints `text` in cyan. | ||
* | ||
* @param text The text to paint in cyan. | ||
* @returns `this` object for chaining. | ||
*/ | ||
Colorizer.prototype.cyan = function (text) { | ||
this.__string = "".concat(this.__string).concat(COLORS.cyan).concat(text); | ||
return this; | ||
}; | ||
/** | ||
* Paints `text` in white. | ||
* | ||
* @param text The text to paint in white. | ||
* @returns `this` object for chaining. | ||
*/ | ||
Colorizer.prototype.white = function (text) { | ||
this.__string = "".concat(this.__string).concat(COLORS.white).concat(text); | ||
return this; | ||
}; | ||
/** | ||
* Makes `text` **bold**. | ||
* | ||
* @param text The text to make **bold**. | ||
* @returns `this` object for chaining. | ||
*/ | ||
Colorizer.prototype.bold = function (text) { | ||
this.__string = "".concat(this.__string).concat(COLORS.bold).concat(text); | ||
return this; | ||
}; | ||
/** | ||
* Makes `text` blink. | ||
* | ||
* @param text The text to make blink. | ||
* @returns `this` object for chaining. | ||
*/ | ||
Colorizer.prototype.blink = function (text) { | ||
this.__string = "".concat(this.__string).concat(COLORS.blink).concat(text); | ||
return this; | ||
}; | ||
/** | ||
* Conceals `text`. | ||
* | ||
* @param text The text to conceal. | ||
* @returns `this` object for chaining. | ||
*/ | ||
Colorizer.prototype.conceal = function (text) { | ||
this.__string = "".concat(this.__string).concat(COLORS.conceal).concat(text); | ||
return this; | ||
}; | ||
/** | ||
* Turns this object into the final string. | ||
* | ||
* @returns The string with all colors in this object. | ||
*/ | ||
Colorizer.prototype.toString = function () { | ||
return "".concat(this.__string, "\u001B[0m"); | ||
}; | ||
/** | ||
* Resolves the object to the final string. | ||
* @deprecated Use {@link Colorizer.prototype.toString} instead. | ||
*/ | ||
Colorizer.prototype.resolve = function () { | ||
((typeof console === 'undefined' ? function () { } : console.warn) || | ||
(typeof console === 'undefined' ? function () { } : console.log))('Coloring.prototype.resolve() is deprecated. Use Coloring.prototype.toString() instead.'); | ||
return this.toString(); | ||
}; | ||
return Colorizer; | ||
}()); | ||
exports.Colorizer = Colorizer; | ||
/** | ||
* @deprecated This is a deprecated alias for the `Colorizer` class. Use {@link Colorizer} instead. | ||
*/ | ||
exports.Coloring = Colorizer; | ||
exports["default"] = void 0; | ||
__exportStar(require("./core"), exports); | ||
__exportStar(require("./colorize"), exports); | ||
__exportStar(require("./colorizer"), exports); | ||
__exportStar(require("./colorize-template"), exports); | ||
__exportStar(require("./rainbowify"), exports); | ||
var colorize_1 = require("./colorize"); | ||
__createBinding(exports, colorize_1, "default"); |
@@ -1,2 +0,2 @@ | ||
# Code of Conduct | ||
# Contributor Covenant Code of Conduct | ||
@@ -8,4 +8,4 @@ ## My Pledge | ||
our community a harassment-free experience for everyone, regardless of age, body | ||
size, disability, ethnicity, level of experience, education, | ||
socio-economic status, nationality, personal appearance, race, | ||
size, disability, ethnicity, level of experience, education, | ||
socio-economic status, nationality, personal appearance, race, | ||
or religion. | ||
@@ -44,3 +44,3 @@ | ||
that are not aligned to this Code of Conduct, or to ban temporarily or | ||
permanently any contributor for other behaviors that I deem inappropriate, | ||
permanently any contributor for other behaviors that they deem inappropriate, | ||
threatening, offensive, or harmful. | ||
@@ -60,5 +60,8 @@ | ||
Instances of abusive, harassing, or otherwise unacceptable behavior may be | ||
reported by contacting me at <santyrojasprieto9+githubissues@gmail.com>. All complaints will be reviewed and investigated and will result in a response that | ||
is deemed necessary and appropriate to the circumstances. I will maintain confidentiality with regard to the reporter of an incident. | ||
Further details of specific enforcement policies may be posted separately. | ||
reported to me at [maintainer contact method]. | ||
All complaints will be reviewed and investigated promptly and fairly. | ||
I'm obligated to respect the privacy and security of the | ||
reporter of any incident. | ||
## Enforcement Guidelines | ||
@@ -74,3 +77,3 @@ | ||
**Consequence**: A private, written warning from me, providing | ||
**Consequence**: A private, written warning from community leaders, providing | ||
clarity around the nature of the violation and an explanation of why the | ||
@@ -117,10 +120,10 @@ behavior was inappropriate. A public apology may be requested. | ||
Community Impact Guidelines were inspired by | ||
Community Impact Guidelines were inspired by | ||
[Mozilla's code of conduct enforcement ladder][Mozilla CoC]. | ||
For answers to common questions about this code of conduct, see the FAQ at | ||
<https://www.contributor-covenant.org/faq>. Translations are available | ||
<https://www.contributor-covenant.org/faq>. Translations are available | ||
at <https://www.contributor-covenant.org/translations>. | ||
[homepage]: https://www.contributor-covenant.org | ||
[Mozilla CoC]: https://github.com/mozilla/diversity | ||
[Mozilla CoC]: https://github.com/mozilla/diversity |
@@ -5,7 +5,17 @@ # Contribute | ||
You can [file an issue](https://github.com/santi100a/equal-lib/issues) | ||
or a [pull request](https://github.com/santi100a/equal-lib/pulls). | ||
You can also [start a discussion](https://github.com/santi100a/equal-lib/discussions). | ||
You can [file an issue](https://github.com/<author>/<repo>/issues) | ||
or a [pull request](https://github.com/<author>/<repo>/pulls). | ||
You can also [start a discussion](https://github.com/<author>/<repo>/discussions). | ||
## Contribution rules | ||
You must comply with the [Code of Conduct](CODE_OF_CONDUCT.md) when doing contributions. | ||
You must comply with the [Code of Conduct](CODE_OF_CONDUCT.md) when doing contributions. | ||
## Types of accepted contributions and how to ask for them | ||
- Bug reports (issue/PR if you know how to fix it) | ||
- Feature requests (issue) | ||
- Code contributions (PR) | ||
- Documentation improvements (PR) | ||
**Please submit each PR independently, as I might want to merge some but not others.** |
@@ -0,4 +1,16 @@ | ||
/** | ||
* A color to paint a string in. | ||
*/ | ||
declare type Color = 'black' | 'red' | 'green' | 'yellow' | 'blue' | 'magenta' | 'cyan' | 'white' | 'bold' | 'blink' | 'conceal'; | ||
/** | ||
* An effect you can give to a string. | ||
*/ | ||
declare type Effect = 'bold' | 'blink' | 'conceal'; | ||
/** | ||
* A valid color or effect. | ||
*/ | ||
declare type ColorOrEffect = Color | Effect; | ||
/** | ||
* An array of valid colors or effects. | ||
*/ | ||
declare type ArrayOfColorsOrEffects = ColorOrEffect[]; | ||
@@ -5,0 +17,0 @@ /** |
{ | ||
"name": "@santi100/coloring-lib", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"repository": { | ||
"url": "https://github.com/santi100a/coloring-lib" | ||
"url": "https://github.com/santi100a/coloring-lib", | ||
"type": "git" | ||
}, | ||
"keywords": [ | ||
"coloring", "ansi", "escape-sequences", "es3" | ||
"coloring", | ||
"ansi", | ||
"escape-sequences", | ||
"es3" | ||
], | ||
"description": "Santi's Coloring Library: Make your text look really cool!", | ||
"main": "cjs/index.js", | ||
"module": "./index.js", | ||
"author": "santi100a <santyrojasprieto9+npmauthor@gmail.com>", | ||
"module": "./index.mjs", | ||
"license": "MIT", | ||
@@ -18,12 +23,26 @@ "dependencies": { | ||
"devDependencies": { | ||
"@types/jest": "^29.4.0", | ||
"jest": "^29.4.2", | ||
"typescript": "4.8.4" | ||
"@types/jest": "^29.4.1", | ||
"@typescript-eslint/eslint-plugin": "^5.59.0", | ||
"@typescript-eslint/parser": "^5.59.0", | ||
"eslint": "^8.39.0", | ||
"eslint-plugin-jest": "^27.2.1", | ||
"jest": "^29.4.3", | ||
"prettier": "^2.8.7", | ||
"remark-cli": "^11.0.0", | ||
"remark-gfm": "^3.0.1", | ||
"remark-validate-links": "^12.1.1", | ||
"typescript": "^4.9.5" | ||
}, | ||
"scripts": { | ||
"build": "tsc", | ||
"test": "jest", | ||
"build": "tsc", | ||
"dev": "tsc -w", | ||
"prettify": "prettier --write src/**/*.ts", | ||
"lint": "eslint src/**/*.ts", | ||
"esm-wrapper": "node scripts/esm-wrapper.js", | ||
"validate-package-json": "node scripts/validate-package-json.js", | ||
"lint-fix": "eslint --fix src/**/*.ts", | ||
"test:watch": "jest --watchAll", | ||
"dev": "tsc -w" | ||
"check-links": "remark --frail ." | ||
} | ||
} |
@@ -1,3 +0,4 @@ | ||
# Santi's Coloring Library | ||
[![Build Status](https://github.com/santi100a/coloring-lib/actions/workflows/test.yml/badge.svg)](https://github.com/santi100a/coloring-lib/actions) | ||
# Santi's Coloring Library | ||
[![Build Status](https://github.com/santi100a/coloring-lib/actions/workflows/ci.yml/badge.svg)](https://github.com/santi100a/coloring-lib/actions) | ||
[![npm homepage](https://img.shields.io/npm/v/@santi100/coloring-lib)](https://npmjs.org/package/@santi100/coloring-lib) | ||
@@ -8,11 +9,8 @@ [![GitHub stars](https://img.shields.io/github/stars/santi100a/coloring-lib.svg)](https://github.com/santi100a/coloring-lib) | ||
- 🚀 Lightweight and fast^ | ||
- 👴 ES3-compliant* | ||
- 🚀 Lightweight and fast[^](#disclaimers) | ||
- 👴 ES3-compliant[*](#disclaimers) | ||
- 💻 Portable between the browser and Node.js | ||
**Hasn't been tested in an actual ES3 environment. Feel free to open an issue or pull request if you find any non-ES3 thing. See "Contribute" for instructions on how to do so.* | ||
## What's this? | ||
*^The source code is about 2 kilobytes.* | ||
## What's this? | ||
This is a coloring library that uses ANSI sequences to color text on a terminal. | ||
@@ -25,3 +23,5 @@ Be aware there might be bugs hidden in this code. Pull requests and issues are welcome! | ||
Make sure you follow the [contribution Code of Conduct](https://github.com/santi100a/coloring-lib/blob/main/CODE_OF_CONDUCT.md). | ||
## Installation | ||
- Via NPM: `npm install @santi100/coloring-lib` | ||
@@ -33,5 +33,8 @@ - Via Yarn: `yarn add @santi100/coloring-lib` | ||
### Functions | ||
### Functions | ||
- `coloring(str: string, color: ColorOrEffect): string;` | ||
**The** `coloring` **function is a deprecated alias for the** `colorize` **function.** | ||
**Use** `colorize` **instead.** | ||
- `colorize(str: string, color: ColorOrEffect): string;` **NEW!** | ||
Color `str` with color `color`. | ||
@@ -42,7 +45,7 @@ | ||
| str | `string` | The string to paint in color. | | ||
| color | `ColorOrEffect` | The color to paint the string in. | | ||
| color | `ColorOrEffect` | The color to paint the string in. | | ||
Returns a string of the colored text. | ||
- `coloring(str: string, colors: ArrayOfColorsOrEffects): string;` | ||
- `colorize(str: string, colors: ArrayOfColorsOrEffects): string;` **NEW!** | ||
Color `str` with colors `colors`. | ||
@@ -52,34 +55,57 @@ | ||
|-----------|--------------------------|-----------------------------------------------| | ||
| `str` | `string` | The string to paint in color. | | ||
| `str` | `string` | The string to paint in color. | | ||
| `colors` | `ArrayOfColorsOrEffects` | The colors to paint the string in. | | ||
Returns a string of the colored text. | ||
- `rainbowify(str: string): string;` | ||
- `rainbowify(str: string): string;` **NEW!** | ||
Colors `str` in a rainbow pattern. | ||
| Parameter | Type | Description | | ||
| Parameter | Type | Description | | ||
|-----------|-------------------------|----------------------------------------------| | ||
| `str` | `string` | The string to paint in color. | ||
| `str` | `string` | The string to paint in color. | | ||
Returns a string of the rainbow colored text. | ||
- `function colorizeTemplate(template: string): string;` **NEW!** | ||
Fills `template`, given that it is a template like this: | ||
```colortemp | ||
text %color,effect(more text) and more text | ||
``` | ||
| Parameter | Type | Description | | ||
|----------------|-------------------------|----------------------------------------------| | ||
| `template` | `string` | The template string to fill. | | ||
Returns the template string with all placeholders replaced with the correct colors or effects. | ||
### Classes | ||
- `class Colorizer`: This is a colorizer object class. | ||
Its instance methods are called the same as the colors/effects, and you can chain them. | ||
- `class Colorizer`: This is a colorizer object class. | ||
Its instance methods are called the same as the colors/effects, and you can chain them. | ||
To convert the object to a string, call the `Colorizer.prototype.toString()` method. | ||
`Colorizer.prototype.resolve()` **is a deprecated alias for** `Colorizer.prototype.toString()`. | ||
`Colorizer.prototype.resolve()` **is a deprecated alias for** `Colorizer.prototype.toString()`. | ||
**Use** `Colorizer.prototype.toString()` **instead.** | ||
**The** `Coloring` **class is a deprecated alias for the** `Colorizer` **class.** | ||
**The** `Coloring` **class is a deprecated alias for the** `Colorizer` **class.** | ||
**Use** `Colorizer` **instead.** | ||
## Types | ||
- `type Color = 'black' | 'red' | 'green' | 'yellow' | 'blue' | 'magenta' | 'cyan' | 'white' | 'bold' | 'blink' | 'conceal';` | ||
A color to paint a string in. | ||
- `type Effect = 'bold' | 'blink' | 'conceal';` | ||
An effect you can give to a string. | ||
### Types | ||
- `type Color = 'black' | 'red' | 'green' | 'yellow' | 'blue' | 'magenta' | 'cyan' | 'white';` | ||
A color to paint a string in. | ||
- `type Effect = 'bold' | 'blink' | 'conceal' | 'italic' | 'underline';` | ||
An effect you can give to a string. | ||
**NEW!** Italic and underline were introduced in version 1.1.2. | ||
- `type ColorOrEffect = Color | Effect;` | ||
A valid color or effect. | ||
A valid color or effect. | ||
- `type ArrayOfColorsOrEffects = ColorOrEffect[];` | ||
An array of valid colors or effects. | ||
An array of valid colors or effects. | ||
## Disclaimers | ||
**Hasn't been tested in an actual ES3 environment. Feel free to open an issue or pull request if you find any non-ES3 thing. See "Contribute" for instructions on how to do so.* | ||
*^The source code is about 2 kilobytes.* |
@@ -5,5 +5,29 @@ # Security Policy | ||
To report a vulnerability, you can [file an issue](https://github.com/santi100a/equal-lib/issues) | ||
or a [pull request](https://github.com/santi100a/equal-lib/pulls). You can also [start a discussion](https://github.com/santi100a/equal-lib/discussions). | ||
**First see the [Code of Conduct](CODE_OF_CONDUCT.md) and [Contribution instructions](CONTRIBUTING.md)!** | ||
**First see the [Code of Conduct](CODE_OF_CONDUCT.md) and [Contribution instructions](CONTRIBUTE.md)!** | ||
If you believe you have discovered a security vulnerability in this project, please email me at <santyprojasprieto9+githubissues@gmail.com>. Please include a detailed description of the vulnerability and steps to reproduce it, along with any relevant information on the environment and configuration where the vulnerability was discovered. Please do not disclose the vulnerability publicly until it has been addressed by me. | ||
## Scope | ||
This security policy applies to all versions of the project, including any pre-release or beta versions. I will make reasonable efforts to address vulnerabilities in a timely manner, but I can make no guarantees whatsoever regarding the timeline or process for addressing vulnerabilities. | ||
## Responsible Disclosure | ||
I am committed to addressing security vulnerabilities in a responsible manner, and will follow the principles of responsible disclosure: | ||
- I will acknowledge receipt of your vulnerability report as soon as possible. | ||
- I will provide an estimated timeline for addressing the vulnerability and keep you informed of any changes to the timeline. | ||
- I will provide credit to you in the release notes for any vulnerability that you report, unless you prefer to remain anonymous. | ||
- I will not take legal action against you or disclose your identity to any third party without your consent, unless required by law. | ||
## Vulnerability Severity | ||
I will evaluate the severity of reported vulnerabilities. The severity of the vulnerability will determine the priority for addressing it. | ||
## Patching | ||
I will try my best to provide patches for all vulnerabilities that are confirmed and accepted. I will make reasonable efforts to provide patches in a timely manner, and will prioritize high-severity vulnerabilities. I may provide workarounds or mitigation advice in cases where a patch is not immediately available. | ||
## Public Disclosure | ||
I will coordinate with you to determine an appropriate timeline for public disclosure of the vulnerability, taking into account the severity of the vulnerability, the availability of patches, and any other relevant factors. I will make a best effort to release a patch for the vulnerability before publicly disclosing it, and will coordinate with other affected parties if necessary. |
{ | ||
"include": ["src/*.ts"], | ||
"exclude": [], | ||
"compilerOptions": { | ||
"declaration": true, | ||
"target": "ES3", | ||
"strict": true, | ||
"module": "commonjs", | ||
"noImplicitAny": true, | ||
"noImplicitThis": true, | ||
"strictNullChecks": true, | ||
"strictFunctionTypes": true, | ||
"outDir": "cjs/", | ||
"noImplicitAny": true | ||
} | ||
"declaration": true, | ||
"target": "es3", | ||
}, | ||
"include": ["src/**/*.ts"], | ||
"exclude": ["node_modules"] | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
307554
35
8190
1
107
0
11
1