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

warg

v2.1.1

Published

A basic stream/reactive library designed to make dirty reads impossible

Downloads

2,283

Readme

A basic reactive/stream library

This library is designed to make dirty reads impossible - i.e. your computed properties will only be called when there is a consistent state for them to run on.

This library runs calculations synchronously and eagerly. If you have a ton of upstream data changing and want lazy calculations, use shiz.

Install

npm i warg

CommonJS:

const { value, computed } = require('warg')

ESM:

import { value, computed } from 'warg'

Examples

const numbers = value([ 1, 2, 3, 42, 69])
const factor = value(2)
const multipliedArray = computed({
	numbers,
	factor,
}, ({ numbers, factor }) => numbers.map(number => number * factor))

multipliedArray.get() // => [ 2, 4, 6, 84, 138 ]

API

wargObservable = value(initialValue)

Returns a warg observable with a set method.

const wat = value('sup')

wat.get() // => 'sup'

wat.set('dawg')

wat.get() // => 'dawg'

wargObservable = computed(dependencies, computeFunction)

Returns a warg observable that takes in an object of dependencies and returns a new warg observable that combines them together with your given function.

const small = value(1)

const bigger = computed({
	number: small
}, ({ number }) => number + 1)

const multiplied = computed({
	a: small,
	b: bigger,
}, ({ a, b }) => a * b)

multiplied.get() // => 2

Warg observable

Besides any methods above, warg observables have these methods:

wargObservable.get()

Returns the current value.

newWargObservable = wargObservable.map(computeFunction)

Sugar for newWargObservable = wargObservable.compute({ observable }, ({ observable }) => computeFunction(observable)).

const a = value(6)
const special = a.map(value => value * 7)
special.get() // 42

unsubscribe = wargObservable.subscribe(callback)

Calls the callback function whenever the observable value changes.

Also calls the callback function with the current value right away when subscribe is called.

value('whu?').subscribe(str => {
	str // => 'whu?'
})

Events

Warg observables are also event emitters, though the events are more for internal library use. You probably won't need them.

These events are fired:

  • dirty - fired whenever a warg observable knows that it, or one of its dependencies, is changed. You may not read from the observable after this point, until it finishes resolving.
  • value - fired whenever a warg observable is resolved and becomes readable again - essentially, whenever its value has changed.

Because warg resolves all changes synchronously in the same tick, you should never need to worry about values becoming dirty and resolving themselves. That all happens behind the scenes before your set call completes.

License

WTFPL