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

newsman

v1.1.1

Published

Report events, alerts and confirmations to the UI, in the browser.

Downloads

6

Readme

Getting started

newsman is a light-weight user notification module for the Browser, with no dependencies. To use newsman, simply install it with NPM and require it with Browserify, as follows:

npm install newsman
require("newsman");

For your convenience, some basic styles are provided in newsman/src/styles.

Methods

notify()

Sends a small, non-interactive notification to the user. By default it is located at the bottom-right of the screen.

/**
* @param {string} msg - text message to display to user, max 120 characters.
*/
newsman.notify(msg);

The notification markup is very simple, it consists of a single "div". It gets two state css classes appended to it during its lifecycle (isInactive and isActive).

<div class="newsman__notification">
    msg
</div>

alert()

Displays a small modal window containing the provided message and a button (ok).

/**
* @param {string} msg - text message to display to users.
* @param {function} cb - callback function triggered when the user clicks the button.
*/
newsman.alert(msg, cb);

The alert window markup has 5 components (divs). The window event listener is always bound to newsman__window.

<div class="newsman__overlay">
  <div class="newsman__window">
    <div class="newsman__window__content"> msg </div>
    <div class="newsman__window__actionBar">
      <div class="newsman__button"> ok </div>
    </div>
  </div>
</div>

confirm()

Displays a small modal window containing the provided message and two buttons (ok and cancel).

/**
* @param {string} msg - text message to display to user.
* @param {function} cb - callback function triggered when the user clicks one of the buttons.
* If "ok", it calls the provided callback with the "true" argument, otherwise "false".
*/
newsman.confirm(msg, cb);

The confirm window markup has 6 components (divs). The window event listener is always bound to newsman__window.

<div class="newsman__overlay">
  <div class="newsman__window">
    <div class="newsman__window__content"> msg </div>
    <div class="newsman__window__actionBar">
      <div class="newsman__button"> cancel </div>
      <div class="newsman__button"> ok </div>
    </div>
  </div>
</div>

Only one Alert or Confirm window can be active at any given time. If you try to launch a second such window, newsman's method will return false and not do anything until the currently active window is deactivated (requires user action).