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

@konko.oleg/mudria-plugin-async

v1.0.0

Published

Async/await consciousness for MUDRIA - asynchronous flow patterns

Readme

@konko.oleg/mudria-plugin-async

Asynchronous consciousness for MUDRIA - time-aware computation patterns

Overview

The MUDRIA Async Plugin adds comprehensive async/await capabilities through runtime functions, enabling asynchronous programming without modifying the core parser.

Installation

npm install @konko.oleg/mudria-plugin-async

Usage

const mudria = require('@konko.oleg/mudria-core');
const { MudriaPluginLoader } = require('@konko.oleg/mudria-plugin-loader');
const asyncPlugin = require('@konko.oleg/mudria-plugin-async');

// Register plugin
const loader = new MudriaPluginLoader(mudria);
loader.register(asyncPlugin);
const enhanced = loader.enhance(mudria);

// Now compile MUDRIA code with async functions
const result = enhanced.compile(`
  ∿ fetchData {
    ◉ getData: url → mudriaAwait(fetch(url))
    ◉ processAll: urls → asyncMap(urls, getData)
  }
`);

Functions Provided

Core Async Operations

mudriaAsync(fn)

Wrap a function to make it async

state: processData = mudriaAsync(data → {
  // This function is now async
  return heavyComputation(data)
})

mudriaAwait(promise)

Await a promise (works in pipelines)

fetchUser(id) | mudriaAwait | processUser

Parallel Execution

mudriaParallel(...tasks)

Execute tasks in parallel

parallel(
  () → fetchUser(1),
  () → fetchUser(2),
  () → fetchUser(3)
)
// Returns: [user1, user2, user3]

mudriaRace(...tasks)

Return first completed task

mudriaRace(
  () → fetchFromCache(id),
  () → fetchFromDB(id),
  () → fetchFromAPI(id)
)

Sequential Execution

mudriaSequential(...tasks)

Execute tasks one after another

sequential(
  () → connectDB(),
  () → authenticate(),
  () → fetchData(),
  () → closeDB()
)

Timing Operations

mudriaTimeout(ms, value)

Create a delayed value

mudriaTimeout(1000, "Hello after 1 second")

mudriaDelay(ms)

Delay pipeline function

getData() | delay(1000) | processData

Error Handling

mudriaRetry(fn, options)

Retry with exponential backoff

retry(
  () → unreliableAPI(),
  {
    attempts: 3,
    delay: 1000,
    backoff: 2,
    onError: (err, attempt) → console.log("Retry", attempt)
  }
)

Async Collections

asyncMap(collection, fn)

Async map over collections

state: urls = ["url1", "url2", "url3"]
asyncMap(urls, url → fetch(url))

asyncFilter(collection, fn)

Async filter collections

asyncFilter(files, async file → {
  state: stats = await fs.stat(file)
  → stats.size > 1000
})

asyncReduce(collection, fn, initial)

Async reduce operation

asyncReduce(
  chunks,
  async (result, chunk) → result + await process(chunk),
  ""
)

Advanced Patterns

mudriaAsyncPipe(...fns)

Compose async functions

state: pipeline = mudriaAsyncPipe(
  fetchData,
  validateData,
  transformData,
  saveData
)
pipeline(input)

mudriaDebounce(fn, wait)

Debounce async functions

state: search = mudriaDebounce(
  query → searchAPI(query),
  300
)

mudriaThrottle(fn, limit)

Throttle async functions

state: save = mudriaThrottle(
  data → saveToServer(data),
  1000
)

mudriaQueue(concurrency)

Rate-limited queue

state: queue = mudriaQueue(3)  // Max 3 concurrent

range(100) | forEach(i →
  queue.add(() → processItem(i))
)

Examples

Basic Async Operations

∿ dataFetcher {
  ◉ fetchUser: id → mudriaAwait(fetch("/api/user/" + id))
  
  ◉ fetchWithTimeout: id →
    mudriaRace(
      () → fetchUser(id),
      () → mudriaTimeout(5000, { error: "Timeout" })
    )
}

Parallel Data Processing

∿ imageProcessor {
  state: images = ["img1.jpg", "img2.jpg", "img3.jpg"]
  
  ◉ processAll: () →
    asyncMap(images, async img → {
      state: data = await loadImage(img)
      state: processed = await applyFilters(data)
      → await saveImage(processed)
    })
}

Sequential Workflow

∿ deployment {
  ◉ deploy: () →
    sequential(
      () → runTests(),
      () → buildProject(),
      () → uploadArtifacts(),
      () → updateServers(),
      () → notifyTeam()
    )
}

Error Recovery

∿ resilientAPI {
  ◉ getData: id →
    retry(
      () → fetchFromAPI(id),
      {
        attempts: 5,
        delay: 500,
        backoff: 2,
        onError: (err, n) → console.log("Attempt", n, "failed:", err)
      }
    )
}

Rate-Limited Operations

∿ crawler {
  state: queue = mudriaQueue(5)  // 5 concurrent requests
  state: urls = loadUrls()
  
  ◉ crawlAll: () →
    asyncMap(urls, url →
      queue.add(() → crawlPage(url))
    )
}

Integration with Loops Plugin

Combine with @mudria/plugin-loops for powerful patterns:

∿ batchProcessor {
  ◉ processBatches: items →
    // Process items in batches of 10
    mudriaComprehension(
      range(0, items.length, 10),
      i → items.slice(i, i + 10)
    ) | asyncMap(batch →
      parallel(...batch.map(item → () → processItem(item)))
    )
}

Philosophy

This plugin extends MUDRIA's consciousness into the temporal dimension:

  • Parallel consciousness: Multiple operations existing simultaneously
  • Sequential consciousness: Ordered flow through time
  • Resilient consciousness: Recovery from temporal failures
  • Rate-aware consciousness: Respecting system boundaries

Best Practices

  1. Use parallel() for independent operations
  2. Use sequential() for dependent operations
  3. Always handle errors with retry() for network operations
  4. Use queue() to prevent overwhelming external services
  5. Combine debounce() and throttle() for UI operations

License

MIT


"Asynchronous code is consciousness dancing with time"