Skip to content

Releases: civitas-cerebrum/context-store

0.0.2

13 Mar 16:09

Choose a tag to compare

Small improvements and readme fixes!

Full Changelog: 0.0.1...0.0.2

0.0.1

13 Mar 15:48

Choose a tag to compare

🎉 Release v0.0.1: Initial Release

Welcome to the very first release of context-store!

This package was born out of the need to replace plain, messy JavaScript objects (Record<string, string>) with a robust, strictly-typed API for passing state between steps in E2E and integration tests.

Whether you are using Playwright, Cypress, Jest, or Cucumber, this lightweight, zero-dependency utility makes test context management safe, clean, and highly readable.

✨ Key Features

  • Framework Agnostic: Works completely independently of your test runner.

  • Type-Safe Retrieval: Fetch your data safely with TypeScript generics (context.get<string>('key')).

  • Built-in Parsers & Fallbacks: * getBoolean() securely handles string-to-boolean conversions (e.g., parsing "true" to true).

  • getNumber() safely parses numeric strings and falls back to a default if parsing fails.

  • Bulk Operations: Use merge() to combine existing Maps or objects, and entries() / items() for clean iteration during assertions.

  • Zero Dependencies: Extremely lightweight. It won't bloat your node_modules.

📦 Installation

npm install context-store 

🚀 Quick Start Example

import { ContextStore } from 'context-store';

const context = new ContextStore();

// Store data
context.put('UserId', 12345);
context.put('IsActive', 'true');

// Retrieve data safely
const id = context.getNumber('UserId'); // Returns 12345
const active = context.getBoolean('IsActive'); // Returns true

🛠️ API Methods Available in v0.0.1

  • put(key, value)
  • get<T>(key, default?)
  • getBoolean(key, default?)
  • getNumber(key, default?)
  • has(key)
  • remove(key)
  • clear()
  • merge(...sources)
  • entries()
  • items()

Full Changelog: https://github.com/Umutayb/js-context-store/commits/0.0.1