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

@poppinss/colors

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@poppinss/colors - npm Package Compare versions

Comparing version 1.0.6 to 1.1.0

build/src/Raw.d.ts

12

build/index.d.ts

@@ -1,2 +0,10 @@

export { Kleur as Colors } from './src/Kleur';
export { Stringify as FakeColors } from './src/Stringify';
import { Raw } from './src/Raw';
import { Kleur } from './src/Kleur';
import { Stringify } from './src/Stringify';
/**
* Returns the best colors instance based upon the tty
* and if in testing mode
*/
export declare function getBest(isTesting: boolean): Raw | Kleur | Stringify;
export { Kleur as Colors };
export { Stringify as FakeColors };

@@ -9,7 +9,23 @@ "use strict";

* file that was distributed with this source code.
*/
*/
Object.defineProperty(exports, "__esModule", { value: true });
var Kleur_1 = require("./src/Kleur");
exports.Colors = Kleur_1.Kleur;
var Stringify_1 = require("./src/Stringify");
exports.FakeColors = Stringify_1.Stringify;
exports.FakeColors = exports.Colors = exports.getBest = void 0;
const Raw_1 = require("./src/Raw");
const Kleur_1 = require("./src/Kleur");
Object.defineProperty(exports, "Colors", { enumerable: true, get: function () { return Kleur_1.Kleur; } });
const Stringify_1 = require("./src/Stringify");
Object.defineProperty(exports, "FakeColors", { enumerable: true, get: function () { return Stringify_1.Stringify; } });
/**
* Returns the best colors instance based upon the tty
* and if in testing mode
*/
function getBest(isTesting) {
if (isTesting) {
return new Stringify_1.Stringify();
}
if (require('color-support').level > 0) {
return new Kleur_1.Kleur();
}
return new Raw_1.Raw();
}
exports.getBest = getBest;

@@ -11,2 +11,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.Colors = void 0;
/**

@@ -13,0 +14,0 @@ * Base class extended by [[Kleur]] and [[Stringify]] classes to have

@@ -14,2 +14,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.Kleur = void 0;
const kleur_1 = __importDefault(require("kleur"));

@@ -16,0 +17,0 @@ const Base_1 = require("./Base");

@@ -11,2 +11,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.Stringify = void 0;
const Base_1 = require("./Base");

@@ -13,0 +14,0 @@ /**

35

package.json
{
"name": "@poppinss/colors",
"version": "1.0.6",
"version": "1.1.0",
"description": "A wrapper on top of kleur with ability to write test against the color functions",

@@ -18,2 +18,3 @@ "main": "build/index.js",

"compile": "npm run lint && npm run clean && tsc",
"format": "prettier --write .",
"build": "npm run compile",

@@ -31,16 +32,19 @@ "commit": "git-cz",

"devDependencies": {
"@adonisjs/mrm-preset": "^2.3.0",
"@types/node": "^13.13.4",
"commitizen": "^4.0.4",
"cz-conventional-changelog": "^3.1.0",
"del-cli": "^3.0.0",
"@adonisjs/mrm-preset": "^2.3.2",
"@types/node": "^14.0.14",
"commitizen": "^4.1.2",
"cz-conventional-changelog": "^3.2.0",
"del-cli": "^3.0.1",
"doctoc": "^1.4.0",
"eslint": "^6.8.0",
"eslint-plugin-adonis": "^1.0.9",
"eslint": "^7.3.1",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-adonis": "^1.0.12",
"eslint-plugin-prettier": "^3.1.4",
"husky": "^4.2.5",
"japa": "^3.0.1",
"mrm": "^2.2.1",
"np": "^5.2.1",
"ts-node": "^8.9.1",
"typescript": "^3.8.3"
"japa": "^3.1.1",
"mrm": "^2.3.3",
"np": "^6.2.4",
"prettier": "2.0.5",
"ts-node": "^8.10.2",
"typescript": "^3.9.5"
},

@@ -57,3 +61,3 @@ "nyc": {

"hooks": {
"pre-commit": "doctoc README.md --title='## Table of contents' && git add README.md",
"pre-commit": "npm run format && npm run lint && doctoc README.md --title='## Table of contents' && git add README.md",
"commit-msg": "node ./node_modules/@adonisjs/mrm-preset/validateCommit/conventional/validate.js"

@@ -72,3 +76,4 @@ }

"dependencies": {
"kleur": "^3.0.3"
"color-support": "^1.1.3",
"kleur": "^4.0.1"
},

@@ -75,0 +80,0 @@ "directories": {

<div align="center"><img src="https://res.cloudinary.com/adonisjs/image/upload/q_100/v1557762307/poppinss_iftxlt.jpg" width="600px"></div>
# Colors
> Wrapper on top of Kleur with support for testing color calls.

@@ -16,2 +17,3 @@

- [Usage](#usage)
- [Raw Implementation](#raw-implementation)

@@ -21,2 +23,3 @@ <!-- END doctoc generated TOC please keep comment here to allow auto update -->

## Why use this module?
Have you ever wonder, how to test the output of function calls like the following?

@@ -48,2 +51,3 @@

## Usage
Install the package from npm registry as follows:

@@ -76,12 +80,34 @@

## Raw Implementation
The `Raw` implementation exposes the same API as kleur, but does not apply any formatting/colors to the output string. You can use the raw implementation when the terminal does not support colors. For example:
```ts
import { Colors, Raw } from '@poppinss/colors'
import { level } from 'color-support'
const colors = level > 0 ? new Colors() : new Raw()
colors.red('hello world')
```
Finally, there is a method called `getBest` to get the best available implementation instance for your runtime.
```ts
import { getBest } from '@poppinss/colors'
const colors = getBest(false)
```
The `getBest` method returns following outputs
- An instance of [Raw](https://github.com/poppinss/colors/blob/develop/src/Raw.ts) when the terminal does not supports colors.
- An instance of [FakeColors](https://github.com/poppinss/colors/blob/develop/src/Stringify.ts) when the first argument passed to the method is `true`.
- Otherwise returns an instance of [Colors](https://github.com/poppinss/colors/blob/develop/src/Kleur.ts).
[circleci-image]: https://img.shields.io/circleci/project/github/poppinss/colors/master.svg?style=for-the-badge&logo=circleci
[circleci-url]: https://circleci.com/gh/poppinss/colors "circleci"
[circleci-url]: https://circleci.com/gh/poppinss/colors 'circleci'
[typescript-image]: https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript
[typescript-url]: "typescript"
[typescript-url]: "typescript"
[npm-image]: https://img.shields.io/npm/v/@poppinss/colors.svg?style=for-the-badge&logo=npm
[npm-url]: https://npmjs.org/package/@poppinss/colors "npm"
[npm-url]: https://npmjs.org/package/@poppinss/colors 'npm'
[license-image]: https://img.shields.io/npm/l/@poppinss/colors?color=blueviolet&style=for-the-badge
[license-url]: LICENSE.md "license"
[license-url]: LICENSE.md 'license'
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