ObliviousSet provides a JavaScript Set-like data structure where each entry is associated with a Time-To-Live (TTL). Unlike traditional caching mechanisms that often rely on intervals or timeouts for eviction, ObliviousSet's design avoids these, enabling proper garbage collection of the set instance when no active references exist. The current stable version is 2.0.0, which targets modern Node.js environments (>=16). While a strict release cadence isn't published, the package is actively maintained with updates released as needed for features or bug fixes. Its key differentiator is the efficient, passive expiration model where entries are only 'removed' (marked as expired) when explicitly checked via the `has()` method or when iterating over active elements, rather than through eager background processes. This minimizes overhead and resource consumption.
npm install oblivious-setVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to create an ObliviousSet, add elements, check for their existence before and after expiration, and clear the set.
Be aware that the `size` property might not immediately reflect the number of *active* items. Explicitly use `has()` or iterate over the set to trigger expiration checks for stale entries.
Ensure your project uses Node.js 16 or newer. If you are in a CommonJS module, you might need to convert your project to ESM or use dynamic `import()` if supported by your runtime/toolchain, e.g., `const { ObliviousSet } = await import('oblivious-set');`.If you intend to 'touch' an item without resetting its TTL, ensure you only `add()` new, unique items or implement custom logic to avoid resetting the TTL on existing ones.
Convert your project to use ES Modules by setting `"type": "module"` in your `package.json` and using `import` statements, or use dynamic import: `const { ObliviousSet } = await import('oblivious-set');`.Ensure you are using the correct named import: `import { ObliviousSet } from 'oblivious-set';` and that your environment supports ES Modules.Add the import statement `import { ObliviousSet } from 'oblivious-set';` at the top of your file.No dependency data recorded yet.