Flow Like Water

TypeScript library for managing complex task workflows

TypeScriptNode.jsAutomation

Flow Like Water transforms complex command sequences into manageable state machines. Define each command as a discrete state and specify how these states transition between each other, complete with conditional logic and retry mechanisms.

Quick Start

Quick Start Example
1
Import
import { Task, TaskGroup, FlowControl } from 'flow-like-water'
2
Create Tasks
const task1 = new Task({ id: 'task1', execute: myFunction })
3
Group Tasks
const group = new TaskGroup('workflow')
4
Execute
await flowControl.run()

Key Features

  • Orchestrate complex sequences of tasks with dependencies
  • Handle both synchronous and asynchronous operations
  • Automatic retry with configurable backoff strategies
  • Group related tasks for collective execution
  • Track progress through event listeners
  • Persist state for long-running operations

Usage Example

workflow.ts
import { Task, TaskGroup, FlowControl } from "flow-like-water";

// Create tasks with retry logic
const downloadTask = new Task({
  id: "download",
  execute: async () => await downloadFile(),
  retries: 3,
  waitTime: 1000,
});

const processTask = new Task({
  id: "process", 
  execute: async () => await processData(),
  retries: 2,
});

// Group and execute
const workflow = new TaskGroup("data-pipeline");
workflow.addChild(downloadTask);
workflow.addChild(processTask);

const flowControl = new FlowControl();
flowControl.addGroup(workflow);

// Run the workflow
await flowControl.run();

Visual Flow

Flow