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

monadic-progress

v0.0.6

Published

Progress tracking monad

Readme

Build Status Coverage Status bitHound Code bitHound Overall Score

Monadic-progress

A tiny library designed to simplify common progress tracking tasks (i.e. worker-based background processing, http polling) and assure value safety by 'swallowing' unsafe values and automating comparisons across subsequent chain calls. Makes heavy use of Ramda and Ramda-adjunct, written in a (mostly) functional manner.

Installation:

npm i -s monadic-progress

Example usage:

Import one of the default factories

const { array: Progress } = require('monadic-progress')
const progress = Progress.of([42])
//or
const { value: Progress } = require('monadic-progress')
const progress = Progress.of(42)

or the basic Progress factory function (keep in mind, that unlike factories, this one requires some configuration):

const Progress = require('monadic-progress/src/Progress')
const progress = Progress.({ options }, 42)

The Default array factory expects chain (aka bind) and map input to be wrapped in an array (non-array types are considered unsafe and ignored). This is because it runs Ramda's 'difference' against last two values. The following code will evaluate to 'None' for that reason:

const progress = Progress.of(["initial state"])
  .chain(prev => Progress.of(prev, ["some other state"]))
  .chain(() => undefined)
  .chain(() => Progress.of(["some other state"]))
  .chain(() => Progress.of(null)
  .chain(() => Progress.of(["different state"]))
  .chain(() => 5))

console.log(progress.flatten()) //prints 'None {}'

This snippet will print '[42]' though:

const progress = Progress.of(["initial state"])
  .chain(prev => Progress.of(prev, ["some other state"]))
  .chain(() => undefined)
  .chain(() => Progress.of(["some other state"]))
  .chain(() => Progress.of(null)
  .chain(() => Progress.of(["different state"]))
  .chain(() => [42]))

console.log(progress.flatten()) //prints [42]

This behaviour is configurable via opts argument of the Progress factory function. Default factories preconfigure it with a set of 3 functions, the process of customising the configuration is as simple as defining a new set and passing it to the aforementioned Progress factory function.

Expected functions are:

valueSafe -> boolean Run against all the values known to Progress instance. Comparison (flatten / join) will return 'None' if any value evaluates to false. Defaults to 'F'. Array factory uses 'isArray' and value factory defaults to 'isNotNil'.

compare -> any Run against last two values in reversed order, defaults to 'None', Array factory uses 'difference' and value factory defaults to negated 'equals'.

differs -> boolean Run against comparison result to determine whether it should be considered a match, 'None' is returned in other case. Defaults to false. Array factory uses 'isNotEmpty' and value factory defaults to 'isNotNil'.

Check 'demo' for alternative configuration examples.

Build

Powered by 'Rollup' and 'Runjs'

Run npx run build or use the command defined under the build task in 'runfile.js'.

By default, Rollup will build umd, Commonjs and ES6 compatible bundles, adjustment can be achieved by changing the contents of 'formats' array inside the rollup.config.js file.

Test

Run npx run test or use the command defined under the 'test' task in the 'runfile.js'.

Demo

Run npx run demo for an example of Progress run against a fake http server with array factory. Accepts two arguments --method=[pull|push] (defaults to 'push') and --type=[default|int-equals|int-subtract] (surprisingly, defaults to default). The type argument is used by the demo artifacts to build the require path for the subfolder where data and options files are kept.

API

To create an instance of Progress monad run:

const { array: Progress } = require('monadic-progress')
const progress = Progress.of([value])

or

const Progress = require('monadic-progress/src/Progress')
const progress = Progress({ options }, 42)

Functor-like mapping:

const { array: Progress } = require('monadic-progress')

const progress = Progress.of([42]).map(x => [...x, 5])
console.log(progress.join()) //prints [5] 

Flat mapping ( aka bind / chain ):

const { array: Progress } = require('monadic-progress')

//implicit value lift
const progress = Progress.of([42]).fmap(x => [...x, 5])
console.log(progress.join()) //prints [5]

//explicit value lift
const progress = Progress.of([42]).fmap(x => Progress.of(x, [5]))
console.log(progress.join()) //prints [5]

Flatten (aka join / value):

const { array: Progress } = require('monadic-progress')

const progress = Progress.of([42]).fmap(x => Progress.of(x, [5]))
const value = progress.join()
console.log(value) //prints [5]

Peek (aka log):

const { array: Progress } = require('monadic-progress')

const progress = Progress.of([42]).fmap(x => Progress.of(x, [5]))
const entries = progress.peek()
console.log(entries) //prints [[42],[5]]

The None type

The default value returned by the join / flatten method if no difference is found across subsequent calls or one of the last two values evaluates to unsafe. Exposes static spec method for convenience.