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

nanoweb-cli

v0.4.2

Published

Nan•web console line interface.

Downloads

261

Readme

Utility Module

This module provides a set of utility functions for formatting console output, measuring performance, and handling memory usage in Node.js applications.

Installation

To install the package, use the following command:

npm install nanoweb-cli

Usage

Import the module and use the provided functions as needed:

const { write, GREEN, RESET, OK, NANO } = require('nanoweb-cli');

// Example usage
print(`${GREEN}${OK} Hello, World!${RESET} Welcome in console interface`);
print(`This is an overwritten text because the previous characters was \\r`, "\n");

Functions

print(message, end = '\r', skipColumns = false)

Prints a message to the console, optionally adjusting for terminal width.

panic(err, highlighedRows = 1)

Prints an error stack trace to the console with highlighted rows.

progress(i, len, fixed = 1)

Calculates progress percentage.

spent(checkpoint, fixed = 2)

Calculates the time spent since the given checkpoint.

debounce(func, wait)

Creates a debounced function that delays invoking the provided function until after the specified wait time.

formatMemoryUsage(bytes, bytesAffix = 'b')

Formats memory usage in human-readable form (e.g., KB, MB, GB).

mem(value = null, bytesAffix = 'b')

Returns the formatted memory usage of the current process or the provided value.

getMemoryUsage(MEMORY_DANGER_USE = 1024 * 1024 * 1024)

Returns an array of formatted memory usage statistics for the current process.

setDebounced

Sets a state value using a debounced function.

short(message, cutTo = null, offsetToSave = null)

Shortens a message to the specified length, optionally preserving parts of the message.

timer(started = null)

Returns the current time or the time elapsed since the given start time.

Constants

GREEN, RED, YELLOW, BG_YELLOW, RESET, OK, FAIL, NANO

Constants for console text formatting and symbols.

const OK = '✓';
const FAIL = '×';
const NANO = '·';

Example

const { print, GREEN, OK, RESET, debounce } = require('nanoweb-cli');

print('Processing...', "\n");
debounce(() => {
	print(`${GREEN}${OK}${RESET} Operation completed successfully.`, "\n");
}, 108);

License

MIT

Contributing

Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.