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

purdy-browser

v3.0.1

Published

Pretty print objects in real purdy colors. Allows clearer visualization of objects than you get from most pretty printers due to colors.

Downloads

15

Readme

Purdy build coverage

Print things real purdy for nodejs.

Usage

    const Purdy = require('purdy');
    Purdy({list: [1,2,3], string: 'some string'});

Purdy(object, [options])

image

Prints anything indented, and with arrays with index keys, and different types in colors such that it's very easy to get an overview of what object you're dealing with.

  • object - anything, number, object, array, etc.
  • options - optional object with the following keys.
    • plain - when true, prints result without colors. Defaults to false with tty, true when not.
    • path - when true, prints result with a path (To be used with Hoek.reach())
    • pathPrefix - prefix for path. default: //
    • arrayIndex - enables index printing for arrays. default: true
    • indent - defines the number of spaces to indent default: 4
    • align - determines how to align object keys. default: left
    • depth - tells purdy how many times to recurse while formatting the object. This is useful for viewing complicated objects. default: 2. Set to null to recurse indefinitely

Purdy.stringify(object, [options])

This function returns a string without printing it to stdout. This may prove to be useful for log files other other applications.

const purdyString = Purdy.stringify({a: 'b'}, {plain: true});
writeLog(purdyString);

Examples

The following code prints what's in the image above.

const mises = function mises () { this.moop = 3 }
const instance = new mises();
const circularObj = { };
circularObj.a = circularObj;
const obj = {
    integer: Date.now(),
    string: 'foo',
    anonPurdy: Purdy,
    defined: function Yes() {},
    nested: {hello: 'hapi'},
    error: new Error('bad'),
    null: null,
    undefined: undefined,
    regexp: new RegExp,
    falseBool: false,
    trueBool: true,
    symbol: Symbol('purdy'),
    emptyArr: [],
    circular: circularObj,
    date: new Date(),
    arrayWithVisibleIndex: [ 'one', 'two', 'three' ],
    instance: instance,
};
Purdy(obj);

Command-line Interface

This package also installs the purdy CLI tool. Right now this just prints any JSON file with default options.

purdy package.json will, for example, print the JSON contents of package.json.

Similarly, cat package.json | purdy -s will use stdin to print the contents.

A new option -l has been added to parse log files that has one JSON string per line in the file.

purdy -l logfile.log will print that.

Contributing

This project adheres to the hapi styleguide.

Acknowledgements