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 🙏

© 2025 – Pkg Stats / Ryan Hefner

jabr

v0.3.1

Published

No-nonsense State Management

Downloads

34

Readme

Jabr

No-nonsense State Management! No more boilerplate hell :)

Basics

Jabr is very simple, first we create a store object.

const {Jabr} = require('jabr')
const store = new Jabr()

This store object is used just like any other object in Javascript. We can read and modify properties without any special methods.

store.a = 12
console.log(store) // Logs 12

Event Listeners

Now the magic here is that we can attach listeners to our store. Whenever we modify the store our callback function is called with the new data. Let's look at an example:

store.on('a', value => {
	console.log(value)
})
store.a = 12 // Logs 12

Jabr triggers the callback function without requiring us to call any methods. It does this by using the Proxy API under the hood, but you don't need to worry about that unless your runtime doesn't support it (all modern Javascript Environments do).

Initializing the Store

We can intialize our store by supplying it with an object in the constructor.

const {Jabr} = require('jabr')
const store = new Jabr({b: "Long John Silvers"})

console.log(store.b) // Logs "Long John Silvers"

Configuring Property Options

You can pass additional options for each store property by passing a map of option objects for each property. There are a number of features you can supply, including data validation using Sandhands formats, normalization, and more

format

The format option can be used to ensure your data is properly formatted

const {Jabr} = require('jabr')
const store = new Jabr({age: 37}, {age: {format: Number}}) // Our store will now throw an error if we attempt to make age anything besides a number (it can still be deleted)

compute

Passing a function as the compute option will allow you to create a property whose value is computed on the fly.

const {Jabr} = require('jabr')
const store = new Jabr({}, {random: {compute: ()=>Math.random()}})
console.log(store.random) // Returns a new random value every time it is accessed

Properties that are computed on the fly cannot be assigned and do not trigger callbacks

default

When the default option is provided, if our property does not have a value currently and we access it the default value will be returned

Synchronizing store to JSON file

We can use the syncToJSON method in order to synchronously save our store to a JSON file. It will also read any existing values in the JSON file.

const {Jabr, syncToJSON} = require('jabr')
const store = new Jabr()
syncToJSON(store, 'data.json') // Loads any existing data in data.json (if it exists), overwriting any conflicting properties in the store
store.snack = "cookie" // Synchronously saves this data to the data.json file when we modify the store