# @trenskow/print

> A simple package for printing to the console (or other streams).

Latest version **0.1.87** (published 2026-10-05) · BSD-3-Clause license · 0 weekly downloads

## Install

```sh
npm install @trenskow/print
pnpm add @trenskow/print
yarn add @trenskow/print
bun add @trenskow/print
```

## Health

**Score 60/100 (C)** — status: active.

Positive: esm support; no vulnerabilities; recently updated; high maintenance score.

Warnings: low downloads; no types; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.1.87 |
| Published | 2026-10-05 |
| First published | 2024-12-18 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 14.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Kristian Trenskow |
| Maintainers | trenskow |
| Keywords | print, stdout, stderr, std |

## Links

- npm: https://www.npmjs.com/package/@trenskow/print
- Repository: https://github.com/trenskow/printer
- Homepage: https://github.com/trenskow/printer#readme
- Issues: https://github.com/trenskow/printer/issues
- npm.io page: https://npm.io/package/@trenskow/print

## Dependencies (2)

- [keyd](https://npm.io/package/keyd.md) ^2.1.84
- [@trenskow/null-stream](https://npm.io/package/@trenskow/null-stream.md) ^0.1.29

## Recent versions

- 0.1.87 (latest) — 2026-10-05
- 0.1.86 — 2026-10-05
- 0.1.85 — 2026-10-05
- 0.1.84 — 2026-09-21
- 0.1.83 — 2026-09-21
- 0.1.82 — 2026-09-21
- 0.1.81 — 2026-09-21
- 0.1.80 — 2026-09-18
- 0.1.79 — 2026-09-18
- 0.1.78 — 2026-09-16
- 0.1.77 — 2026-09-16
- 0.1.76 — 2026-09-16
- 0.1.75 — 2026-08-04
- 0.1.74 — 2026-08-03
- 0.1.73 — 2026-08-03
- … 73 more at https://npm.io/package/@trenskow/print/versions

## README

# @trenskow/print

A simple package for printing to the console (or other streams).

## Usage

````javascript
import { createWriteStream } from 'node:fs';

import print from '@trenskow/print';

print('Hello, World!'); // Simply prints to stdout.
print.nn('Hello, World!'); // Prints to stdout without new line.
print.sentence('Hello, World, this is a sentence.'); // Prints to stdout a sentence and line breaks at TTY width.

// Below does the same as above but to stderr instead.

print.err('Hello, World!');
print.err.nn('Hello, World!');
print.err.sentence('Hello, World, this is a sentence!');

// Below does the same but to a stream.

const out = print.stream(createWriteStream('out.txt'));

out('Hello, World!');
out.nn('Hello, World!');
out.sentence('Hello, World, this is a sentence!');
````

## Parallel processing printer

There is also a build-in parallel processing builder. This is used to convey the state of multiple tasks.

### Usage

````javascript
import { parallelProgress } from '@trenskow/print';

const states = {
	myTask1: 'waiting',
	myTask2: 'waiting',
	myTask3: 'waiting'
}

const { stateUpdated } = parallelProgress({
	states,
	simpleOutput: false, // force non-TTY output (defaults to `false`).
	completionState: 'done', // State to remove task from list (defaults to ´'done'`).
	waitingState: 'waiting' // State to signal task is waiting (defaults to `'waiting'`).
});

for (let idx = 0 ; idx < 3 ; idx++) {

	setTimeout(() => {
		states[`myTask${idx}`] = 'processing';
		stateUpdated(`myTask${idx}`);
	}, idx * 1000);

	setTimeout(() => {
		states[`myTask${idx}`] = 'done';
		stateUpdated(`myTask${idx}`);
	}, idx * 2000);

}
````

The above will output something like this.

````
myTask1  processing
myTask2  processing
myTask3  waiting
````

The list will auto-remove items that has the state of `options.completionState` (default is `'done'`).

# License

See license in LICENSE.

---
_Source: https://npm.io/package/@trenskow/print · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
