GithubHelp home page GithubHelp logo

eyes.js's Introduction

eyes

a customizable value inspector for Node.js

synopsis

I was tired of looking at cluttered output in the console -- something needed to be done, sys.inspect() didn't display regexps correctly, and was too verbose, and I had an hour or two to spare. So I decided to have some fun. eyes were born.

eyes-ss

example of the output of a user-customized eyes.js inspector

eyes also deals with circular objects in an intelligent way, and can pretty-print object literals.

usage

var inspect = require('eyes').inspector({styles: {all: 'magenta'}});

inspect(something); // inspect with the settings passed to `inspector`

or

var eyes = require('eyes');

eyes.inspect(something); // inspect with the default settings

you can pass a label to inspect(), to keep track of your inspections:

eyes.inspect(something, "a random value");

If you want to return the output of eyes without printing it, you can set it up this way:

var inspect = require('eyes').inspector({ stream: null });

sys.puts(inspect({ something: 42 }));

customization

These are the default styles and settings used by eyes.

styles: {                 // Styles applied to stdout
    all:     'cyan',      // Overall style applied to everything
    label:   'underline', // Inspection labels, like 'array' in `array: [1, 2, 3]`
    other:   'inverted',  // Objects which don't have a literal representation, such as functions
    key:     'bold',      // The keys in object literals, like 'a' in `{a: 1}`
    special: 'grey',      // null, undefined...
    string:  'green',
    number:  'magenta',
    bool:    'blue',      // true false
    regexp:  'green',     // /\d+/
},

pretty: true,             // Indent object literals
sortObjectKeys: false,    // Sort object keys
hideFunctions: false,     // Don't output functions at all
stream: process.stdout,   // Stream to write to, or null
maxLength: 2048           // Truncate output if longer

You can overwrite them with your own, by passing a similar object to inspector() or inspect().

var inspect = require('eyes').inspector({
    styles: {
        all: 'magenta',
        special: 'bold'
    },
    maxLength: 512
});

eyes.js's People

Contributors

indexzero avatar mattijs avatar nrw avatar mmalecki avatar chakrit avatar kesla avatar laverdet avatar ptshih avatar

Watchers

James Cloos avatar  avatar Eric Pan avatar Brian Nguyen avatar  avatar Bruno Marinho avatar Edward Junprung avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.