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

util-tool

v2.0.0

Published

Simple debugging and logging tool.

Downloads

11

Readme

Util-Tool

Utility Tool in order to debug code. Runs console logs, checks objects in order to see if they are empty or undefined, and provides feedback through terminal. Also uses Mocha & Chai to run tests on itself verifying that it functions properly.


How to setup

In order to setup the Util tool simply follow these steps:

  1. Install the module into your project using npm install util-tool

  2. Now that you have the module installed simply require it in your project files by using var util = require('util-tool')

  3. In order to use the debugging functionality of the tool you have to run your project in DEBUG mode. Simply turn DEBUG mode on by running DEBUG=true whenever you start the server.

  4. Enjoy the utility tool ( ^-^)

The util-tool was tested using Mocha and Chai for the unit testing. But the unit testing is not included in the npm install.

For information on the unit testing check out the files on GitHub.


Util Tool Methods

Logging

In order to log using the util tool simply remember this format util.writer(title, data, status, consoleMethod).

  • Title: is the header of the log.
  • Data: is any type of data that you pass in. For logging purposes data is simply a placeholder.
  • Status: is meant to be any piece of information that would benefit the developer. Ex: Test #3: Successful function
  • consoleMethod: takes one of the strings in the array based on what kind of console you want ['log', 'warn', 'error']. They will console in different colors.

Example Output:

util.writer('Testing Log', '', 'Test successful', 'log')
//Data was passed in as an empty string in order to leave whitespace.

Output:
=================================================
[2016-06-23T14:48:26-04:00]: Testing Log
=================================================
 "" Test successful

Debugging

The debugging portion of the tool is meant to discern whether or not data is empty or undefined. Simply write it in this format util.debug(data)

  • Data: is any type of data that you pass in. The util tool was tested with objects, arrays, and strings. When debugging it will check to see if the data was either empty or undefined and log a response accordingly. If the data is correct then it will log successful.

Example Output:

// Undefined Test
util.debug()

Output:
=================================================
[2016-06-21T14:29:47-04:00]: Data Check ?
=================================================
 undefined
Data was undefined.

--------------------------------------------------

// Empty Test
util.debug({})

Output:
=================================================
[2016-06-21T14:30:41-04:00]: Data Check -
=================================================
 {}
Data was empty.

--------------------------------------------------

// Successful Test
util.debug(['array'])

Output:
=================================================
[2016-06-21T14:30:41-04:00]: Data Check +
=================================================
 ['array']
Data was passed correctly.

Version Bump

This module is good to use with gulp.

Call this module to increment the version number.

Usage

const util = require('util-tool');

// takes the current version -> (string)  & tag -> (string) ['major', 'minor', 'patch']
util.versionbump('1.0.0', 'major');

Returns (string)

'2.0.0'