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

@qavajs/memory

v1.11.0

Published

memory package for @qavajs framework

Readme

npm version

@qavajs/memory

Unified test data storage for the @qavajs framework. Provides a singleton memory store with support for constants, computed values, string interpolation, and parallel test data assignment.

npm install @qavajs/memory

Usage

Import the singleton and use getValue/setValue in your step definitions:

import memory from '@qavajs/memory';

When(/^save variable as '(.+)'$/, async function (key) {
  memory.setValue(key, 42);
});

Then(/^value '(.+)' should be equal to '(.+)'$/, async function (variable1, variable2) {
  const val = memory.getValue(variable1);
  expect(val).to.equal(variable2);
});
When save variable as 'variable'
Then value of '$variable' should be equal to '42'

getValue passes non-string values through unchanged, so it is safe to call on any step parameter.


Register constants and computed values

Define a memory map with constants and computed functions, then register it before your tests run:

// memoryMap.ts
export default {
  constant: 42,
  baseUrl: 'https://example.com',
  now: function () {
    return Date.now();
  },
  uuid: function () {
    return crypto.randomUUID();
  },
};
// hooks.ts
import memory from '@qavajs/memory';
import memoryMap from './memoryMap.js';

Before(async function () {
  memory.register(memoryMap);
});

Plain properties are constants; function properties are computed — they are evaluated each time getValue resolves them.


Value resolution syntax

Simple key lookup

Prefix a key with $ to look it up in memory:

Then value of '$variable' should equal '42'

Property access

Dot notation and bracket notation both work:

Then value of '$user.name' should equal 'Alice'
Then value of '$items[0]' should equal 'first'

Calling computed functions with arguments

Then value of '$add(1, 2)' should equal '3'

String interpolation

Wrap $key references in {...} to embed memory values inside a larger string:

Then endpoint '{$baseUrl}/api/users/{$userId}' should return 200

Built-in $js() computed

Evaluate arbitrary JavaScript expressions against the current memory storage:

Then value of '$js($counter + 1)' should equal '6'
Then value of '$js(JSON.stringify($user))' should be valid JSON

Escaping $

Prefix $ with a double backslash to treat it as a literal character:

When I expect text of 'Currency Label' to equal '\\$42'

API

memory.getValue(str)

Resolves a value from memory. Returns the input unchanged if it is not a string or contains no $ references.

| Parameter | Type | Description | |-----------|-------|--------------------------------------------| | str | any | String to resolve, or a pass-through value |

Returns any.


memory.setValue(key, value)

Stores a value in memory under key.

| Parameter | Type | Description | |-----------|----------|----------------| | key | string | Storage key | | value | any | Value to store |


memory.register(memoryMap)

Registers a memory map object as the backing storage. Call this once before your tests run. All keys from the map become resolvable via $key syntax.

| Parameter | Type | Description | |-------------|----------|-------------------------------| | memoryMap | object | Object of constants/computeds |


memory.setLogger(logger)

Attach a logger to trace value resolution. The logger receives a formatted string for each getValue call that transforms the input.

import memory from '@qavajs/memory';

memory.setLogger({ log: (msg) => console.log('[memory]', msg) });
// Output: [memory] $username -> alice
//         [memory] $counter <- 5

| Parameter | Type | Description | |-----------|---------------------------------|-----------------| | logger | { log: (value: any) => void } | Logger instance |


memory.convertToString(value)

Converts a value to a string for logging. Override this method to customize serialization (e.g. use util.inspect instead of JSON.stringify):

import util from 'util';
import memory from '@qavajs/memory';

memory.convertToString = function (value) {
  return util.inspect(value);
};

Parallel test data

When running Cucumber in parallel mode or using qavajs shards, use parallel to assign unique data per thread:

import { parallel } from '@qavajs/memory/utils';

export default class Memory {
  // Assigns by CUCUMBER_WORKER_ID (0-based)
  user = parallel([
    { username: 'user1', password: 'password' },
    { username: 'user2', password: 'password' },
  ]);

  // Assigns by worker + shard offset (requires SHARD env var)
  shardUser = parallel(
    [
      { username: 'user1', password: 'password' },
      { username: 'user2', password: 'password' },
      { username: 'user3', password: 'password' },
      { username: 'user4', password: 'password' },
    ],
    { shard: true }
  );
}

parallel reads CUCUMBER_WORKER_ID (default 0) and CUCUMBER_TOTAL_WORKERS from the environment. In shard mode it also reads SHARD (1-based) and multiplies across workers to produce a globally unique index.


License

MIT