Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

purdy

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

purdy

print objects real purdy in color

  • 0.3.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4.5K
decreased by-20.96%
Maintainers
1
Weekly downloads
 
Created
Source

Purdy

Print things real purdy for nodejs.

Usage

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

Purdy(object, [options])

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.

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.

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

Examples

// var circularObj = { };
// circularObj.a = circularObj;
// var circ = [];
// circ.push(circ);
// Purdy({
//     a: 3,
//     bn: 'foo',
//     raino: it,
//     d: {king: 'cobra'},
//     null: null,
//     undefined: undefined,
//     regexp: new RegExp,
//     falseBool: false,
//     trueBool: true,
//     emptyArr: [],
//     circular: circularObj,
//     circularArr: circ
// });

{
              a: 3,
             bn: 'foo',
          raino: [Function: ?],
              d: {
        king: 'cobra'
    },
           null: null,
      undefined: undefined,
         regexp: /(?:)/,
      falseBool: false,
       trueBool: true,
       emptyArr: [],
       circular: {
        a: [Circular]
    },
    circularArr: [
        [0] [Circular]
    ]
}
```

```javascript
// Purdy([1,2,'foo', it, Array.isArray, new Date,1,1,1,1,12,[1,2]]);

[
    [ 0] 1,
    [ 1] 2,
    [ 2] 'foo',
    [ 3] [Function: ?],
    [ 4] [Function: isArray],
    [ 5] Tue May 06 2014 20:49:29 GMT-0700 (PDT),
    [ 6] 1,
    [ 7] 1,
    [ 8] 1,
    [ 9] 1,
    [10] 12,
    [11] [
        [0] 1,
        [1] 2
    ]
]
```


## Acknowledgements
* Michael Dvorkin for [Awesome Print]

[Awesome Print]: https://github.com/michaeldv/awesome_print

Keywords

FAQs

Package last updated on 05 Jun 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc