# obj-console

> Shows JS objects in terminal with custom format in VSCode colors

Latest version **1.0.2** (published 2023-05-10) · ISC license · 0 weekly downloads

## Install

```sh
npm install obj-console
pnpm add obj-console
yarn add obj-console
bun add obj-console
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2023-05-10 |
| First published | 2023-05-03 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 71 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | mkant@list.ru |
| Maintainers | mkant |
| Keywords | format, console, ansi, color, print, objects, custom |

## Links

- npm: https://www.npmjs.com/package/obj-console
- Repository: https://github.com/m-kant/obj-console
- Homepage: https://github.com/m-kant/obj-console#readme
- Issues: https://github.com/m-kant/obj-console/issues
- npm.io page: https://npm.io/package/obj-console

## Alternatives

- [postcss-color-hex-alpha](https://npm.io/package/postcss-color-hex-alpha.md) — 6.4M weekly downloads
- [randomcolor](https://npm.io/package/randomcolor.md) — 348.0K weekly downloads
- [bows](https://npm.io/package/bows.md) — 1.3K weekly downloads
- [ep_prefer_color_scheme](https://npm.io/package/ep_prefer_color_scheme.md) — 260 weekly downloads
- [coc-yank](https://npm.io/package/coc-yank.md) — 61 weekly downloads

## Recent versions

- 1.0.2 (latest) — 2023-05-10
- 1.0.1 — 2023-05-03
- 1.0.0 — 2023-05-03

## README

# 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](https://github.com/m-kant/obj-console/raw/main/docs/columns-object.png)

![unfold depth](https://github.com/m-kant/obj-console/raw/main/docs/unfold-depth.png)

## Usage

```javascript
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

```typescript
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

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

objConsole(someData, BRIEF);
```

- COMPACT
- BRIEF
- ONE_LINE
- AS_JSON
- COLUMNS

![brief](https://github.com/m-kant/obj-console/raw/main/docs/brief.png)

---
_Source: https://npm.io/package/obj-console · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
