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

propagator.js

v0.0.3

Published

A propagator library borrowing heavily from Radul & Sussman's The Art of the Propagator

Downloads

11

Readme

Build Status Coverage Status

Cells

Found at propagator-cell.js
Cells carry a value and a list of propagators to update when the value changes

methods:

  • constructor: returns a new cell with no value
  • update: changes the value stored at this cell and runs every attached propagator, optionally takes a second argument to identify the caller and lock the cell to that caller only.
  • addListener: adds a new propagator to the list to update, should only be called from within a propagator instance
  • getContents: returns the value stored at this cell

Probes

Found at probe.js
Attaches a console.log probe to a cell so you can see when that cell changes.

usage: probe(string name,Cell cell) output: name : value

Propagators

Found at propagator.js
Propagators do something with a value when it has changed. They carry no state, they are purely a function of cells. Propagators will not run until all their upstream cells hold values.
This is the primary interface to the module, you can access all constructors as methods on the Propagator object.

methods:

  • constructor: takes a function, a list of input cells, an output cell, and optionally a merge-strategy function. Registers a function on the input cells that sets the output cells whenever the input cells change value.
  • makeCell: returns a newly created blank cell.
  • addProbe: adds a probe with a "name" to a Cell. Api as listed for probe.js
Merge Strategy Function:

A function (optionally) passed to the propagator constructor. It is called by the cell when the propagator tries to update a cell that already holds a value, and merges the new value with the old value to provide a new value for the cell.

  • It is given three arguments (previousValue, UpdatedValue and cellHistory), it should return a new value for the cell.
  • If no merge-strategy is passed to the propagator constuctor, the default merge strategy (called update) is used. Update simply overwrites the old value with the new value.

Constants

Not implemented yet
Constants are propagators which only set a scalar value to their output cells.
Can easily be created by making a propagator with an function that always returns a single value and attaching it to an internal cell.

methods:

  • constructor: takes a value and a list of cells. Creates a function that always returns that value, and binds that function to its output cells.