RESP, which stands for Redis SErialization Protocol, is the protocol used by Redis to communicate with clients. This document shows how RESP types can be mapped to JavaScript types. You can learn more about RESP itself in the offical documentation.
By default, each type is mapped to the first option in the lists below. To change this, configure a typeMapping
.
- Integer (
:
) =>number
- Simple String (
+
) =>string | Buffer
- Blob String (
$
) =>string | Buffer
- Simple Error (
-
) =>ErrorReply
- Array (
*
) =>Array
NOTE: the first type is the default type
- Null (
_
) =>null
- Boolean (
#
) =>boolean
- Number (
:
) =>number | string
- Big Number (
(
) =>BigInt | string
- Double (
,
) =>number | string
- Simple String (
+
) =>string | Buffer
- Blob String (
$
) =>string | Buffer
- Verbatim String (
=
) =>string | Buffer | VerbatimString
(TODO:VerbatimString
typedoc link) - Simple Error (
-
) =>ErrorReply
- Blob Error (
!
) =>ErrorReply
- Array (
*
) =>Array
- Set (
~
) =>Array | Set
- Map (
%
) =>object | Map | Array
- Push (
>
) =>Array
=> PubSub push/'push'
event
NOTE: the first type is the default type
When decoding a Map to Map | object
or a Set to Set
, keys and members of type "Simple String" or "Blob String" will be decoded as string
s which enables lookups by value, ignoring type mapping. If you want them as Buffer
s, decode them as Array
s instead.
These parts of RESP3 are not yet implemented in Redis itself (at the time of writing), so are not yet implemented in the Node-Redis client either: