A JavaScript library improving inspection of objects

Overview

Pro Inspector

Image Image

A JavaScript utility improving inspection of objects on Node.js.

Introduction

Let's suppose that we have this declaration.

class Person {
    constructor (firstName, lastName) {
        this.firstName = firstName;
        this.lastName = lastName;
    }
    
    get fullName () {
        return `${this.firstName} ${this.lastName}`;
    }
    
    drink () {
        // ...
    }
    
    async read () {
        // ...
    }
}

Now let's create an instance of this class and log it using our beloved console.log.

console.log(new Person("John", "Chen"));

This is the log in our console.

Person { firstName: 'John', lastName: 'Chen' }

Where is the problem? The getter is not visible and the methods are not visible. This is because by default certain class properties are not enumerable. This would happen also with a literal object (only for getters).

Pro Inspector solves this issues by reading the descriptors of the logged entities and presenting them with a nice syntax highlighted format.

This is the log with Pro Inspector.

Installation

npm i @reiryoku/pro-inspector

Usage

Pro Inspector can be activated globally for every log by using activateGlobally() in the program entry point.

import { ProInspector, } from "@reiryoku/pro-inspector";

ProInspector.activateGlobally();

In alternative you can use Pro Inspector only on certain objects/classes.

import { ProInspector, } from "@reiryoku/pro-inspector";

const myObject = {
    fullName: "Jessica Chen",
    
    get age () {
        return 22;
    },
    
    async destroy () {
        // ...
    },
    
    [ProInspector.inspector] () {
        return ProInspector.inspect(this);
    }
};

In this way Pro Inspector will be enabled only for the object above when logged with console.

Options

Few options are available since the project is new and not in a stable phase.

spaces

Determines the tab size, default is 4.

import { ProInspector, } from "@reiryoku/pro-inspector";

// Set tab size to 2
ProInspector.globalOptions.spaces = 2;

Todo

A list of tasks for the future.

  • Create a format for arrays
  • Show functions/methods named parameters
  • Create a format for maps, weak maps and sets
  • Allow using custom syntax highlight colors

Create an issue to suggest improvements and/or report a bug.

You might also like...

This is a basic app that allows user add/remove books from a list of books. It was created by using JavaScript arrays and objects to dynamically modify the DOM.

Awesome-Books This application lets you compile a dynamic collection of books using JavaScript. It is a single page app. You enter your book title & a

Oct 24, 2022

Json-parser - A parser for json-objects without dependencies

Json Parser This is a experimental tool that I create for educational purposes, it's based in the jq works With this tool you can parse json-like stri

Jan 3, 2022

Hierarchical Converter for Array of Objects

Conversor Hierárquico para Array de Objetos - Hierarchical Converter to Array of Objects Docker-compose Cria a interface network e containers indicado

Jan 27, 2022

Visualize the Directed Acyclic Graph that Git creates to connect Commit, Tree and Blob objects internally.

Visualize the Directed Acyclic Graph that Git creates to connect Commit, Tree and Blob objects internally.

Git Graph Visualize the Directed Acyclic Graph that Git creates to connect Commit, Tree and Blob objects. Hosted at HarshKapadia2.github.io/git-graph.

Aug 21, 2022

An API for producing and validating ActivityPub objects.

ActivityHelper A library that exports an API for producing and validating ActivityPub objects. In a federated system bound together by protocols, it's

May 2, 2022

🧩 TypeScript utility type in order to ensure to return only properties (not methods) containing values in primitive types such as number or boolean (not Value Objects)

🧩 TypeScript utility type in order to ensure to return only properties (not methods) containing values in primitive types such as number or boolean (not Value Objects)

🧩 TypeScript Primitives type TypeScript utility type in order to ensure to return only properties (not methods) containing values in primitive types

Dec 7, 2022

LiveJSON provides LiveView-like updating for JSON objects rather than DOM elements.

live_json LiveJSON provides LiveView-like updating for JSON objects rather than DOM elements. It works within your existing LiveViews - just use push_

Dec 29, 2022

Solid Forms provides several form control objects useful for making working with forms easier.

Solid Forms Solid Forms provides several form control objects useful for making working with forms easier. Demos and examples below. # solidjs yarn ad

Jan 2, 2023

jQuery Plugin for Sticky Objects

Sticky Sticky is a jQuery plugin that gives you the ability to make any element on your page always stay visible. Sticky in brief This is how it works

Dec 16, 2022
Owner
Reiryoku Technologies
Reiryoku Technologies
Superlight vanilla javascript plugin improving forms look and functionality

Superlight pure javascript form switch plugin by LCweb Give a modern look to your applications and take advantage of javascript events and public func

Luca 31 Mar 9, 2022
Pagination Manager is an useful framework for improving the use of object pagination in APIs like Discord.

Pagination Manager Pagination Manager is an useful framework for improving the use of object pagination in APIs like Discord. Lightweight module, ES6

tnfAngel 4 Jul 26, 2022
A small library for turning RSS XML feeds into JavaScript objects

rss-parser A small library for turning RSS XML feeds into JavaScript objects. Installation npm install --save rss-parser Usage You can parse RSS from

Robert Brennan 1.1k Dec 31, 2022
javascript library to convert a list of objects to a nested json output format, depending on the names in the list

formToNestedJson javascript "library" to convert a list of objects to a nested json output format, depending on the names in the list Basic usage Give

null 2 Aug 2, 2021
Binary-encoded serialization of JavaScript objects with generator-based parser and serializer

YaBSON Schemaless binary-encoded serialization of JavaScript objects with generator-based parser and serializer This library is designed to transfer l

Gildas 11 Aug 9, 2022
An free e-book entirely about JavaScript objects

Advanced JavaScript Objects An e-book entirely about JavaScript objects Chapters Total length: 70 A4 pages. Chapter 0 - Introduction Chapter 1 - Getti

Carl Riis 240 Dec 13, 2022
Awesome books: plain JavaScript with objects

Awesome books: plain JavaScript with objects Awesome books is an online book store. It's built with HTML, CSS and mostly JS based on a medium-fidelity

null 17 Aug 30, 2022
This project will be a basic website that allows users to add/remove books from a list. The main objective is to understand how to use JavaScript objects and arrays and dynamically modify the DOM and add basic events.

Awesome-books Awesome Books This project will be a basic website that allows users to add/remove books from a list. This project is part of the Microv

Aleksandra Ujvari 10 Oct 3, 2022
Functions for testing the types of JavaScript values, cross-realm. Has testers for all standard built-in objects/values.

@suchipi/is Functions for testing the types of JavaScript values, cross-realm. Has testers for all standard built-in objects/values. Usage import { is

Lily Skye 5 Sep 8, 2022
Basic website that allows users to add/remove books from a list. Achieved using JavaScript objects and arrays, dynamically modifying the DOM and adding basic events.

Awesome Books Basic website that allows users to add/remove books from a list. Achieved using JavaScript objects and arrays, dynamically modifying the

Didier Peran Ganthier 6 Dec 20, 2022