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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@focuson/view

v0.2.31

Published

Used when we want to view data from one or more APIs.

Readme

State fetch

A common pattern in GUIs is 'showing the data revealed by an API'. For example we might show the data in shopping site, or show account data about customers.

When doing this typically there is a navigation area which determines what is being looked at, and then multiple places that show information about what is being looked at. Each time the state is changed a decision needs to be made about whether to get more information from the backing API(s).

The strategy adopted is to have a 'tag' field in the state which describes the type of the display being shown. This tag is linked to a set of functions that allow state-fetcch to decide when to load state information.

Key Concepts

State

This uses the state defined in the project @focus-on/state. The state is a javascript object with one or more lens focused on different parts of it which allows it to be 'modified' using the usual 'immutable' meaning of modified (i.e. copied and the copy updated)

View

The state will have (names all configurable - the following is just the normal names)

  • A view field that holds a string defining the current view. It is used as a key into the ViewState
  • A mainItem that is either undefined or the current mainItem the view is focused on
  • A selectionState that holds information allowing the mainItem to be fetched (e.g. one or more ids)

View state

Given the name of a view, the view state defines

  • How to display it
  • How to fetch it from the back end
  • How to work out whether it needs to be fetched

Parent Views

Some views depend on parents, and the parent data has to be loaded first. For instance if we are displaying an item in a collection there could be a view for the collection which should be loaded before the item is loaded.

This is handled using parentView

setJsonUsingView

This is the helper method that makes it all work. This controls the rendering.

Generics in View

View store has the signature ViewStore<State, Element>. State is the javascript object that defines the state the view will be looking at. Element will usually be a JSX.Element, but is defined as a generic to avoid binding to any specific library. Thus you can use this with any version of react

Displaying the view

The @focuson/view-components project has the MainView component. It is bound to a particular version of react, but you can just copy it if you want a different version.