https://github.com/dmnsgn/value-inspector
Get a string representation of a value or an object. Pretty much like they look in Chrome DevTools.
https://github.com/dmnsgn/value-inspector
inspect inspector object prettify stringify
Last synced: 2 months ago
JSON representation
Get a string representation of a value or an object. Pretty much like they look in Chrome DevTools.
- Host: GitHub
- URL: https://github.com/dmnsgn/value-inspector
- Owner: dmnsgn
- License: mit
- Created: 2024-03-26T23:41:56.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-12T13:51:44.000Z (10 months ago)
- Last Synced: 2025-04-20T22:32:53.079Z (6 months ago)
- Topics: inspect, inspector, object, prettify, stringify
- Language: JavaScript
- Homepage: https://dmnsgn.github.io/value-inspector/
- Size: 1.15 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# value-inspector
[](https://www.npmjs.com/package/value-inspector)
[](https://www.npmjs.com/package/value-inspector)
[](https://bundlephobia.com/package/value-inspector)
[](https://github.com/dmnsgn/value-inspector/blob/main/package.json)
[](https://github.com/microsoft/TypeScript)
[](https://conventionalcommits.org)
[](https://github.com/prettier/prettier)
[](https://github.com/eslint/eslint)
[](https://github.com/dmnsgn/value-inspector/blob/main/LICENSE.md)Get a string representation of a value or an object. Pretty much like they look in Chrome DevTools.
[](https://paypal.me/dmnsgn)
[](https://commerce.coinbase.com/checkout/56cbdf28-e323-48d8-9c98-7019e72c97f3)
[](https://twitter.com/dmnsgn)
## Installation
```bash
npm install value-inspector
```## Usage
```js
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) |
## Options : object
**Kind**: global typedef
**Properties**
| Name | Type | Default | Description |
| ------------------ | ------------------- | ------------------------------------- | -------------------------------------------- |
| [depth] | number
| 2
| Specify levels to expand arrays and objects. |
| [stringLength] | number
| Number.POSITIVE_INFINITY
| Length to truncate strings. |
| [collectionLength] | number
| Number.POSITIVE_INFINITY
| Length to slice arrays, Map and Set. |
| [objectLength] | number
| Number.POSITIVE_INFINITY
| Length to truncate object keys. |
## License
MIT. See [license file](https://github.com/dmnsgn/value-inspector/blob/main/LICENSE.md).