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

@piyushagade/waterfall

v1.0.6

Published

Create waterfall tasks, execute them sequentially or asynchronously, and manage task metadata.

Readme

Waterfall.js

Waterfall.js is a lightweight JavaScript library for managing and executing tasks in a sequential or parallel manner. It supports both synchronous and asynchronous task execution, making it ideal for workflows where tasks depend on each other or need to be executed in a specific order.

Installation

You can include Waterfall.js in your project via a CDN:

<script src="https://cdn.jsdelivr.net/npm/@piyushagade/waterfall@latest/waterfall.js"></script>

Alternatively, you can install it using npm:

npm install @piyushagade/waterfall

Usage

Basic Setup

  1. Include the waterfall.js script in your HTML file.
  2. Initialize the Waterfall instance with optional configuration.
  3. Define and execute tasks.
// Initialize Waterfall
const wf = Waterfall({
    options: {
        synchronous: true, // Execute tasks synchronously (default: true)
        verbose: true       // Enable logging (default: false)
    },
    variables: {
        test: "Initial Value" // Shared variables across tasks
    }
});

// Set tasks
wf.setTasks([
    (next, skip, variables, taskId) => {
        console.log("Task 1");
        variables.stage1 = "executed";
        next(); // Proceed to the next task
    },
    (next, skip, variables, taskId) => {
        return new Promise((resolve) => {
            setTimeout(() => {
                console.log("Task 2 (async)");
                variables.stage2 = "executed";
                resolve(); // Proceed to the next task
            }, 2000);
        });
    },
    (next, skip, variables, taskId) => {
        console.log("Task 3");
        variables.stage3 = "executed";
        next(0.5); // Partial progress (pressure)

        setTimeout (() => {
            next(0.5);  // Move to next task when the total pressure is 1
        });
    }
]);

// Execute tasks
wf.executeTasks().then((next, skip, variables, lastTaskId) => {
    console.log("All tasks completed");
    console.log("Final variable:", variables);
});

Key Features

  • Synchronous and Asynchronous Execution: Tasks can be executed sequentially or in parallel.
  • Task Management: Add, delete, or modify tasks dynamically.
  • Shared Variables: Pass and modify variables across tasks.
  • Progress Control: Use next(fraction) to control task progress or skip() to skip the next task.
  • Verbose Logging: Enable detailed logging for debugging.

API Reference

Waterfall(options)

Initializes a new Waterfall instance.

  • options (object):
    • synchronous (boolean): Whether tasks should execute synchronously (default: true).
    • verbose (boolean): Enable verbose logging (default: false).
  • variables (object): Shared variables accessible across tasks.

setTasks(tasks)

Sets an array of tasks to be executed.

  • tasks (array): An array of functions or promises. Each task receives next, skip, variables, and taskId as arguments.

addTask(task)

Adds a single task to the task list.

  • task (function): A function or promise to be executed.

deleteTask(id)

Deletes a task by its ID.

  • id (string): The ID of the task to delete.

executeTasks()

Executes all tasks. Returns a promise that resolves when all tasks are completed.

setVariables(variables)

Updates the shared variables.

  • variables (object): New variables to merge with existing ones.

Example Use Cases

  • Data Processing: Execute a series of data transformations sequentially.
  • Workflow Automation: Manage complex workflows with dependencies between tasks.
  • UI Rendering: Control the rendering order of UI components.

Contributing

Contributions are welcome! If you'd like to contribute, please fork the repository and submit a pull request.

License

Waterfall.js is licensed under the MIT License. See the LICENSE file for more details.

Author


Enjoy building robust workflows with Waterfall.js! 🚀 EOL

echo "README.md created successfully!"