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

purple-tea

v0.3.3

Published

Light-speed and feather-weight state container for JavaScript app

Readme

Purple Tea

Light-weight state container for JavaScript app.

Store which doesn't hurt.

Purple Tea is very light-weight state container for JavaScript app. It contain shared state for JavaScript create( to access on any piece of code.
Purple tea is inspired by Redux but with only a simple and handy logic. Under the hood, it use a simple collection of JavaScript API which supported since IE 9.

Purple Tea feature:

  • A very light-weight storage: 0.6KB (gzipped).
  • Very high performance operation.
  • Middleware support.
  • Readable error message, easier to debug.
  • As simple as LocalStorage.
  • Get realtime storage change.
  • TypeScript support.
  • Support on every browser even IE 10.

Readable error

One thing people most hate about, unreadable error by human. It's very annoying yet not productive to anyone.
Purple tea error is readable by human and suggested a way to resolve.

let tea = new Store()

// Create "sugar" store with initial value of { amount: 0 }

tea.create("sugar", { amount: 0 }) // { amount: 0 }
tea.create("sugar", { amount: 0 }) // sugar is already existed.

A simple way to create store

Purple Tea is very easy to be created, maintained, and debugged. It's just a collection of simple API under the hood.

Create Store

Let's create a simple store with Purple Tea.
Purple Tea is created with class to contain reusable collection of function.

import Store from "purple-tea"

let tea = new Store()

create() will handle storage creation. It require name and initial storage value.

let tea = new Store()

tea.create("sugar", { amount: 0 })

This will create a store name "sugar" with initial value of { amount: 0 }.

Get data

get() is introduced here, to retrieve data in the storage.

let tea = new Store()

tea.create("sugar", { amount: 0 })

tea.get("sugar")         // { amount: 0 }
tea.get("sugar").amount  // 0

If you get data from storage which isn't existed, it'll return error.

let tea = new Store()

tea.get("sugar") // sugar isn't existed. Please create it with create("sugar")

tea.create("sugar", { amount: 0 })
tea.get("sugar") // { amount: 0 }

tea.get("salt") // salt isn't existed. Please create it with create("sugar")

Update store

Mutate storage data, doesn't overwrite existed value if new value is not provided.

let tea = new Store()

tea.create("sugar", { amount: 0 })
tea.get("sugar") // { amount: 0 }

tea.update("sugar", { amount: 1 })
tea.get("sugar") // { amount: 1 }

Set store

Overwrite a storage. Store's value will be overwriten. It take store name and value.

let tea = new Store()

tea.create("sugar", { ingredient: "sugar", amount: 0 })
tea.get("sugar") // { ingredient: "sugar", amount: 0 }

tea.set("sugar", { amount: 0 })
tea.get("sugar") // { amount: 0 }

Subscribe to the storage

Purple tea is able to subscribe to the storage change in real-time.

import Store from "./purple.ts"

let tea = new Store()

tea.create("sugar", { amount: 0 })

// Trigger when store is updated.
tea.subscribe("sugar", data => {
    console.log(data) // Get current value of sugar. eg. { amount: 1 }
})

tea.update("sugar", { amount: 1 })

// Support multiple listener at once.
tea.subscribe(["sugar", "milk"], data => {
    console.log(data) // Get current value of sugar. eg. { amount: 1 }
})

Middleware

A function which invoked before operation succeed. Mutate store data is recommended here.

import Store from "./purple.ts"

let tea = new Store()

tea.applyMiddleware((store, process) => {
  console.log(store, `Process: ${process}`) // { amount: 0 } Process: create(
  return store
})

tea.create("sugar", { amount: 0 })
  • list - Get every store name.

    store.create("sugar", {})
    store.list() // ["sugar"]
  • model - Get collection of store's model. An equivalent to Object.entries()

    store.create("sugar", {
      amount: 0
    })
    store.model() // [
      [
        0: "sugar",
        1: { amount: 0 }
      ]
    ]