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

wheeling

v3.1.1

Published

A flat utility to easily chain any number of tasks & turn any event listening to infinite async iterables

Downloads

9

Readme

wheeling

A flat utility to easily chain any number of tasks & turn any event listening to infinite async iterables

Demo

Demo sources

Install

Using NPM

npm i wheeling

Using JSPMI

jspmi i wheeling

Examples

App initialization

// apps.js
import init from 'wheeling/init'

export const app = init()

Create a task on an iterable

import task from 'wheeling/task'
import { app } from './apps.js'

// logs every value
export const logger = task(app, [1, 2, 3], console.log)

Create a skippable task

import skip from 'wheeling/skip'
import task from 'wheeling/task'
import { app } from './apps.js'

// logs every value, except the 2
export const logger = task(app, [1, 2, 3], value => {
  if (value === 2) {
    throw skip
  }
  
  console.log(value)
})

Create any forks of an iterable

import fork from 'wheeling/fork'
import task from 'wheeling/task'
import { app } from './apps.js'

const logger = task(app, [4, 5, 6], console.log)

// logs every value... twice!
export const forks = fork(app, logger, 2)

Create an input/output

import io from 'wheeling/io'
import task from 'wheeling/task'
import { app } from './apps.js'

const [input, output] = io(app)

// logs every value
export const reader = task(app, output, console.log)

queueMicrotask(async () => {
  await input.next(7)
  await input.next(8)
  await input.next(9)
  await input.return()
})

Create an iterable listener

import listen from 'wheeling/listen'
import preventDefault from 'wheeling/hooks/preventDefault'
import task from 'wheeling/task'
import { app } from './apps.js'

const onClick = listen(app, document.body, {
  type: 'click',
  hooks: [
    preventDefault
  ]
})

// logs every { event: click }
export const logOnClick = task(app, onClick, console.log)

Autorun the iterables

import add from 'wheeling/add'
import { app } from './apps.js'
import { logger } from './logger.js'
import { forks } from './forks.js'
import { reader } from './reader.js'
import { logOnClick } from './logOnClick.js'

await add(app, [
  logger,
  ...forks,
  reader,
  logOnClick
])

Revoke an app

import revoke from 'wheeling/revoke'
import { app } from './apps.js'

// stops all the iterators registered for that app
revoke(app)

API

wheeling / wheeling/dist

wheeling/init

app = init()

Initialises an app, returning its promise used for every library functions

wheeling/add

async add(app, [...iterables])

Runs any number of provided iterables

wheeling/fork

iterables = fork(app, iterable, length = 2)

Returns an array of iterables reading the provided one

wheeling/io

[input, output] = io(app)

Returns an array containing

  • input: an iterable used to write to the output one
  • output: an iterable used to read the input one

wheeling/listen

iterable = listen(app, target, listener)

Returns an iterable listening an event type

The target must be an EventTarget

The listener must be an object containing

  • hooks: an array of functions executed synchronously when an event triggers
  • type: MANDATORY* the event type
  • ...options: see options

Yields an object like this: { event, target }, where the target is event.currentTarget ?? event.target

Additionally, it can have { reject, resolve } if any listener hooks returns a thenable object, like a promise (Mostly useful for the ServiceWorker)

revoke(app)

Stops all the added iterables and the app itself (Mostly useful to launch a new version of the app)

wheeling/hooks

  • wheeling/hooks/awaitUntil
  • wheeling/hooks/preventDefault
  • wheeling/hooks/respondWith
  • wheeling/hooks/stopImmediatePropagation
  • wheeling/hooks/stopPropagation

wheeling/options

  • wheeling/options/capture
  • wheeling/options/once
  • wheeling/options/passive

wheeling/skip

An error to throw into a task, to skip an iteration

License

MIT