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

hadithi

v0.0.3

Published

When your logs tell a story about who dunnit!

Downloads

3

Readme

Hadithi (Swahili for story)

When you need your logs to tell a story...

'Hadithi' is Swahili for 'Story'. Often, my son loves when I tell him stories at night. As with any story, he often wants to know:

  • How it happened
  • Where it happened
  • When it happened
  • Who did it

Hadithi (the module) arose from the need to have my logs tell me a story. A story that is easy to follow with metadata on where, how and who dunnit!

I also happen to be fussy about how my logs are presented so I had to chalk them over :-)

Don't use this if...

You want machine readable (saved to file/db) logs. This is and will remain a debugging tool for the most part where a developer wants to read a story of what the code is doing. While I have entertained the thought of building in such capability a couple of times, there are better tools like bunyan for that.

Sample Hadithi

A hadithi looks somewhat like this...

┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃                                              ┃
┃  SERVER STARTUP                              ┃
┃⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻┃
┃  Loading necessary modules                   ┃
┃  ₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋  ┃
┃  Setting up routes                           ┃
┃  ₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋  ┃
┃  Starting Up Server...                       ┃
┃  ₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋  ┃
┃  Server started                              ┃
┃                                              ┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
┃  WHEN:    Tue, 09 Aug 2016 18:50:57 GMT      ┃
┃  ₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋  ┃
┃  CALLER:  E:\projects\Node\_MY MODULES\...   ┃
┃          ..hadithi\test.js                   ┃
┃  ₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋  ┃
┃  LINE:    22                                 ┃
┃  ₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋  ┃
┃  AT CHAR: 9                                  ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

See test.js for sample Hadithis.

Start with

Install with npm install --save hadithi;


const hadithi = require('hadithi');

//start hadithi (story) using an array
var storyline = [
  {
    hadithiStyle: 'bold', //style with chalk.bold()
    hadithiColor:'blue', //style with chalk.color()
    hadithiType:"title",  // treat this as a title
    hadithiContent:'SERVER STARTUP', //here id the title content
    hadithiNumbered: true //ok we want this numbered. Note, this option is applied to all other items other than the title itself! Putting it here is a shortcut to putting it elswhere in the items
  }
];

//Now Let us develop this story...
//somewhere else in your code
storyline.push('Loading necessary modules at line ' + hadithi.lineTrace().lineArr[0]);

//somewhere else in your code
storyline.push('Setting up routes at line ' + hadithi.lineTrace().lineArr[0]);

//somewhere else in your code, might be another file
storyline.push('Starting Up Server...')
storyline.push(hadithi.lineTrace().string);

var server_details = {
    port : 1335,
    started : new Date().toUTCString(),
    clients : 2,
    version : '1.0.0'
};

//somewhere else in your code
storyline.push('Server started at line ' + hadithi.lineTrace().lineArr[0] );

storyline.push(server_details);

//OK, Now Print Story
hadithi.log(storyline);


//lets do a quick story
hadithi.log(
   "Hadithi is awesome!",
   "But hey, heard of the inbuilt function .lineTrace()",
   "It helps you get data of the line in question like this: ",
   {hadithiColor:"green", hadithiContent : hadithi.lineTrace().string},
   "So you can use your Hadithi to tell WHERE & WHO DUNNIT!",
   "And somewhere in the middle of the code, you can number your story items...",
   {hadithiNumbered:true , hadithiContent: "This is the first numbered item :-)"},
   {hadithiColor:"red", hadithiNumbered:true , hadithiContent: "A second numbered item with color styling :-)"},
   {hadithiNumbered:false , hadithiContent: "Oh. We don't want any more numbering..."},
   {hadithiNumbered:true , hadithiContent: "Let's resume numbering, this time with some indentation...", hadithiIndent: 2 },
   {hadithiNumbered:true , hadithiContent: "Another Indented item", hadithiIndent: 3 },
   {hadithiNumbered:true , hadithiContent: "A last Indented item", hadithiIndent: 4 },
   "",//lets skip this line
   "\n\r", // or even leave out more space right here...
   "So what is the moral of this lesson?",
   "Like console.log(), Hadithi can take multiple arguments (logs) and 'storify' them!"
 );

Columns

test.js is a pretty good example to start with. If you run it, you will note that it outputs objects as beautiful columns! Did you?

Well, that's because Hadithi wraps the awesome columnify

Styling

Please note that Hadithi uses chalk under the hood so all color names and style names must follow Chalk color/style names or will be ignored.

Go on, tell that story!