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

@theinternetfolks/context

v2.3.0

Published

Library to help you create a context that can be used to reference data, without prop drilling, in Node-based environments.

Downloads

137

Readme

The Internet Folks Logo

@theinternetfolks/context

GitHub license Maintainer

Library to help you create a context that can be used to reference data, without prop drilling, in Node-based environments.

The inspiration comes from the concept of Context in React.

Prop drilling is the process of getting data from component A to component Z by passing it through multiple layers of intermediary React components. Instead of manually passing props down, Context provides a way to share values between components.

Passing data to child functions in Node-based environments is a challenge. You could use a static class that works as your storage, but in cases where the application might be accessed in parallel, this approach fails. There is a definite need for a context-like concept.

Instead of doing this:

callFunction1(originalData) {
    callFunction2(someData, originalData);
}

callFunction2(someData, originalData) {
    processOtherDataToo(someData);
    callFunction3(originalData);
}

callFunction3(originalData) {
    callFunction4(originalData);
}

callFunction4(originalData) {
    useTheOriginalDataFinally(originalData);
}

You can do this:

callFunction1(originalData) {
    Context.set(originalData);
    callFunction2(someData);
}

callFunction2(someData) {
    processOtherDataToo(someData);
    callFunction3();
}

callFunction3() {
    callFunction4();
}

callFunction4() {
    const data = Context.get();
    useTheOriginalDataFinally(data);
}

The library uses Async Local Storage internally, which provides an API to track the lifetime of asynchronous resources in a Node application.

Installation

Install with npm:

npm install @theinternetfolks/context

Install with pnpm:

pnpm add @theinternetfolks/context

Install with bun:

bun add @theinternetfolks/context

Install with yarn:

yarn add @theinternetfolks/context

Features

  • Lightweight implementation using native AsyncLocalStorage
  • TypeScript typings with interfaces support
  • Works with all kinds of async functions (Promises, Timeouts, TCPWrap, UDP, etc.)

Usage/Examples

Example 1: Simple Function Call

const { Context } = require("@theinternetfolks/context");

const SomeFunction = () => {
  const data = Context.get();
  console.log(`Name: ${data.name}`);
};

(() => {
  Context.init(); // initialize the context for this run
  Context.set({ name: "The Internet Folks" });
  SomeFunction();
})();

Output:

Name: The Internet Folks

Example 2: Parent-Child Function Calls

const { Context } = require("@theinternetfolks/context");

const ChildFunction = () => {
  const data = Context.get();
  console.log(`Name from Context: ${data.name} in Child`);
};

const ParentFunction = () => {
  const data = Context.get();
  console.log(`Name from Context: ${data.name} in Parent`);
  ChildFunction();
};

(() => {
  Context.init(); // initialize the context for this run
  Context.set({ name: "The Internet Folks" });
  ParentFunction();
})();

Example 3: Usage in Express.js (Per-Request Context)

const express = require("express");
const { Context } = require("@theinternetfolks/context");

const app = express();

app.use(express.json());

app.use((req, res, next) => {
  Context.init(); // initialize the context for the request
  Context.set({ host: req.get("host") });
  next();
});

app.get("/", (req, res) => {
  const data = Context.get();
  return res.json({ host: data?.host });
});

app.listen(3000, () => {
  console.log("Server running on port 3000");
});

Example 4: Express.js with TypeScript

import express from "express";
import { Context } from "@theinternetfolks/context";

interface IPayload {
    host: string;
}

const app = express();

app.use(express.json());

app.use((req, res, next) => {
  Context.init(); // initialize the context for the request
  Context.set({ host: req.get("host") });
  next();
});

app.get("/", (req, res) => {
  const context = Context.get<IPayload>();

  setTimeout(() => {
    console.log(context?.host);
  }, 2500);

  return res.json({ host: context?.host });
});

app.listen(6174, () => {
  console.log("Server running on port 6174");
});

Documentation

API Methods

  • static init(): void; Initializes a new context. This must be called before setting data.

  • static get<T>(key?: string | null): T; Retrieves the stored data in the context.

  • static set(data: Record<string, any>): boolean; Stores data in the context.

  • static remove(key?: string): void; Deletes the data stored in the context.

  • static run<T>(fn: () => T | Promise<T>, initialData?: Record<string, any>): T | Promise<T>; Runs a function with an isolated context.

Tests

  • Uses Bun Test Suite for unit testing.
  • Load tested with k6 to ensure no data leakage across requests.

Test Coverage

Authors

Careers at The Internet Folks

At The Internet Folks, we’re a team of ambitious builders driven by curiosity and a passion for crafting high-performance, scalable software. We tackle complex engineering challenges, push the boundaries of innovation, and create technology that makes a real impact.

If you love solving hard problems, designing clean architectures, and building systems that scale, we’d love to have you on board. Here, you’ll work with some of the sharpest minds, ship fast, and grow even faster.

🚀 Explore open roles and join us: Explore Now

Let’s build something extraordinary—together.