dmnsgn / value-inspector

Get a string representation of a value or an object. Pretty much like they look in Chrome DevTools.

Home Page:https://dmnsgn.github.io/value-inspector/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

value-inspector

npm version stability-stable npm minzipped size dependencies types Conventional Commits styled with prettier linted with eslint license

Get a string representation of a value or an object. Pretty much like they look in Chrome DevTools.

paypal coinbase twitter

Installation

npm install value-inspector

Usage

import inspect from "value-inspector";

const obj = {
  primitiveNull: null,

  valueUndefined: undefined,

  booleanTrue: true,

  textString: "a string",
  textRegExp: new RegExp("$ 🐈"),

  numberZero: 0,
  numberOne: 1,

  obj: {
    zero: 0,
    one: { two: 2, three: { four: 4 } },
  },

  fun() {},

  array: [0, 1],
  arrayTyped: Float32Array.of(0, 1),

  collectionMap: new Map([
    [0, "zero"],
    [1, "one"],
  ]),
  collectionSet: new Set([0, 1]),
  [Symbol("bar")]: "symbol-bar-value",

  promise: Promise.resolve(),
};

inspect(obj);

// =>
// {
//   array: (2)[0, 1]
//   arrayTyped: Float32Array(2)[0, 1]
//   booleanTrue: true
//   circularArray: [Circular]
//   circularObject: [Circular]
//   collectionMap: [object Map]
//   collectionSet: [object Set]
//   fun: [Function: fun]
//   numberOne: 1
//   numberZero: 0
//   obj: {
//     one: {
//       three: [object Object],
//       two: 2
//     },
//     zero: 0
//   }
//   primitiveNull: null
//   promise: Promise {}
//   textRegExp: /\$ 🐈/
//   textString: "a string"
//   valueUndefined: undefined
//   Symbol(bar): "symbol-bar-value"
// }

API

Functions

inspect(value, [options]) β‡’ string

Inspect a value.

Typedefs

Options : object

inspect(value, [options]) β‡’ string

Inspect a value.

Kind: global function Returns: string - A string representation of a value or an object.

Param Type
value *
[options] Options

Options : object

Kind: global typedef Properties

Name Type Description
depth number Specify levels to expand arrays and objects.

License

MIT. See license file.

About

Get a string representation of a value or an object. Pretty much like they look in Chrome DevTools.

https://dmnsgn.github.io/value-inspector/

License:MIT License


Languages

Language:JavaScript 99.0%Language:HTML 1.0%