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

@mhkeller/notify

v1.2.0

Published

Simple, colorful console notifications.

Downloads

10

Readme

@mhkeller/notify

tests npm version

Install

npm install --save @mhkeller/notify

Usage

Pass an object to the notify function with the following options:

  • m — {String} The message.
  • v — {String} The value.
  • d — {String|String[]|Object} Display options. The display style. Can be a chalk style name, array of chalk styles, the name of a built-in display or a display config.
  • k — {Boolean} [false] Whether to show a desktop notification using node-notifier
  • error — {Error} Pass an error object to get printed out with console.error for reference.
  • x — {Object} An object that will extend the display. This is useful if you're setting a string or an array of string colors in d and you want to extend the display in a quick way.

All of these are optional. If you omit either the message or the value, that part of the notification won't appear. If you omit a display, it will use the default which bolds the value portion.

import notify from '@mhkeller/notify'

notify({ m: 'A notification...', v: 'hello', d: 'magenta' });

Built-in displays

The chalk styles passed to d can be a single string, an array of strings or the name of one of the built-in display styles:

// String
notify({ m: 'A notification...', v: 'hello', d: 'cyan' });

// Array of strings
notify({ m: 'A notification...', v: 'hello', d: ['magenta', 'bold', 'italic', 'underline'] });

// Display name
notify({ m: 'A notification...', v: 'hello', d: 'header' });

Here's the full list of built-in display names:

{
  header: ['blue', 'bold'],
  group: ['magenta', 'bold'],
  task: ['cyan', 'bold'],
  note: ['gray', 'italic'],
  error: {
    messageStyle: 'red',
    desktop: true,
    level: 'error'
  },
  warn: {
    messageStyle: ['yellow', 'bold'],
    level: 'warn'
  },
  change: {
    preString: '\n',
    messageStyle: 'cyan'
  },
  success: ['green', 'bold']
}

header

group

task

note

error

warn

change

success

Advanced styling

You can also pass a display config object to the d key. Any keys you don't set will be filled in with the default values:

{
  messageStyle: '',
  valueStyle: 'bold',
  preString: '', // A string that goes before the timestamp. Useful if you want to put a line break character '\n'
  postString: '', // Same as pre-string but it gets added to the end
  skipPrefix: false, // Skip the bracketed timestamp + project name portion, called the prefix
  prefixStyle: { // Styling for the prefix
    open: '[',
    close: ']',
    sep: '|',
    timestampStyle: 'gray',
    projectNameStyle: ['blue', 'bold']
  },
  projectName: null, // By default, this is the name of your project directory but you can manually set it to something else here
  time: null, // By default, this is the current time, but you can manually set it to something else here
  desktop: false, // Show a desktop notification
  level: 'log' // Can be 'log', 'warn' or 'error'. Whether the notification gets called through `console.log`, `console.warn` or `console.error`.
}