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

@node-yalc/utils

v0.3.7

Published

Yalc Node module

Downloads

4,968

Readme

npm version License

🚀 Installation

npm install @node-yalc/utils
# or
yarn add @node-yalc/utils
# or
pnpm add @node-yalc/utils

🛠️ Core Utilities & Concurrency Control (@node-yalc/utils)

💡 1. What It Is & Architectural Purpose

@node-yalc/utils is the high-performance utility and concurrency execution library of @node-yalc. It was designed to provide memory-efficient object mapping, concurrency-limited task runners (runConcurrently), deep object sanitization, and serialization helpers without introducing heavy third-party utility dependencies like lodash or async.


⚙️ 2. What It Does & Key Features

  • Concurrency Execution Runner (runConcurrently): Bounded asynchronous task runner preventing Event Loop queue overload.
  • Deep Object Sanitization (sanitizeObject): Strips undefined, null, or sensitive keys recursively from data objects.
  • Deep Clone & Merge: Memory-optimized object cloning and merging.

🔬 3. How It Works Under the Hood

flowchart TD
    TaskQueue["Task Queue (10,000 items)"]
    WorkerPool["Concurrency Pool (Limit: 5)"]
    Worker1["Worker 1"]
    Worker2["Worker 2"]
    Worker3["Worker 3"]
    Worker4["Worker 4"]
    Worker5["Worker 5"]
    Results["Results Array"]

    TaskQueue --> WorkerPool
    WorkerPool --> Worker1 & Worker2 & Worker3 & Worker4 & Worker5
    Worker1 & Worker2 & Worker3 & Worker4 & Worker5 --> Results
  1. runConcurrently Engine: Uses an internal queue worker pool. When a task resolves, the worker immediately pulls the next item from the input array, ensuring that no more than $N$ promises run concurrently.

🧠 4. Why It Was Designed This Way (Controlled Concurrency vs Promise.all)

| Metric / Scenario | 🛠️ runConcurrently (Limit: 10) | ❌ Promise.all(...) | |---|---|---| | Memory Allocation | Bounded Memory Pool | Unbounded Memory Spike (10k Promises created at once) | | Database Connection Pool | Prevents Pool Exhaustion | Crashes Connection Pool with ECONNRESET | | Error Handling | Configurable (Fail-Fast or Settle All) | Rejects immediately on first error |


🚀 5. Practical Usage Guide & Extended Code Examples

import { runConcurrently, sanitizeObject } from '@node-yalc/utils';

async function processUserQueue() {
  const userIds = Array.from({ length: 500 }, (_, i) => `usr_${i + 1}`);

  // Process 500 items with a maximum concurrency limit of 5 parallel workers
  const results = await runConcurrently(userIds, async (id) => {
    return await fetchExternalAPIData(id);
  }, { concurrency: 5 });

  console.log(`Processed ${results.length} user records successfully.`);

  // Deep sanitize an object to remove undefined values
  const rawPayload = { name: 'Alice', age: undefined, role: null };
  const cleanPayload = sanitizeObject(rawPayload, { removeUndefined: true });
  console.log('Sanitized Payload:', cleanPayload); // { name: 'Alice', role: null }
}

processUserQueue().catch(console.error);

⚠️ 6. Anti-Patterns: How NOT to Use It

  1. ❌ DO NOT use Promise.all() over thousands of database queries or API calls: Running Promise.all() over large arrays consumes all available database connection pool slots and leads to socket timeouts. Always use runConcurrently.

💡 7. Pro-Tips & Best Practices

[!TIP] Database Pool Sizing: Set concurrency to match your database connection pool size (e.g. concurrency: 10 for a Postgres connection pool of 10 connections) to maximize I/O throughput without queue wait times.


🔗 Cross-References

To see how this module integrates with the rest of the Ferrox architecture, refer to the following documentation:


📚 Ecosystem Documentation

This module is a core component of the Ferrox enterprise microservice architecture.

👉 Read the Full Documentation on Ferrox-Rust.dev