Registry / database / redis-type

redis-type

JSON →
library0.5.1jsnpmunverified

redis-type 0.5.1 is a thin wrapper around Redis data structures (HASH, LIST, SET) that mirrors JavaScript's Map, Array, and Set APIs, returning native JS types instead of raw Redis replies. It provides Promise-based methods and optional JSON serialization. Unlike generic Redis clients, it offers a typed, idiomatic interface. The package is maintained but does not release frequently. It requires a user-provided Redis client (e.g., node-redis). Compatible with modern Node.js (>=14) and ESM/CommonJS dual packaging.

npm install redis-type
INSTALL
IMPORT
SIG · REDIS-TYPE
R
redis-type
databasejavascriptv0.5.1
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.

Hash
import { Hash } from 'redis-type'
import Hash from 'redis-type'
Named export; no default export. Use after calling .bind(client).
List
import { List } from 'redis-type'
const { List } = require('redis-type')
CommonJS require works in Node.js; for ESM use named import. Requires .bind(client) before usage.
Set
import { Set } from 'redis-type'
const Set = require('redis-type').Set
CommonJS destructuring is correct, but note that Set is a global JS object; avoid naming conflicts.

Creates a redis client, initializes a Hash wrapper with JSON serialization enabled, sets and gets an object.

import { createClient } from 'redis'; import { Hash } from 'redis-type'; const client = createClient(); await client.connect(); const h = Hash('myhash', true); h.set('user', { name: 'Alice', age: 30 }); const user = await h.get('user'); console.log(user); // { name: 'Alice', age: 30 } await client.disconnect();
Debug
Known issues
gotchaForgetting to call .bind(client) before using Hash, List, or Set will cause a runtime error: 'Client not provided'.
fix
Call .bind(client) immediately after importing: const { Hash } = require('redis-type').bind(client);
affects: >=0.1.0
gotchaThe .getAll() method on Hash returns all fields as a plain object, not a Map. Documentation may mislead that it returns a Map.
fix
Use the returned plain object directly or convert to Map manually: const map = new Map(Object.entries(obj));
affects: >=0.1.0
gotchaJSON serialization (second argument true) only works for Hash; List and Set do not support JSON transforms.
fix
Do not pass a second argument to List or Set; it is ignored.
affects: >=0.1.0
breakingIn version 0.5.0, .bind(client) changed from accepting a callback to returning an object. Old code expecting a callback breaks.
fix
Switch to: const { Hash } = require('redis-type').bind(client);
affects: >=0.5.0
Errors
Common errors & fixes
Client not provided
Calling Hash/List/Set methods without first calling .bind(client) or passing a client.
fix
Ensure you invoke .bind(client) and use the destructured constructors from its return.
TypeError: Cannot read properties of undefined (reading 'hSet')
Using an older node-redis version (<4) that doesn't have the expected methods.
fix
Upgrade to node-redis v4+: npm install redis@latest
ERR wrong number of arguments for 'hSet' command
Mixing field and value arguments incorrectly (e.g., order or arity).
fix
Check .set(field, value) signature for Hash: exactly two arguments after key.
Upgrade
Version history
0.5.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
18 hits · last 30 days
node
16
Resources
redis-type — npm install redis-type · libregistry