Popularity
0.3
Growing
Activity
8.6
Growing
8
2
0

Monthly Downloads: 0
Programming language: JavaScript
Tags: Log     Logging     Console     Logger     Debug     Echo     Print     Variable     Debugging    
Latest version: v1.1.16

Consono alternatives and similar libraries

Based on the "Log" category

Do you think we are missing an alternative of Consono or a related project?

Add another 'Log' Library

README

[Consono](docs/img/logo.png?raw=true "Consono")

๐Ÿ•ต๏ธ Consono ๐Ÿ•ต๏ธโ€โ™€๏ธ

The most correct, informative, appealing and configurable variable inspector for Node.js

๐Ÿ—Ž Consono Documentation ๐Ÿ—Ž

NPM Version NPM Downloads Build Status Issues

Known Vulnerabilities Dependency Status devDependencies Status

Maintainability Codacy Badge Quality Gate Status

GitHub stars GitHub watchers GitHub followers GitHub forks


If you use this project don't forget to give a โญ star โญ to it on GitHub!


๐Ÿ”‹ Motivation

Motivation and differences from other libraries.

๐Ÿงฌ Examples

consono(undefined);
consono(null);

[Nil](docs/img/light/001.png?raw=true "Nil")

consono(true);
consono(false);

[Boolean](docs/img/light/002.png?raw=true "Boolean")

consono(Infinity);
consono(Number.NEGATIVE_INFINITY);
consono(NaN);
consono(1);
consono(1.5);
consono(BigInt(9007199254740991));

[Number](docs/img/light/003.png?raw=true "Number")

consono(new Date());

[Date](docs/img/light/004.png?raw=true "Date")

consono("Hello, world ๐Ÿ˜€๐Ÿ˜๐Ÿ˜‚๐Ÿคฃ๐Ÿ˜ƒ๐Ÿ˜„๐Ÿ˜…๐Ÿ˜†๐Ÿ˜‰๐Ÿ˜Š", { stringMaxLength: 17 });
consono(Symbol("๐ŸŒˆ"));

[String](docs/img/light/005.png?raw=true "String")

consono(/[0-9]+/);
consono(/\w+/giu);

[RegExp](docs/img/light/006.png?raw=true "RegExp")

consono(function() {});
consono(function helloWorld() {});
consono(() => {});

[Function](docs/img/light/007.png?raw=true "Function")

consono(new Promise(() => {}));
consono(async function helloWorld() {});
consono(async () => {});
consono(function* gen() { yield 1; });

[Async](docs/img/light/008.png?raw=true "Async")

consono([1, 2, 3]);
consono(Int8Array.from([1, 2, 3]));

[Array](docs/img/light/009.png?raw=true "Array")

consono(new ArrayBuffer(8));
consono(new SharedArrayBuffer(16));

[Array Buffer](docs/img/light/010.png?raw=true "Array Buffer")

consono(new Set(["a", true, { prop: 1 }]));
consono(new Map([["first", "a"], [true, "b"]]));
consono(new WeakMap());
consono(new WeakSet());

[Collection](docs/img/light/011.png?raw=true "Collection")

consono({});

class MyClass {} const myClass = new MyClass(); myClass.deeper = new
MyClass(); consono(myClass);

[Object](docs/img/light/012.png?raw=true "Object")

consono(new Error("Standard error"));
consono(new EvalError("Unable to run this code"));
consono(new RangeError("Must be less than 10 and greater than 0"));
consono(new ReferenceError("This is error from try/catch"));
consono(new SyntaxError("Not a source code"));
consono(new TypeError("Value is not of the expected type"));

[Error](docs/img/light/013.png?raw=true "Error")

(function(a, b) { consono(arguments); })(true, false);

[Arguments](docs/img/light/014.png?raw=true "Arguments")

consono(global || globalThis, { objectMaxProps: 3 });

[Global](docs/img/light/015.png?raw=true "Global")

๐Ÿ“ฆ Installation

npm install consono
yarn add consono

โŒจ๏ธ Include

Default is function for printing variable.

const consono = require("consono").default;

Require multiple items: function, constructor, options object, theme objects.

const {
  Consono,
  consono,
  options,
  THEME_DARK,
  THEME_LIGHT,
} = require("consono");

Import as ECMAScript module.

import { consono } from "consono/es";

โš™๏ธ Options

const { Consono } = require("consono");
const options = {
  clear: true,
  quotesEnd: `โ€`,
  quotesStart: `โ€œ`,
  stringMaxLength: 54,
};
const theme = "light"; // default is "dark"
const consono = new Consono(options, theme);
consono.log("Cleared before output. Different quotes. And cut to 54!");
// string โ€ข "Cleared before output. Different quotes. And cut to 54"
// (length=55, shown=54)
const { Consono } = require("consono");
const theme = {
  argument: [253, 151, 31],
  boolean: [174, 129, 255],
  comment: [117, 113, 94],
  keyword: [249, 38, 114],
  name: [230, 219, 116],
  number: [174, 129, 255],
  plain: [255, 255, 255],
  property: [102, 217, 239],
  string: [166, 226, 46],
};
const consono = new Consono(null, theme);
consono.log("Themed");
const { Consono, options } = require("consono");
options.colorize = false;
const consono = new Consono(options);
consono.log("Text without colorization");
const { consono } = require("consono");
console.debug(
  consono("Outputs a message only at the debug log level.", false)
);

๐Ÿท๏ธ Instance

const consono = Consono.factory(options, theme);
consono("This is log function with your own options");

๐Ÿ”– Log function

const { consono } = require("consono");
const map = new Map();
map.add("key", true);
consono(map);

Return string with variable description.

const variableAsString = consono({}, false);

or

const variableAsString = consono({},  { console: false });
const defaultOptions = {
  // Maximum number of elements in array to show
  arrayMaxElements: 99,
  // Assign symbol
  assignSymbol: "โ†’",
  // Clear console before output
  clear: false,
  // Colorize the output
  colorize: true,
  // Output to console
  console: true,
  // Default depth of object
  depth: 20,
  // 'false' - do nothing. 'true' - exit status ok.
  // Number greater than zero - exit status with passed error code.
  exit: false,
  // Call console.log immediately
  immediate: false,
  // Print indentation
  indent: "ห‘ห‘",
  // Maximum number of entries in map to show
  mapMaxEntries: 99,
  // Maximum number of properties in object to show
  objectMaxProps: 99,
  // Quote start
  quotesEnd: `"`,
  // Quote end
  quotesStart: `"`,
  // Return inspected variable as string
  returns: true,
  // Maximum number of values in set to show
  setMaxValues: 99,
  // Maximum length of string to show
  stringMaxLength: 360,
};
consono("Some variable", defaultOptions);

๐Ÿ”ฎ Shortcuts

consonoExit("Some value", null, null, 15); // Exit code - 15
consonoPlain("Some value"); // No colorization
consonoReturn("Some value"); // Return only, no `console.log`

๐Ÿ‘€ Discover more

  • ๐ŸŒ OF๐ŸŒ  - Promise wrapper with some sugar.

  • ๐Ÿ”ฉLocal Storage Fallback๐Ÿ”ฉ - Universal localStorage fallback.

  • ๐Ÿ”„Publish Subscribe๐Ÿ”„ - JavaScript implementation of the Publish-Subscribe pattern.

  • ๐ŸงฐVicis๐Ÿงฐ - Presentation and transformation layer for data output in RESTful APIs.

Or find useful these tools:

  • ๐ŸงพJSON Sorter๐Ÿงพ - Neat online JSON sorter.