npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

console-ansi

v2.0.1

Published

Easy console coloring and prefixing via Proxy object with ANSI strings. Works in Node.js and in browsers that support ANSI strings.

Downloads

74

Readme

console-ansi

npm version stability-stable npm minzipped size dependencies types Conventional Commits styled with prettier linted with eslint license

Easy console coloring and prefixing via Proxy object with ANSI strings. Works in Node.js and in browsers that support ANSI strings.

paypal coinbase twitter

Installation

npm install console-ansi

Usage

import console, { styles } from "console-ansi";

// Set prefix
console.prefix = "[test]";

// Call the console object methods as usual
console.time("Test time");
console.log("Test log");
console.info("Test info");
console.warn("Test warn");
console.error("Test error");
console.timeEnd("Test time");

// Customise color
console.theme.log = styles.blue;
console.log("Test log blue");

// Remove symbols
console.symbol = {};

API

Modules

Typedefs

console-ansi

console-ansi.styles : ConsoleAnsiTheme

Basic ANSI escape codes map

Kind: static property of console-ansi See

console-ansi.default : ConsoleAnsi

Export a Proxy object to automatically style the console with ANSI strings.

Kind: static property of console-ansi

console-ansi.getConsole(options) ⇒ ConsoleAnsi

Get an instance of the Proxy-ed console. Useful if you need different prefixes for instance.

Kind: static method of console-ansi

| Param | Type | | ------- | ---------------------------------------- | | options | ConsoleAnsi |

ConsoleAnsi : object

Kind: global typedef Properties

| Name | Type | Default | Description | | --------- | ---------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | | [prefix] | string | """" | A string to prepend to every log. | | [theme] | ConsoleAnsiTheme | | Color definition associated to console methods. | | [level] | ConsoleAnsiLevel | "log" | A minimum log level value. See ConsoleAnsiLevels. | | [levels] | ConsoleAnsiLevels | { error: 5, warn: 4, info: 3, log: 2 } | Numbered priority associated to console methods to match above for level property. | | [symbol] | ConsoleAnsiSymbol | { log: "✔", info: "ℹ", warn: "⚠", error: "✖" } | Unicode symbols to prepend to defined console methods. | | [noColor] | boolean | false | Disable color ansi sequence. |

ConsoleAnsiThemeAttributeArray : Array.<number>

Array for ANSI definition [start, end].

Kind: global typedef

ConsoleAnsiTheme : Object.<string, ConsoleAnsiThemeAttributeArray> | Object.<string, Array.<ConsoleAnsiThemeAttributeArray>>

Theme object consisting of ANSI styles or Array of ANSI styles.

Kind: global typedef

ConsoleAnsiLevel : string

Current log level. Can be any console method but levels property only defines log(1)/info(2)/warn(3)/error(4).

Kind: global typedef

ConsoleAnsiLevels : Object.<ConsoleAnsiLevel, number>

Levels object consisting of console method as keys and numbered priority.

Kind: global typedef

ConsoleAnsiSymbol : Object.<string, string>

Map of unicode symbols to be prepended to certain console methods.

Kind: global typedef

License

MIT. See license file.