Skip to main content
Home

@bearz/ansi@0.1.0
Built and signed on GitHub Actions

Works with
This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score100%
Published10 months ago (0.1.0)

A cross runtime library for emitting ansi styles and writing stylized messages to standard out. It falls back console.log if standard out is unavailable. Ansi styles are basically terminal colors.

Overview

The ansi module provides color detection, writing ansi codes, and an ansi writer.

logo

JSR npm version GitHub version

Documentation

Documentation is available on jsr.io

A list of other modules can be found at github.com/bearz-io/js

Usage

import { blue, writer, bgBlue, green, bold, apply } from "@bearz/ansi";

console.log(blue("test"));
console.log(green("success"));
writer.write("Hello, World!").writeLine();
writer.debug("Hello, World!");
writer.info("Hello, World!");
writer.success("Hello, World!");
writer.writeLine(apply("Hello, World!", bold, green, bgBlue) + " test");
writer.styleLine("Hello, World", bold, green);
writer.info("An informational message");
writer.writeLine(blue("My message"));
writer.writeLine(apply("Multiple Styles", bgBlue, bold));
writer.style("ok, ", blue);
writer.styleLine("success", green);

Notes

The core ansi functions in the styles module comes from Deno's @std/fmt/color with addition modififcations such as being less tied to deno and additional functions like apply and rgb24To8.

The detector module is heavily based on support color, but isn't a direct port.

The @bearz/process module is used for the writer class rather than console.log so that text is directly written to stdout and because stdout in that module abstracts the runtime specific stuff for deno, node, and bun.

License

Deno's MIT License

Support Colors MIT License

MIT License

Built and signed on
GitHub Actions

Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@bearz/ansi

Import symbol

import * as ansi from "@bearz/ansi";
or

Import directly with a jsr specifier

import * as ansi from "jsr:@bearz/ansi";

Add Package

pnpm i jsr:@bearz/ansi
or (using pnpm 10.8 or older)
pnpm dlx jsr add @bearz/ansi

Import symbol

import * as ansi from "@bearz/ansi";

Add Package

yarn add jsr:@bearz/ansi
or (using Yarn 4.8 or older)
yarn dlx jsr add @bearz/ansi

Import symbol

import * as ansi from "@bearz/ansi";

Add Package

vlt install jsr:@bearz/ansi

Import symbol

import * as ansi from "@bearz/ansi";

Add Package

npx jsr add @bearz/ansi

Import symbol

import * as ansi from "@bearz/ansi";

Add Package

bunx jsr add @bearz/ansi

Import symbol

import * as ansi from "@bearz/ansi";