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

tagged

v0.1.0

Published

Logger with styles and inheritance support.

Downloads

2

Readme

Tagged

Logger for Node.js with styles and inheritance support.

npm install tagged
var tagged = require('tagged');

tagged.add('plain',   { trim: false });

tagged.add('em',      { style:  'i',
                        extend: 'plain' });

tagged.add('strong',  { style:  'b',
                        extend: 'plain' });

tagged.add('braces',  { borderStyle: 'none',
                        borderLeft:  '[ ',
                        borderRight: ' ] ',
                        width:        7,
                        align:       'center',
                        extend:      'plain' });

tagged.add('error',   { style:  'red, bright',
                        extend: 'braces' });

tagged.add('warning', { style:  'yellow, bright',
                        extend: 'braces' });

tagged.add('info',    { style:  'blue, bright',
                        extend: 'braces' });

tagged.add('success', { style:  'green, bright',
                        extend: 'braces' });

tagged.add('error2',  { borderRight: ': ' });

var tags = { error:   { error:   'error'  },
             warning: { warning: 'warning' },
             info:    { info:    'info' },
             success: { success: 'success' },
             error2:  { error2:  'my_program' } };

tagged(tags.error,   'Error message');
tagged(tags.warning, 'Some text');
tagged(tags.info,    'Info message 1');
tagged(tags.info,    'Info message 2');
tagged(tags.success, 'Completed');
tagged(tags.error2,  'Error decription');
tagged({ em: 'Some text.\n', plain: 'Some other text.\n', strong: 'Bold text.' });

API

tagged.add(name, options)

Add style definition.

  • string name — style name.
  • object options — style definition.
    • string extend — parent style name.
    • string style — style definition string.
    • string borderLeft — left border string.
    • string borderRight — right border string.
    • string borderStyle — style definition for borders.
    • number width — number of symbols of resulting string.
    • number digits — number of digits after comma.
    • number radix — radix desu.
    • boolean zero — fill left space with zeros.
    • boolean plus — add plus sign to positive numbers.
    • string align — horisontal align (left, center, right).
    • boolean trim — trim whitespace at start and end of string.
    • string overflow — overflow style if width is defined and string width greater then defined width (visible, hidden, ellipsis).

Style definition string

  • Colors:
    • By name: black, red, green, yellow, blue, magenta, cyan, white.
    • By code: color(<0..255>). ANSI color code.
    • By HEX value: hex(<#rrggbb>). CSS-like color.
    • Background color: bg.red, bg.hex(#0080ff).
  • Font styles:
    • Bold: bold, b, bright.
    • Italic: italic, i.
    • Underline: underline, u.
  • Other:
    • blink;
    • inverse;
    • hidden.
    • Clear style: 0, unset, clear, off, none, default.

Style rules can be combined with comma: red, bg.hex(#0080ff), u, i.

tagged.remove(name)

Remove style definition.

  • string name — style name.

tagged([<object>|<string>]*)

<object> can contain one or more name-value pairs. Example:

{
    em: 'Some text.\n',
    plain: 'Some other text.\n',
    strong: 'Bold text.'
}

TODO

  • Write tests for extend property.