npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue3-object-inspector

v0.1.1

Published

Vue component used as an js/json object inspector/viewer

Downloads

14

Readme

vue3-object-inspector

Vue component used as an js/json object inspector/viewer, inspired by vue-object-inspector and react-inspector .

Nodes will not be rendered if parent is collapsed.

Online Playground

Online Playground:

https://codesandbox.io/s/vue-object-inspector-demo-gjs9h?file=/src/components/InspectorDemo.vue

https://codesandbox.io/s/vue-object-inspector-demo-dark-bouxd?file=/src/components/InspectorDemo.vue

Examples

Usage

npm install vue3-object-inspector

In Vue component:

<template>
  <div>
    <object-inspector :data="data" />
  </div>
</template>

<script>
import ObjectInspector from 'vue3-object-inspector'

export default {
  name: 'your-component',
  components: {
    ObjectInspector,
  },
  data() {
    return {
      data: {
        a: 1,
        b: 'abc',
        c: [1, 2, 3],
        d: { x1: 1, x2: 2 },
      },
    }
  },
}
</script>

Vue props

This component supports some Vue props, similar to react-inspector , just a bit different.

data

  • what: JavaScript Object or any var you would like to inspect
  • type: any
  • mandatory: true

name

  • what: root node prefix name
  • type: String
  • mandatory: false

expandLevel

  • what: an integer specifying to which level the tree should be initially expanded
  • type: Integer
  • mandatory: false
  • default: 0

expandPaths

  • what: an array containing all the paths that should be expanded when the component is initialized, or a string of just one path
  • type: Array of String
  • mandatory: false
  • details: syntax like JSONPath
  • default: []
  • examples:
    • ['$']: expand root node, $ always refers to the root node
    • ['$.myKey']: expand to myKey node (will also expand all parent nodes)
    • ['$.myKey.myArr']: expand to myArr node (will also expand all parent nodes)
    • ['$.a', '$.b']: expand first level nodes a and b
    • ['$.1']: expand by array index
    • ['$.*']: wildcard, expand all level 2 nodes, equivalent to :expandLevel="2"
    • ['$.*.*']: wildcard, expand all level 3 nodes, equivalent to :expandLevel="3"

expandPaths vs expandPaths

Both are reactive.

In most case, don't use both at the same time.

One of them changes, only the changed one will take effect and ignore the other one.

If want to expand all level, change expandLevel to a very big number.

If want to collapse all level, change expandLevel to 0.

If already change expand by hand, change the expandLevel to a nagative number, then change it back in $nextTick.

showNonenumerable

  • what: show non-enumerable properties, like __proto__, length, constructor ...
  • type: Boolean
  • mandatory: false
  • default: false

sortObjectKeys

  • what: sort object keys like Array.sort()
  • type: Boolean or Function
  • mandatory: false
  • default: no sort
  • examples:
    • true: keys of objects are sorted in alphabetical order except for arrays
    • function in Vue component methods:
      reverseSortFunc(a, b) {
        return b > a ? 1 : -1
      }

nodeRenderer

  • what: use a custom nodeRenderer to render the object properties
  • type: Function, should return JSX elements
    • function parameters: depth, name, data, isNonenumerable
    • isNonenumerable refers to default hidden properties like __proto__, length ...
  • mandatory: false
  • default: a default nodeRenderer
  • examples:
    • function in Vue component methods:
      myNodeRenderer(depth, name, data, isNonenumerable) {
        return (
          <button>
            {name}: {data}
          </button>
        )
      }

objectMaxProperties

  • what: max count object properties should be list in preview label
  • type: Interger
  • mandatory: false
  • default: 5

arrayMaxProperties

  • what: max count array properties should be list in preview label
  • type: Interger
  • mandatory: false
  • default: 10

theme

  • what: use light or dark theme
  • type: String
  • mandatory: false
  • default: light theme, keep this prop empty
  • dark theme value: chromeDark

Development

Local preview page is example/App.vue .

# Install dependencies
npm install

# Compiles and hot-reloads for development
npm run serve

# Compiles and minifies for production
npm run build

Thanks