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

@hux-js/hux

v0.3.0

Published

Hyperfast data management to enable next-gen UX

Downloads

1

Readme


Hux is a data management tool that abstracts API interaction, data processing and data storage away from the UI layer, leaving it free to do jobs it’s designed to do such as DOM interaction.

It acts as a source of truth, preventing data being duplicated or having shared ownership in and across the UI state.

It has a large focus on performance. Data is automatically optimised and all processes are run in web workers. This means we can front load large amounts of data rather than constantly having to retrieve ‘snapshots’ from an API, leading to better UX and more valuable visualisations.


Installation

NPM

npm i @hux-js/hux

Yarn

yarn add @hux-js/hux

Basic usage

Setting up your Buckets

This is the first step when using Hux. It allows you to define the APIs and schemas associated with the bucket, otherwise known as contracts. They may include what API you would call to fill the bucket with data, or what API you call when updating or POST'ing data.

Below you can see we are setting a unique name for the bucket, the GET API method and the POST API method. We also define the expected JSON schema.

Bucket({
  name: 'Users',
  hydrate: {
    url: 'http://localhost:3456',
  },
  sync: {
    url: 'http://localhost:3456/create',
    options: {
      method: 'POST',
    }
  },
  schema: {
    type: 'object',
    properties: {
      meta: { type: 'object' },
      users: { type: 'array' },
      userCount: { type: 'number' },
    },
    required: ['users'],
  },
});

Calling an API

After you've set up your bucket, you can use the hydrate function to fill it with data when required.

To immediately retrieve data from the bucket, you can add a query to the hydrate function. This will initially return cached data if available. When the latest API data returns from the server you can use the onUpdate property to push the fresh data to the UI.

const { users: cachedUsers } = await hydrate({
  name: 'Users',
  query: [
    'users',
  ],
  onUpdate: ({ users: freshUsers }) => updateUiWithFreshUsers(freshUsers)
});

Contributing

If you'd like to contribute please read our Code of Conduct & Contributing guides before doing so


Full Documentation - https://huxjs.org