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

worldview

v0.1.3

Published

small library for managing nested global state object with listeners

Readme

worldview

A small library for managing a nested global state object with listeners.

  • uses global immutable data structure to hold state
  • uses dot notation to refer to nested path (e.g. 'things.like.this')
  • batches updates using requestAnimationFrame/setImmediate/setTimeout
  • atomic updates by passing a function
  • read-only cursors
  • writable cursors
  • compound cursors
  • derived values with function
  • cursor/compound/derived values can be nested arbitarily (hopefully)
  • can efficiently listen for changes on any of the above
  • works in browser or in node/io
  • written in es6, babel'd to es5
  • no dependencies
  • exploratory/experimental state, use cautiously in production

Examples

Update a simple value

var world = require('worldview');

world.listen(function(state){
  console.log('the state of the world is', state);
});

world.update('name', 'Earth');

Use all the cool things at once

var world = require('worldview');

// readonly cursors
var nick = world.at('people.nick');
var peter = world.at('people.peter');

// they keys a/b let me refer to them in the listener by key
var nickAndPeter = world.compound({ a: nick, b: peter });

var derived = nickAndPeter.derive(function(obj){
  // it will be initialized with { a: undefined, b: undefined }
  // I'm not sure if this is a good thing or not
  if (obj.a && obj.b) {
    return 'nick is ' + obj.a.age + ' and peter is ' + obj.b.age;
  }
});

// these will get called whenever people.nick or people.peter changes
// after having been run through the derivation function above
derived.listen(function(status){
  console.log('status:', status);
});

// these updates will be batched
world.update('people.nick', { age: 31 });
world.update('people.peter', { age: 35 });

setTimeout(function(){
  // 10 years passes...
  world.update('people.nick', { age: 41 });
  world.update('people.peter', { age: 45 });
}, 1000);

What do you mean by efficient updates?

Well, it uses immutable values so all comparisons are just object identity ones. These are very fast. This means trees can be diff'd very quickly, but I also traverse the trees with the listeners, if there are no listeners for that part of the tree we don't need to even do the object comparisons.

To achieve this the listeners are stored globally, this also means they can be combined so there is no penalty for having lots of listeners on the same path, the time to find the listeners only grows with the number of unique paths being listened on.

How to use it?

npm install worldview
var world = require('worldview');
// ... etc