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

printaeu

v0.1.12

Published

Alternative to console.log

Downloads

2,177

Readme

printaeu

Time stamp is a must. Period.

Features

  • Time stamp (configurable to even show ms and date)
  • Can replace previous line content
  • Colorful text
  • Modifiers (bold, italic, underline)
  • Verbosity control
  • File output

Install

npm i printaeu

Usage

It receives the same parameters of console.log.

const { print } = require('printaeu');

// All of them has time stamp
print.log('Like console.log');  // [08:39] Like console.log
print.inline.log('Replace previous line');  // [08:40] Replace previous line
print.inline.green('Replace previous line + green');    // print.inline has all available colors
print.inline.bright.magenta('Replace previous line + bright + magenta');

// Clear console
print.clear();

// Many colors available
print.red('Red');
print.green('Green');
print.cyan('Cyan');
// ...and more

// Control verbosity
print.high.log(`This shows only if verbosity is set to 'high'`);
print.med.bold.pink(`This shows only if verbosity is set to 'high' or 'medium'`);
print.bold.pink(`This always shows`);
print.setVerbosity('low');
print.high.italic.orange(`This won't show :(`);
print.med.underline.magenta(`Neither this`);
print.underline.magenta(`This will`);

// ...and more!
// Also works with ES5+
import { print, italic as i} from 'printaeu';

print.green(`You won't ${i.on}believe${i.off} this!`);

Parameters

  • ...args: Just like console.log().

Show milliseconds

print.showMs() turn it on. print.showMs(false) turn it off.

Clear

print.clear() clear the terminal. print.clearLine(lines = 0) clear some line. No args clears the current line. print.goBacknLines(lines) move the cursor N lines from the current position. Negative goes down.

Track errors

I don't commit errors, but when you do it's better to know where this come from.

const { print } = require('printaeu');

function foo () {
    print.green(thisVarDoesntExist);
}

try {
    foo();
} catch(e) {
    print.red('omg where does this error come from? help me print');
    print.track(e); // Like stack error, but beautier
}

File redirection

Print and logs into a file

const { Print, print } = require('printaeu');
print.logToFile("/tmp/app.log");

const error = Print.create();
error.logToFile("/tmp/app.err");

try {
    foo();
} catch(e) {
    print.red('error data will be printed');
    print.logToFile("/tmp/app.log", false); // stop logging
    error.track(e); // Like stack error, but beautier
    print.log('Error printed') // won't be to the log file
}

Not sure?

Copy, paste and run.

const { print } = require('printaeu');

const warningSign = '\u{26a0}',
      recycleBin  = '\u{267b}',
      heart       = '\u{2764}';

const hey = 'HEY';
print.log(hey, `${hey}`, 'YOU YOU');
print.cyan("I don't like your girlfriend!");

print.showDate();
print.underline.yellow(warningSign, 'NO WAY NO WAY');
print.showDate(false);

print.showMs();
print.setColorfulTimeStamp(false);

print.bright.green(`${recycleBin} I think you need a new one`);
print.reverse.log('HEY HEY YOU YOU');

print.showMs(false);

setTimeout(() => {print.inline.bright.red('I could be your girlfriend ' + heart + heart + heart)}, 3000);

Socket

print.socket(socket); receives a socket from Socket.io lib. Then, every print.log call will fire socket.emit('console', [timeStamp] + data).

Whole Lib

const { print } = require('printaeu');

// All of them has time stamp
print.log('Like console.log');  // [08:39] Like console.log
print.inline.log('Replace previous line');
print.inline.green('Replace previous line + green');    // print.inline has all available colors
print.inline.bright.magenta('Replace previous line + bright + green');

// Colors available
print.red('Red');
print.green('Green');
print.magenta('Magenta');
print.white('White');
print.black('Black');
print.blue('Blue');
print.cyan('Cyan');
print.yellow('Yellow');
print.gray('Gray');
print.gray('Same as grey');
print.pink('Pink');
print.orange('Orange');

// Bright or Bold colors
print.bright.log('Like console.log but brighter');
print.bold.log('Like console.log but bold');
print.bright.red('Bright Red');     // print.bright has all available colors
print.bold.red('Bold Red');     // print.bright has all available colors

// Italic colors
print.bright.log('Like console.log but *italic*');
print.italic.red('Italic Red');     // print.italic has all available colors

// Underline + colors
print.underline.log('Like console.log but underscored');
print.underline.green('Underline Green');     // print.underline has all available colors

// Reversed background
print.reverse.log('Like console.log but with background reversed');
print.reverse.green('Reverse Green');     // print.reverse has all available colors

// Dim colors
print.dim.log('Like console.log but dim');
print.dim.green('Bright Green');     // print.dim has all colors above

// More
print.showMs(false);    // Switch milliseconds display
print.setBG.cyan('magenta');     // Switch the background color of all cyan prints (pink, orange and gray bg are not available)
print.clearBG.cyan();   // Set the default bg for all cyan prints
try {
    print.socket(socket);   // Every print.log(data) it executes socket.emit('console', [timeStamp] data);
} catch(error) {
    print.track(error);     // Print the error in a more readable way
}