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

@bigbyte/ctx

v0.8.2

Published

<div align="center">

Downloads

19

Readme

🗃️ @bigbyte/ctx

NPM Version License TypeScript

Context Management and Value Storage System for BigByte

A robust and efficient context management module that provides an immutable value store with full support for dependency injection, environment variables, and configuration traceability.

📋 Table of Contents

✨ Features

🏦 Immutable Value Store: Once stored, values cannot be modified, ensuring configuration integrity
🔄 Environment Variables Integration: Transparent access to operating system variables
🏷️ Unique Identification: Each stored value has a unique UUID for traceability
📝 Temporal Metadata: Automatic tracking of value creation dates
🔍 Flexible Search API: Search by key, ID, or value
🔌 Dependency Injection: Fully compatible with BigByte's IoC system
📊 Integrated Logging: Automatic logging of operations and warnings

🚀 Installation

npm install @bigbyte/ctx

🔧 Basic Usage

Import

import { ctxStore, ValueStore, StoreValue } from '@bigbyte/ctx';

Storing Values

// Add a value to the store
ctxStore.add('API_URL', 'https://api.example.com');
ctxStore.add('MAX_RETRIES', '3');

Retrieving Values

// Get a value by key
const apiUrl = ctxStore.getByKey('API_URL');
console.log(apiUrl?.value); // 'https://api.example.com'

// Get all values
const allValues = ctxStore.getAllValues();

Usage with Dependency Injection

import { Inject, componentRegistry } from '@bigbyte/ioc';
import { ValueStore } from '@bigbyte/ctx';

const inject = componentRegistry.getByClass(Inject);

class ApiService {
    private valueStore?: ValueStore = inject.get(ValueStore);

    constructor() {}

    getApiUrl(): string {
        return this.valueStore.getValue('API_URL') || 'default-url';
    }
}

🔍 Detailed API

CtxStore

The main container for value storage.

Main Methods

CtxStore

| Method | Description | Parameters | Return | |--------|-------------|------------|--------| | add(key, value) | Adds a new value to the store | key: string, value: string \| undefined | void | | getByKey(key) | Gets a value by its key | key: string | StoreValue \| undefined | | getById(id) | Gets a value by its unique ID | id: string | StoreValue \| undefined | | getAllStoreValues() | Gets all stored values | - | StoreValue[] | | getAllValues() | Gets all values as Map | - | Map<string, string \| undefined> | | hasKey(key) | Checks if a key exists | key: string | boolean | | hasValue(value) | Checks if a value exists | value: any | boolean |

StoreValue

Model representing a stored value with metadata.

Properties

class StoreValue {
    readonly id: string;        // Unique UUID
    readonly key: string;       // Value key
    readonly value: string | boolean | number | undefined;  // Stored value
    readonly createAt: Date;    // Creation date
}

ValueStore

Service that provides a programmatic interface to the store. This service is added to @bigbyte/ioc to make it injectable.

Service Methods

class ValueStore {
    getValue(key: string): string | undefined;
    getStoreValue(key: string): StoreValue | undefined;
    getAllValues(): Map<string, string | undefined>;
    has(key: string): boolean;
    add(key: string, value: string | undefined): void;
}

🏗️ Architecture

The module is structured into three main components:

📁 Project Structure

src/
├── container/
│   └── CtxStore.ts          # Main value container
├── model/
│   └── StoreValue.ts        # Stored value model
├── service/
│   └── ValueStore.ts        # Service for programmatic operations
└── constant/
    └── index.ts             # Module constants

🔧 Advanced Examples

Environment Variables Integration

The system automatically accesses operating system environment variables:

// If the NODE_ENV environment variable exists
const env = ctxStore.getByKey('NODE_ENV');
console.log(env?.value); // 'development', 'production', etc.

Duplicate Prevention

The system warns and ignores keys that already exist in environment values.

ctxStore.add('API_URL', 'https://api1.com');
ctxStore.add('API_URL', 'https://api2.com'); 
// ⚠️ Warning: The value with key "API_URL" already exists in the ValueStore.

Traceability and Auditing

Each stored value includes traceability metadata:

const value = ctxStore.getByKey('CONFIG_KEY');
console.log(`ID: ${value?.id}`);           // Unique UUID
console.log(`Created: ${value?.createAt}`); // Creation timestamp

📄 License

This project is under the Apache 2.0 license. See the LICENSE file for more details.


Developed with ❤️ by Jose Eduardo Soria Garcia

Part of the BigByte ecosystem