This package has been archived, and as such it is read-only.
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




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
Add Package
deno add jsr:@ph/printer
Import symbol
import * as printer from "@ph/printer";
Import directly with a jsr specifier
import * as printer from "jsr:@ph/printer";
Add Package
pnpm i jsr:@ph/printer
pnpm dlx jsr add @ph/printer
Import symbol
import * as printer from "@ph/printer";
Add Package
yarn add jsr:@ph/printer
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";