Registry / storage / session-cache

session-cache

JSON →
library0.2.0jsnpmunverified

Session storage for tasks, designed to pass data between gulp tasks or similar workflow steps. Current stable version is 0.2.0, released in 2015 with no updates since. It provides a simple context-based session object to store and retrieve key-value pairs, with methods to bind functions and EventEmitters. Lacks TypeScript support, tests, and modern ESM compatibility. Alternatives include async hooks or more maintained session libraries.

npm install session-cache
INSTALL
IMPORT
SIG · SESSION-CACHE
S
session-cache
storagejavascriptv0.2.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import session from 'session-cache'
const { session } = require('session-cache')
The package exports a factory function via module.exports, so it can be imported as a default import in ESM or required directly.
require
const session = require('session-cache')
const { createSession } = require('session-cache')
CommonJS require returns the factory function directly; there is no named export.
factory
session('my-app')
new session('my-app')
The function returned by require/import is a factory that creates a session instance; do not use 'new'.

Demonstrates creating a session, setting/getting values, binding a function, and binding an EventEmitter.

// Create a session instance const session = require('session-cache')('my-app'); // Set and get values session.set('key', 'value'); console.log(session.get('key')); // 'value' // Bind a function to the session context function myTask(data, next) { console.log(this.get('key')); next(); } session.bind(myTask); // Bind an EventEmitter const EventEmitter = require('events'); const emitter = new EventEmitter(); session.bindEmitter(emitter);
Debug
Known issues
gotchaThe package uses `new Function` internally which can be unsafe if untrusted input is passed to session names or keys.
fix
Validate session names and keys to avoid code injection.
affects: >=0.0.0
gotchaNo TypeScript definitions available; manual type declaration needed.
fix
Create a .d.ts file or use type assertions.
affects: >=0.0.0
gotchaThe package is unmaintained since 2015 and may have unpatched vulnerabilities.
fix
Consider migrating to an actively maintained session library.
affects: >=0.0.0
deprecatedUses `require('session-cache')` which is CommonJS; no ESM export.
fix
Use dynamic import if needed in ESM: `const session = (await import('session-cache')).default;`
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: session is not a function
Importing the module incorrectly, e.g. using named import when only default export exists.
fix
Use `const session = require('session-cache');` or `import session from 'session-cache';`
Cannot find module 'session-cache'
Package not installed or typo in package name.
fix
Run `npm i session-cache --save` and ensure the package name is correct.
TypeError: this.get is not a function
Using `bind` on a function that is not called within the session context properly.
fix
Ensure you call `session.bind(fn)` and that `fn` is invoked with the correct `this`.
Upgrade
Version history
0.2.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
22 hits · last 30 days
node
20
Resources
session-cache — npm install session-cache · libregistry