Skip to content

util.inspect replacement based on Unexpected's output and type system

Notifications You must be signed in to change notification settings

unexpectedjs/uninspected

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Oct 30, 2023
d91aceb · Oct 30, 2023
Oct 30, 2023
Oct 27, 2023
Oct 30, 2023
Oct 30, 2023
Oct 31, 2018
Oct 31, 2018
Apr 25, 2021
Jun 23, 2019
Dec 16, 2014
Oct 31, 2018
Oct 27, 2023
May 10, 2020
Oct 31, 2018
Oct 30, 2023
Oct 30, 2023
Oct 30, 2023
Mar 28, 2020

Repository files navigation

uninspected

Replacement for util.inspect and the console object.

NPM version Build Status Coverage Status Dependency Status

var uninspected = require('uninspected');

var str = uninspected.inspect({ foo: 'bar' }); // "{ foo: 'bar' }"

uninspected.log('foo', { bar: /hey/ }); // { bar: /hey/ }

// Or use this shorthand:
uninspected('foo', { bar: /hey/ }); // { bar: /hey/ }

The library also includes diffing support (powered by Unexpected's diffing engine):

uninspected.diff({ foo: 'bar' }, { foo: 'baz' });
{
  foo: 'bar'; // should be 'baz'
  // -bar
  // +baz
}

Or if you want to get the rendered diff as a string:

const diff = uninspected.diffAsString({ foo: 'bar' }, { foo: 'baz' });

You can use the equal function if you just want to compare two values for equality:

uninspected.equal({ foo: 123 }, { foo: 123 }); // returns true
uninspected.equal({ abc: 123 }, { def: 456 }); // returns false

You can also ask for the diff with ANSI codes, or in HTML format:

const ansiDiff = uninspected.diffAsString(
  { foo: 'bar' },
  { foo: 'baz' },
  { format: 'ansi' }
);
const htmlDiff = uninspected.diffAsString(
  { foo: 'bar' },
  { foo: 'baz' },
  { format: 'html' }
);

You can also use it instead of the console object:

var console = require('uninspected');

console.log('...');

console.trace();

In the Chrome console this will produce colored output using this API.

The uninspected npm package includes a bookmarklet for doing the above, ie. replacing the console object with uninspected, see bookmarklet.html at the root of the package. Unfortunately github doesn't permit putting it directly into this README.

RELEASES

See the changelog.