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

console.table.diff

v1.1.0

Published

Adds the "console.table.diff" method that logs the difference between 2 arrays of objects in a styled table.

Downloads

7

Readme

console.table.diff

A simple script that adds a function to the console.table object that displays a styled table of difference between 2 arrays of objects, since there's no styling capabilities on the console.table function, as per the Console API.

It is useful for debugging in the browser's Web Console in a clear and neat way.

Quickstart

Consider having 2 arrays of objects and you want to find the difference between them, and then display the result in a styled table. The difference is computed using the lodash.differenceWith and lodash.isEqual methods.

Definition: console.table.diff(objAr1, objAr2);

Example

var persons = [
  {name: 'John', age: 24, gender: 'M'},
  {name: 'Jane', age: 22, gender: 'F'},
  {name: 'Smith', age: 26, gender: 'M'}
];

console.table.diff(persons, [{name: 'John', age: 24, gender: 'M'}]);
// Or console.table.diff(persons, [persons[0]]);
// The lodash.isEqual comparator used performs a deep comparison 
// between the 2 values to determine if they are equivalent.

Output:

Output table.

The rows with red background represent the common objects between the 2 arrays.
The rows with green background represent the rest of the objects in array 1.

Use in browser

npm i console.table.diff

Get the difftable.min.js file, then place this script tag in your HTML:

<script type="text/javascript" src=".../difftable.min.js"></script>

For browserify:

var consoleTable = require('console.table.diff');
// consoleTable has the 'window.console.table' object.
// undefined in Node.

License

MIT © 2017 Saad Malaeb.