Skip to main content
Home
This package has been archived, and as such it is read-only.

@ph/printer@1.0.6
Built and signed on GitHub Actions

latest

Provides a fluent interface for configuring printer options including styling, colors, and output behavior.

This package works with Node.js, Deno, BunIt is unknown whether this package works with Cloudflare Workers, Browsers
It is unknown whether this package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
It is unknown whether this package works with Browsers
JSR Score
100%
Published
a year ago (1.0.6)

Printer

A TypeScript library for styled console output with a fluent builder interface.

Installation

import { PrinterBuilder, type Method, type ColorType, type Callable } from "@ph/printer";

Features

  • Fluent builder interface for printer configuration
  • RGB foreground and background colors support
  • Text styling (bold, underline)
  • Custom separators for multiple text segments
  • Custom output methods support
  • Type-safe interface

Usage

Basic Example

import { PrinterBuilder, type Method, type ColorType, type Callable } from "@ph/printer";

// Simple printer
const printer = PrinterBuilder.create().build();
printer("Hello", "World"); // Outputs: Hello, World

// Styled printer
const styledPrinter = PrinterBuilder.create()
    .bold
    .underline
    .foreground({ r: 255, g: 193, b: 37 })
    .separator(" -> ")
    .build();

styledPrinter("Step 1", "Step 2", "Step 3"); // Outputs: Step 1 -> Step 2 -> Step 3 (in gold, bold, underlined)

Advanced Usage

import { PrinterBuilder, type Method, type ColorType } from "@ph/printer";

// Custom output method
const errorPrinter = PrinterBuilder.create()
    .method((text: string) => console.error(`[ERROR] ${text}`))
    .foreground({ r: 255, g: 0, b: 0 })
    .build();

errorPrinter("Operation failed"); // Outputs in red: [ERROR] Operation failed

// Combining multiple styles
const highlightPrinter = PrinterBuilder.create()
    .bold
    .foreground({ r: 0, g: 255, b: 0 })
    .background({ r: 0, g: 0, b: 0 })
    .separator(" | ")
    .build();

highlightPrinter("Success", "Done"); // Outputs: Success | Done (in green on black, bold)

License

MIT

Built and signed on
GitHub Actions

New Ticket: 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:@ph/printer

Import symbol

import * as printer from "@ph/printer";
or

Import directly with a jsr specifier

import * as printer from "jsr:@ph/printer";

Add Package

pnpm i jsr:@ph/printer
or (using pnpm 10.8 or older)
pnpm dlx jsr add @ph/printer

Import symbol

import * as printer from "@ph/printer";

Add Package

yarn add jsr:@ph/printer
or (using Yarn 4.8 or older)
yarn dlx jsr add @ph/printer

Import symbol

import * as printer from "@ph/printer";

Add Package

vlt install jsr:@ph/printer

Import symbol

import * as printer from "@ph/printer";

Add Package

npx jsr add @ph/printer

Import symbol

import * as printer from "@ph/printer";

Add Package

bunx jsr add @ph/printer

Import symbol

import * as printer from "@ph/printer";