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

@devtools-ds/object-inspector

v1.2.1

Published

An emulation of the Chrome and Firefox object inspector, which allows you to view JavaScript objects in the console.

Downloads

1,127,975

Readme

@devtools-ds/object-inspector

An emulation of the Chrome and Firefox object inspector, which allows you to view JavaScript objects in the console.

Installation

npm i @devtools-ds/object-inspector
# or with yarn
yarn add @devtools-ds/object-inspector

Supported Types

JavaScript has a broad and sometimes complicated set of available types. This component attempts to display most types nicely, and we have styles for the following:

export type SupportedTypes =
  | boolean
  | null
  | number
  | string
  | Error
  | symbol
  | undefined
  | Date
  | RegExp
  | object
  | Map<any, any>
  | WeakMap<any, any>
  | Set<any>
  | WeakSet<any>
  | Promise<any>
  | any[]
  | Function;

For types it doesn't know about, the component should try to find a name or string to display.

Usage

Then to use the component in your code just import it!

import { ObjectInspector } from "@devtools-ds/object-inspector";

const data = {
  string: "string",
  boolean: true,
  number: 100,
};

<ObjectInspector data={data} expandLevel={1} sortKeys={true} />;

Callbacks

onSelect

This function is called with the selected AST node (after parsing the data prop with @devtools-ds/object-parser). With the selected node, you're able to traverse up/down the tree, and act on the currently selected node (like displaying additional details about that property).

FAQ

Why is [insert type] type not supported better?

Some types like WeakSet, WeakMap, etc. cannot be easily inspected using the JavaScript APIs. Promises are similar, although there is a workaround using Promise.race that forces most things in this component to be asynchronous. The reason they work nicely in the browsers is because they have access to the JavaScript engine APIs which gives them a lot more control.

If you see a type that is missing and easy to support, feel free to open an issue or PR to add it.

Why does [insert property] property not always match my browser?

I had a goal with this project to look at both the Chrome and Firefox inspectors to ideally support theming based on browser. Sometimes things couldn't be themed simply between the two and compromises were made. For example Chrome mixes a double underscore syntax like __proto__ with a double bracket syntax like [[Entries]]. Firefox is much more consistent with a <prototype> and <entries> syntax so I decided to stick with that. There were some compromises in both directions for consistency.

I'm open to suggestions on ways this can be improved.

Why is [insert property] color slightly different?

For the most part, the colors should be near identical to the browser implementations.

Sometimes there were complicated colors across browsers, where one might take three colors to do what the other does in one. These were basically evaluated case-by-case looking at the added complexity. Sometimes browsers had colors that were really light and had really bad contrast. In the interest of accessibility I sometimes left these a bolder color.

Useful References

Contributors ✨

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!