New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

obj-console

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

obj-console

Shows JS objects in terminal with custom format in VSCode colors

latest
Source
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

obj-console

Beautify terminal output of JS-objects with VSCode colors and custom format. 10K dist with no dependencies.

You can tune output to enhance readability of single objects or arrays. Or print compact brief of data just to understand, that data has appropriate form. For example, options: {unfoldDepth: 1, omitBrackets: true, omitEolCommas: true, quote: "", align: true} leads to output:

columns-object

unfold depth

Usage

import { objConsole, objFormat } from 'obj-console';

objConsole(someData);
objConsole(someData, options);

const str = objFormat(someData); // just format, no print
console.log(str); // same as objConsole(someData)

Options

interface FormatOptions {
  omitBrackets?: boolean;
  /** Ommit commas at the end of lines even in arrays */
  omitEolCommas?: boolean;
  /** Quotation marks to surround strings */
  quote?: "" | "'" | "\"";
  /** Quotation marks to surround keys in objects */
  keyQuote?: "" | "'" | "\"";
  /** All elemetns with index higher then `maxArrayLength`
   * will be ommited, text `...overall {n} elements` wil be added at the end */
  maxArrayLength?: number;
  /** Strings will be cutted to `maxStringLength`
   * text `... +{n}chrs` wil be added at the end */
  maxStringLength?: number;
  /** Maximum depth to scan object */
  maxDepth?: number;
  /** Spaces or other symbols for left padding  */
  padding?: string;
  /** Works on 1-st level */
  align?: boolean;
  /** If depth is more then `unfoldDepth`,
   * then objects will be printed in one line */
  unfoldDepth?: number;
}

Predefined options

import { objConsole, BRIEF } from 'obj-console';

objConsole(someData, BRIEF);
  • COMPACT
  • BRIEF
  • ONE_LINE
  • AS_JSON
  • COLUMNS

brief

Keywords

format

FAQs

Package last updated on 10 May 2023

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