@encore.dev/sdk 0.0.0 → 2.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +362 -0
- package/README.md +122 -2
- package/app_meta.test.ts +134 -0
- package/app_meta.ts +186 -0
- package/config/config.test.ts +381 -0
- package/config/config.ts +178 -0
- package/config/mod.ts +14 -0
- package/config/secrets.ts +147 -0
- package/config/value.ts +243 -0
- package/cron/mod.ts +23 -0
- package/dist/app_meta.d.ts +93 -0
- package/dist/app_meta.js +65 -0
- package/dist/app_meta.js.map +1 -0
- package/dist/config/config.d.ts +105 -0
- package/dist/config/config.js +87 -0
- package/dist/config/config.js.map +1 -0
- package/dist/config/mod.d.ts +4 -0
- package/dist/config/mod.js +3 -0
- package/dist/config/mod.js.map +1 -0
- package/dist/config/secrets.d.ts +92 -0
- package/dist/config/secrets.js +80 -0
- package/dist/config/secrets.js.map +1 -0
- package/dist/config/value.d.ts +51 -0
- package/dist/config/value.js +178 -0
- package/dist/config/value.js.map +1 -0
- package/dist/cron/mod.d.ts +22 -0
- package/dist/cron/mod.js +9 -0
- package/dist/cron/mod.js.map +1 -0
- package/dist/internal/otel/backend.d.ts +50 -0
- package/dist/internal/otel/backend.js +2 -0
- package/dist/internal/otel/backend.js.map +1 -0
- package/dist/internal/otel/context.d.ts +10 -0
- package/dist/internal/otel/context.js +34 -0
- package/dist/internal/otel/context.js.map +1 -0
- package/dist/internal/otel/context_manager.d.ts +22 -0
- package/dist/internal/otel/context_manager.js +120 -0
- package/dist/internal/otel/context_manager.js.map +1 -0
- package/dist/internal/otel/encode.d.ts +112 -0
- package/dist/internal/otel/encode.js +290 -0
- package/dist/internal/otel/encode.js.map +1 -0
- package/dist/internal/otel/index.d.ts +9 -0
- package/dist/internal/otel/index.js +9 -0
- package/dist/internal/otel/index.js.map +1 -0
- package/dist/internal/otel/meter.d.ts +73 -0
- package/dist/internal/otel/meter.js +265 -0
- package/dist/internal/otel/meter.js.map +1 -0
- package/dist/internal/otel/propagator.d.ts +14 -0
- package/dist/internal/otel/propagator.js +61 -0
- package/dist/internal/otel/propagator.js.map +1 -0
- package/dist/internal/otel/provider.d.ts +9 -0
- package/dist/internal/otel/provider.js +19 -0
- package/dist/internal/otel/provider.js.map +1 -0
- package/dist/internal/otel/request_context.d.ts +11 -0
- package/dist/internal/otel/request_context.js +20 -0
- package/dist/internal/otel/request_context.js.map +1 -0
- package/dist/internal/otel/span.d.ts +61 -0
- package/dist/internal/otel/span.js +206 -0
- package/dist/internal/otel/span.js.map +1 -0
- package/dist/internal/otel/tracer.d.ts +15 -0
- package/dist/internal/otel/tracer.js +65 -0
- package/dist/internal/otel/tracer.js.map +1 -0
- package/dist/internal/reqtrack/mod.d.ts +6 -0
- package/dist/internal/reqtrack/mod.js +28 -0
- package/dist/internal/reqtrack/mod.js.map +1 -0
- package/dist/internal/runtime/meter.d.ts +11 -0
- package/dist/internal/runtime/meter.js +22 -0
- package/dist/internal/runtime/meter.js.map +1 -0
- package/dist/internal/runtime/mod.d.ts +12 -0
- package/dist/internal/runtime/mod.js +28 -0
- package/dist/internal/runtime/mod.js.map +1 -0
- package/dist/internal/runtime/napi/napi.cjs +122 -0
- package/dist/internal/runtime/napi/napi.d.cts +601 -0
- package/dist/internal/runtime/shutdown.d.ts +13 -0
- package/dist/internal/runtime/shutdown.js +56 -0
- package/dist/internal/runtime/shutdown.js.map +1 -0
- package/dist/internal/utils/constraints.d.ts +9 -0
- package/dist/internal/utils/constraints.js +2 -0
- package/dist/internal/utils/constraints.js.map +1 -0
- package/dist/log/index.d.ts +39 -0
- package/dist/log/index.js +44 -0
- package/dist/log/index.js.map +1 -0
- package/dist/log/logger.d.ts +123 -0
- package/dist/log/logger.js +203 -0
- package/dist/log/logger.js.map +1 -0
- package/dist/log/runtime.d.ts +19 -0
- package/dist/log/runtime.js +22 -0
- package/dist/log/runtime.js.map +1 -0
- package/dist/log/stderr.d.ts +9 -0
- package/dist/log/stderr.js +25 -0
- package/dist/log/stderr.js.map +1 -0
- package/dist/metrics/mod.d.ts +315 -0
- package/dist/metrics/mod.js +488 -0
- package/dist/metrics/mod.js.map +1 -0
- package/dist/mod.d.ts +6 -0
- package/dist/mod.js +4 -0
- package/dist/mod.js.map +1 -0
- package/dist/otel.d.ts +9 -0
- package/dist/otel.js +13 -0
- package/dist/otel.js.map +1 -0
- package/dist/pubsub/encoding.d.ts +3 -0
- package/dist/pubsub/encoding.js +10 -0
- package/dist/pubsub/encoding.js.map +1 -0
- package/dist/pubsub/mod.d.ts +6 -0
- package/dist/pubsub/mod.js +3 -0
- package/dist/pubsub/mod.js.map +1 -0
- package/dist/pubsub/refs.d.ts +12 -0
- package/dist/pubsub/refs.js +11 -0
- package/dist/pubsub/refs.js.map +1 -0
- package/dist/pubsub/subscription.d.ts +128 -0
- package/dist/pubsub/subscription.js +39 -0
- package/dist/pubsub/subscription.js.map +1 -0
- package/dist/pubsub/topic.d.ts +148 -0
- package/dist/pubsub/topic.js +164 -0
- package/dist/pubsub/topic.js.map +1 -0
- package/dist/req_meta.d.ts +47 -0
- package/dist/req_meta.js +26 -0
- package/dist/req_meta.js.map +1 -0
- package/dist/services/index.d.ts +7 -0
- package/dist/services/index.js +17 -0
- package/dist/services/index.js.map +1 -0
- package/dist/shutdown/mod.d.ts +23 -0
- package/dist/shutdown/mod.js +24 -0
- package/dist/shutdown/mod.js.map +1 -0
- package/dist/storage/objects/bucket.d.ts +216 -0
- package/dist/storage/objects/bucket.js +123 -0
- package/dist/storage/objects/bucket.js.map +1 -0
- package/dist/storage/objects/error.d.ts +14 -0
- package/dist/storage/objects/error.js +81 -0
- package/dist/storage/objects/error.js.map +1 -0
- package/dist/storage/objects/mod.d.ts +4 -0
- package/dist/storage/objects/mod.js +3 -0
- package/dist/storage/objects/mod.js.map +1 -0
- package/dist/storage/objects/refs.d.ts +31 -0
- package/dist/storage/objects/refs.js +20 -0
- package/dist/storage/objects/refs.js.map +1 -0
- package/dist/storage/postgres/database.d.ts +295 -0
- package/dist/storage/postgres/database.js +378 -0
- package/dist/storage/postgres/database.js.map +1 -0
- package/dist/storage/postgres/mod.d.ts +2 -0
- package/dist/storage/postgres/mod.js +2 -0
- package/dist/storage/postgres/mod.js.map +1 -0
- package/dist/storage/redis/commands.d.ts +573 -0
- package/dist/storage/redis/commands.js +637 -0
- package/dist/storage/redis/commands.js.map +1 -0
- package/dist/storage/redis/database.d.ts +302 -0
- package/dist/storage/redis/database.js +336 -0
- package/dist/storage/redis/database.js.map +1 -0
- package/dist/storage/redis/mod.d.ts +88 -0
- package/dist/storage/redis/mod.js +84 -0
- package/dist/storage/redis/mod.js.map +1 -0
- package/dist/storage/redis/native.d.ts +8 -0
- package/dist/storage/redis/native.js +11 -0
- package/dist/storage/redis/native.js.map +1 -0
- package/dist/storage/redis/options.d.ts +89 -0
- package/dist/storage/redis/options.js +53 -0
- package/dist/storage/redis/options.js.map +1 -0
- package/dist/storage/redis/pubsub.d.ts +53 -0
- package/dist/storage/redis/pubsub.js +88 -0
- package/dist/storage/redis/pubsub.js.map +1 -0
- package/dist/storage/redis/reply.d.ts +256 -0
- package/dist/storage/redis/reply.js +572 -0
- package/dist/storage/redis/reply.js.map +1 -0
- package/dist/storage/redis/scan.d.ts +11 -0
- package/dist/storage/redis/scan.js +76 -0
- package/dist/storage/redis/scan.js.map +1 -0
- package/dist/storage/redis/script.d.ts +91 -0
- package/dist/storage/redis/script.js +143 -0
- package/dist/storage/redis/script.js.map +1 -0
- package/dist/storage/redis/target.d.ts +47 -0
- package/dist/storage/redis/target.js +82 -0
- package/dist/storage/redis/target.js.map +1 -0
- package/dist/storage/redis/wire.d.ts +105 -0
- package/dist/storage/redis/wire.js +333 -0
- package/dist/storage/redis/wire.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/types/mod.d.ts +42 -0
- package/dist/types/mod.js +65 -0
- package/dist/types/mod.js.map +1 -0
- package/internal/otel/backend.ts +60 -0
- package/internal/otel/context.test.ts +70 -0
- package/internal/otel/context.ts +48 -0
- package/internal/otel/context_manager.test.ts +154 -0
- package/internal/otel/context_manager.ts +141 -0
- package/internal/otel/encode.test.ts +266 -0
- package/internal/otel/encode.ts +408 -0
- package/internal/otel/index.ts +20 -0
- package/internal/otel/meter.test.ts +231 -0
- package/internal/otel/meter.ts +332 -0
- package/internal/otel/propagator.test.ts +105 -0
- package/internal/otel/propagator.ts +68 -0
- package/internal/otel/provider.ts +23 -0
- package/internal/otel/request_context.ts +32 -0
- package/internal/otel/span.ts +252 -0
- package/internal/otel/tracer.test.ts +352 -0
- package/internal/otel/tracer.ts +104 -0
- package/internal/reqtrack/mod.ts +39 -0
- package/internal/runtime/meter.ts +26 -0
- package/internal/runtime/mod.ts +41 -0
- package/internal/runtime/napi/napi.cjs +122 -0
- package/internal/runtime/napi/napi.d.cts +601 -0
- package/internal/runtime/shutdown.test.ts +248 -0
- package/internal/runtime/shutdown.ts +64 -0
- package/internal/utils/constraints.ts +12 -0
- package/log/index.ts +107 -0
- package/log/logger.test.ts +194 -0
- package/log/logger.ts +308 -0
- package/log/runtime.test.ts +65 -0
- package/log/runtime.ts +40 -0
- package/log/stderr.test.ts +23 -0
- package/log/stderr.ts +24 -0
- package/metrics/export.test.ts +337 -0
- package/metrics/mod.test.ts +180 -0
- package/metrics/mod.ts +619 -0
- package/mod.ts +22 -0
- package/otel.test.ts +84 -0
- package/otel.ts +17 -0
- package/package.json +121 -5
- package/pubsub/encoding.ts +8 -0
- package/pubsub/mod.ts +14 -0
- package/pubsub/pubsub.test.ts +186 -0
- package/pubsub/refs.ts +22 -0
- package/pubsub/subscription.ts +180 -0
- package/pubsub/topic.test.ts +121 -0
- package/pubsub/topic.ts +212 -0
- package/req_meta.ts +75 -0
- package/services/index.test.ts +30 -0
- package/services/index.ts +16 -0
- package/shutdown/mod.ts +24 -0
- package/storage/objects/bucket.ts +338 -0
- package/storage/objects/error.ts +94 -0
- package/storage/objects/mod.ts +35 -0
- package/storage/objects/refs.ts +69 -0
- package/storage/postgres/database.integration.test.ts +175 -0
- package/storage/postgres/database.test.ts +241 -0
- package/storage/postgres/database.ts +497 -0
- package/storage/postgres/mod.ts +15 -0
- package/storage/redis/commands.ts +1221 -0
- package/storage/redis/database.ts +466 -0
- package/storage/redis/mod.ts +135 -0
- package/storage/redis/native.ts +11 -0
- package/storage/redis/options.ts +119 -0
- package/storage/redis/pubsub.ts +92 -0
- package/storage/redis/redis.test.ts +706 -0
- package/storage/redis/reply.ts +705 -0
- package/storage/redis/runtime.test.ts +233 -0
- package/storage/redis/scan.ts +125 -0
- package/storage/redis/script.ts +162 -0
- package/storage/redis/target.ts +131 -0
- package/storage/redis/wire.ts +369 -0
- package/types/mod.ts +92 -0
|
@@ -0,0 +1,705 @@
|
|
|
1
|
+
import {MapReply, ServerError, Status, Value} from './wire';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A reply as plain values: what {@link Reply.value} returns. A string reply is
|
|
5
|
+
* text, an integer a `number` (a `bigint` past what a `number` holds exactly),
|
|
6
|
+
* a map an object keyed by its keys' text, with no prototype.
|
|
7
|
+
*/
|
|
8
|
+
export type RedisValue =
|
|
9
|
+
| null
|
|
10
|
+
| string
|
|
11
|
+
| number
|
|
12
|
+
| bigint
|
|
13
|
+
| boolean
|
|
14
|
+
| RedisValue[]
|
|
15
|
+
| {[key: string]: RedisValue};
|
|
16
|
+
|
|
17
|
+
/** A member of a sorted set, with its score. */
|
|
18
|
+
export interface ScoredMember {
|
|
19
|
+
member: string;
|
|
20
|
+
score: number;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** A field of a hash, with its value. */
|
|
24
|
+
export interface FieldValue {
|
|
25
|
+
field: string;
|
|
26
|
+
value: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** An entry of a stream: its id and its fields. */
|
|
30
|
+
export interface StreamEntry {
|
|
31
|
+
id: string;
|
|
32
|
+
fields: Record<string, string>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** The entries read from one stream. */
|
|
36
|
+
export interface Stream {
|
|
37
|
+
key: string;
|
|
38
|
+
entries: StreamEntry[];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The summary of what a consumer group has been given and not acknowledged,
|
|
43
|
+
* as `xpending` replies.
|
|
44
|
+
*/
|
|
45
|
+
export interface StreamPending {
|
|
46
|
+
/** How many entries are pending. */
|
|
47
|
+
count: number;
|
|
48
|
+
/** The lowest pending id: `null` when nothing is pending. */
|
|
49
|
+
lowest: string | null;
|
|
50
|
+
/** The highest pending id: `null` when nothing is pending. */
|
|
51
|
+
highest: string | null;
|
|
52
|
+
/** The consumers with pending entries, and how many each has. */
|
|
53
|
+
consumers: {name: string; pending: number}[];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** What the server knows about a stream, as `xinfoStream` replies. */
|
|
57
|
+
export interface StreamInfo {
|
|
58
|
+
length: number;
|
|
59
|
+
radixTreeKeys: number;
|
|
60
|
+
radixTreeNodes: number;
|
|
61
|
+
groups: number;
|
|
62
|
+
lastGeneratedId: string;
|
|
63
|
+
/** `null` for an empty stream. */
|
|
64
|
+
firstEntry: StreamEntry | null;
|
|
65
|
+
/** `null` for an empty stream. */
|
|
66
|
+
lastEntry: StreamEntry | null;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** What `xautoclaim` replies. */
|
|
70
|
+
export interface StreamAutoClaim {
|
|
71
|
+
/**
|
|
72
|
+
* The id to pass as the next call's start, or `"0-0"` when the scan of
|
|
73
|
+
* pending entries is done.
|
|
74
|
+
*/
|
|
75
|
+
next: string;
|
|
76
|
+
/** The entries now held by the consumer. */
|
|
77
|
+
claimed: StreamEntry[];
|
|
78
|
+
/** The ids of pending entries that no longer exist. */
|
|
79
|
+
deleted: string[];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** A position on Earth. */
|
|
83
|
+
export interface GeoPosition {
|
|
84
|
+
longitude: number;
|
|
85
|
+
latitude: number;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** A member found by a radius search, with what the search asked for of it. */
|
|
89
|
+
export interface GeoRadiusResult {
|
|
90
|
+
name: string;
|
|
91
|
+
/** The distance from the center, with `withDist`. */
|
|
92
|
+
dist?: number;
|
|
93
|
+
/** The member's geohash as an integer, with `withHash`. */
|
|
94
|
+
hash?: bigint;
|
|
95
|
+
/** The member's position, with `withCoord`. */
|
|
96
|
+
coord?: GeoPosition;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function kindOf(v: Value): string {
|
|
100
|
+
if (v === null) return 'nil';
|
|
101
|
+
if (typeof v === 'bigint') return 'integer';
|
|
102
|
+
if (typeof v === 'number') return 'double';
|
|
103
|
+
if (typeof v === 'boolean') return 'boolean';
|
|
104
|
+
if (Buffer.isBuffer(v)) return 'bulk string';
|
|
105
|
+
if (v instanceof Status) return 'status';
|
|
106
|
+
if (Array.isArray(v)) return 'array';
|
|
107
|
+
if (v instanceof MapReply) return 'map';
|
|
108
|
+
return 'error';
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function typeErr(v: Value, want: string): Error {
|
|
112
|
+
return new TypeError(`redis: cannot read a ${kindOf(v)} reply as ${want}`);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** Throws `v` if it is an error. */
|
|
116
|
+
function ok(v: Value): Exclude<Value, ServerError> {
|
|
117
|
+
if (v instanceof ServerError) throw v;
|
|
118
|
+
return v;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export function textOf(v: Value): string {
|
|
122
|
+
v = ok(v);
|
|
123
|
+
if (Buffer.isBuffer(v)) return v.toString('utf8');
|
|
124
|
+
if (v instanceof Status) return v.text;
|
|
125
|
+
if (typeof v === 'bigint' || typeof v === 'number') return String(v);
|
|
126
|
+
throw typeErr(v, 'text');
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function numberOf(v: Value): number {
|
|
130
|
+
v = ok(v);
|
|
131
|
+
if (typeof v === 'number') return v;
|
|
132
|
+
if (typeof v === 'bigint') return Number(v);
|
|
133
|
+
if (Buffer.isBuffer(v) || v instanceof Status) {
|
|
134
|
+
const text = textOf(v);
|
|
135
|
+
// How Redis spells what it replies as a string.
|
|
136
|
+
if (text === 'inf' || text === '+inf') return Infinity;
|
|
137
|
+
if (text === '-inf') return -Infinity;
|
|
138
|
+
const n = Number(text);
|
|
139
|
+
if (text.trim() === '' || Number.isNaN(n)) {
|
|
140
|
+
throw new TypeError(`redis: ${JSON.stringify(text)} is not a number`);
|
|
141
|
+
}
|
|
142
|
+
return n;
|
|
143
|
+
}
|
|
144
|
+
throw typeErr(v, 'a number');
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function bigintOf(v: Value): bigint {
|
|
148
|
+
v = ok(v);
|
|
149
|
+
if (typeof v === 'bigint') return v;
|
|
150
|
+
if (Buffer.isBuffer(v) || v instanceof Status) {
|
|
151
|
+
const text = textOf(v);
|
|
152
|
+
try {
|
|
153
|
+
return BigInt(text);
|
|
154
|
+
} catch {
|
|
155
|
+
throw new TypeError(`redis: ${JSON.stringify(text)} is not an integer`);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
throw typeErr(v, 'an integer');
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function boolOf(v: Value): boolean {
|
|
162
|
+
v = ok(v);
|
|
163
|
+
if (typeof v === 'boolean') return v;
|
|
164
|
+
if (typeof v === 'bigint') return v !== 0n;
|
|
165
|
+
if (v instanceof Status) return v.text === 'OK';
|
|
166
|
+
if (Buffer.isBuffer(v)) {
|
|
167
|
+
switch (v.toString('utf8')) {
|
|
168
|
+
case '1':
|
|
169
|
+
case 'true':
|
|
170
|
+
return true;
|
|
171
|
+
case '0':
|
|
172
|
+
case 'false':
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
throw new TypeError(
|
|
176
|
+
`redis: ${JSON.stringify(v.toString())} is not a boolean`,
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
throw typeErr(v, 'a boolean');
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/** An array reply's elements; a map's keys and values in turn; none for nil. */
|
|
183
|
+
export function arrayOf(v: Value): Value[] {
|
|
184
|
+
v = ok(v);
|
|
185
|
+
if (v === null) return [];
|
|
186
|
+
if (Array.isArray(v)) return v;
|
|
187
|
+
// A map read as an array is its keys and values in turn, as RESP2 sends one.
|
|
188
|
+
if (v instanceof MapReply) return v.entries.flat();
|
|
189
|
+
throw typeErr(v, 'an array');
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function plain(v: Value): RedisValue {
|
|
193
|
+
v = ok(v);
|
|
194
|
+
if (Buffer.isBuffer(v)) return v.toString('utf8');
|
|
195
|
+
if (v instanceof Status) return v.text;
|
|
196
|
+
if (typeof v === 'bigint') {
|
|
197
|
+
return v >= BigInt(Number.MIN_SAFE_INTEGER) &&
|
|
198
|
+
v <= BigInt(Number.MAX_SAFE_INTEGER)
|
|
199
|
+
? Number(v)
|
|
200
|
+
: v;
|
|
201
|
+
}
|
|
202
|
+
if (Array.isArray(v)) return v.map(plain);
|
|
203
|
+
if (v instanceof MapReply) {
|
|
204
|
+
const out = dict<RedisValue>();
|
|
205
|
+
for (const [k, item] of v.entries) out[textOf(k)] = plain(item);
|
|
206
|
+
return out;
|
|
207
|
+
}
|
|
208
|
+
return v;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* An object to hold the fields of a reply under their names. It has no
|
|
213
|
+
* prototype, so a field named `__proto__` is a field like any other, and one
|
|
214
|
+
* named `constructor` is not there unless the reply holds it.
|
|
215
|
+
*/
|
|
216
|
+
function dict<V>(): Record<string, V> {
|
|
217
|
+
return Object.create(null) as Record<string, V>;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function textMapOf(v: Value): Record<string, string> {
|
|
221
|
+
const items = arrayOf(v);
|
|
222
|
+
if (items.length % 2 !== 0) {
|
|
223
|
+
throw new TypeError(
|
|
224
|
+
`redis: an array of ${items.length} elements is not pairs`,
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
const out = dict<string>();
|
|
228
|
+
for (let i = 0; i < items.length; i += 2) {
|
|
229
|
+
out[textOf(items[i])] = textOf(items[i + 1]);
|
|
230
|
+
}
|
|
231
|
+
return out;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/** The members of a sorted set with their scores, nested in pairs or flat. */
|
|
235
|
+
export function scoredMembersOf(items: Value[]): ScoredMember[] {
|
|
236
|
+
// RESP3 sends each member as a pair; RESP2 sends them flat, in turn.
|
|
237
|
+
if (items.length > 0 && Array.isArray(items[0])) {
|
|
238
|
+
return items.map(item => {
|
|
239
|
+
if (!Array.isArray(item) || item.length !== 2) {
|
|
240
|
+
throw typeErr(item, 'a member and its score');
|
|
241
|
+
}
|
|
242
|
+
return {member: textOf(item[0]), score: numberOf(item[1])};
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
if (items.length % 2 !== 0) {
|
|
246
|
+
throw new TypeError(
|
|
247
|
+
`redis: an array of ${items.length} elements is not members and scores`,
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
const out: ScoredMember[] = [];
|
|
251
|
+
for (let i = 0; i < items.length; i += 2) {
|
|
252
|
+
out.push({member: textOf(items[i]), score: numberOf(items[i + 1])});
|
|
253
|
+
}
|
|
254
|
+
return out;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
function streamEntryOf(v: Value): StreamEntry {
|
|
258
|
+
const parts = arrayOf(v);
|
|
259
|
+
if (parts.length !== 2) throw typeErr(v, 'a stream entry');
|
|
260
|
+
return {id: textOf(parts[0]), fields: textMapOf(parts[1])};
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
function geoPositionOf(v: Value): GeoPosition {
|
|
264
|
+
const parts = arrayOf(v);
|
|
265
|
+
if (parts.length !== 2) throw typeErr(v, 'a position');
|
|
266
|
+
return {longitude: numberOf(parts[0]), latitude: numberOf(parts[1])};
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* What Redis replied to a command, or the error the command failed with. Read
|
|
271
|
+
* it as what it holds: {@link Reply.text}, {@link Reply.number},
|
|
272
|
+
* {@link Reply.textMap}, …; each throws the command's error if it failed, and
|
|
273
|
+
* reads a nil reply as `null`.
|
|
274
|
+
*/
|
|
275
|
+
export class Reply {
|
|
276
|
+
/** @internal */
|
|
277
|
+
constructor(
|
|
278
|
+
private readonly reply: Value,
|
|
279
|
+
private readonly err?: Error,
|
|
280
|
+
) {}
|
|
281
|
+
|
|
282
|
+
/** @internal A reply for a command that could not be sent. */
|
|
283
|
+
static failed(err: unknown): Reply {
|
|
284
|
+
return new Reply(null, err instanceof Error ? err : new Error(String(err)));
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/** The error the command failed with, if it did. A nil reply is not one. */
|
|
288
|
+
get error(): Error | undefined {
|
|
289
|
+
return (
|
|
290
|
+
this.err ?? (this.reply instanceof ServerError ? this.reply : undefined)
|
|
291
|
+
);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/** Whether the command succeeded and replied nil. */
|
|
295
|
+
isNull(): boolean {
|
|
296
|
+
return !this.err && this.reply === null;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/** The reply, or the error it failed with, thrown. */
|
|
300
|
+
private get v(): Value {
|
|
301
|
+
if (this.err) throw this.err;
|
|
302
|
+
return this.reply;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/** The reply as plain values. */
|
|
306
|
+
value(): RedisValue {
|
|
307
|
+
return plain(this.v);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/** The reply as text: a string's bytes as UTF-8, or a number's digits. */
|
|
311
|
+
text(): string | null {
|
|
312
|
+
return this.v === null ? null : textOf(this.v);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/** The reply as bytes. */
|
|
316
|
+
bytes(): Buffer | null {
|
|
317
|
+
const v = ok(this.v);
|
|
318
|
+
if (v === null) return null;
|
|
319
|
+
return Buffer.isBuffer(v) ? v : Buffer.from(textOf(v), 'utf8');
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* The reply as a number, parsing a string that holds one. An integer past
|
|
324
|
+
* what a `number` holds exactly is rounded: read it with
|
|
325
|
+
* {@link Reply.bigint}.
|
|
326
|
+
*/
|
|
327
|
+
number(): number | null {
|
|
328
|
+
return this.v === null ? null : numberOf(this.v);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/** The reply as an integer, parsing a string that holds one. */
|
|
332
|
+
bigint(): bigint | null {
|
|
333
|
+
return this.v === null ? null : bigintOf(this.v);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/** The reply as a boolean: an integer is true unless 0, and `OK` is true. */
|
|
337
|
+
bool(): boolean | null {
|
|
338
|
+
return this.v === null ? null : boolOf(this.v);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/** The reply's text, parsed as JSON. */
|
|
342
|
+
json<T = unknown>(): T | null {
|
|
343
|
+
const text = this.text();
|
|
344
|
+
return text === null ? null : (JSON.parse(text) as T);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/** An array reply as each of its elements, to read each as what it holds. */
|
|
348
|
+
replies(): Reply[] {
|
|
349
|
+
return arrayOf(this.v).map(item => new Reply(item));
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* An array reply as text. A nil element throws; to tell missing elements
|
|
354
|
+
* apart, use {@link Reply.optionalTexts}.
|
|
355
|
+
*/
|
|
356
|
+
texts(): string[] {
|
|
357
|
+
return arrayOf(this.v).map(item => {
|
|
358
|
+
if (item === null)
|
|
359
|
+
throw new TypeError('redis: a nil element is not text');
|
|
360
|
+
return textOf(item);
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* An array reply as text, a nil element as `null`: what `mget` and `hmget`
|
|
366
|
+
* reply for a missing key or field.
|
|
367
|
+
*/
|
|
368
|
+
optionalTexts(): (string | null)[] {
|
|
369
|
+
return arrayOf(this.v).map(item => (item === null ? null : textOf(item)));
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/** An array reply as numbers. */
|
|
373
|
+
numbers(): number[] {
|
|
374
|
+
return arrayOf(this.v).map(numberOf);
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/** An array reply as booleans. */
|
|
378
|
+
bools(): boolean[] {
|
|
379
|
+
return arrayOf(this.v).map(boolOf);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* A map reply, or an array of keys and values in turn, as an object: what
|
|
384
|
+
* `hgetall` replies. The object has no prototype, so each field is its own
|
|
385
|
+
* key, `__proto__` too.
|
|
386
|
+
*/
|
|
387
|
+
textMap(): Record<string, string> {
|
|
388
|
+
return textMapOf(this.v);
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* The members of a sorted set with their scores, as `zrangeWithscores` and
|
|
393
|
+
* `zpopmin` reply.
|
|
394
|
+
*/
|
|
395
|
+
scoredMembers(): ScoredMember[] {
|
|
396
|
+
return scoredMembersOf(arrayOf(this.v));
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* The entries of a stream, as `xrange`, `xrevrange` and `xclaim` reply.
|
|
401
|
+
*/
|
|
402
|
+
streamEntries(): StreamEntry[] {
|
|
403
|
+
return arrayOf(this.v).map(streamEntryOf);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* The entries read from each stream, as `xread` and `xreadGroup` reply. A
|
|
408
|
+
* read that found nothing is no streams.
|
|
409
|
+
*/
|
|
410
|
+
streams(): Stream[] {
|
|
411
|
+
const v = ok(this.v);
|
|
412
|
+
if (v === null) return [];
|
|
413
|
+
const pairs: [Value, Value][] =
|
|
414
|
+
v instanceof MapReply
|
|
415
|
+
? v.entries
|
|
416
|
+
: arrayOf(v).map(item => {
|
|
417
|
+
const parts = arrayOf(item);
|
|
418
|
+
if (parts.length !== 2)
|
|
419
|
+
throw typeErr(item, 'a stream and its entries');
|
|
420
|
+
return [parts[0], parts[1]];
|
|
421
|
+
});
|
|
422
|
+
return pairs.map(([key, entries]) => ({
|
|
423
|
+
key: textOf(key),
|
|
424
|
+
entries: arrayOf(entries).map(streamEntryOf),
|
|
425
|
+
}));
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
/** The reply of `xpending`. */
|
|
429
|
+
streamPending(): StreamPending {
|
|
430
|
+
const parts = arrayOf(this.v);
|
|
431
|
+
if (parts.length !== 4) throw typeErr(this.v, 'a pending summary');
|
|
432
|
+
const count = numberOf(parts[0]);
|
|
433
|
+
if (count === 0) return {count, lowest: null, highest: null, consumers: []};
|
|
434
|
+
return {
|
|
435
|
+
count,
|
|
436
|
+
lowest: textOf(parts[1]),
|
|
437
|
+
highest: textOf(parts[2]),
|
|
438
|
+
consumers: arrayOf(parts[3]).map(c => {
|
|
439
|
+
const pair = arrayOf(c);
|
|
440
|
+
if (pair.length !== 2) throw typeErr(c, 'a consumer and its count');
|
|
441
|
+
return {name: textOf(pair[0]), pending: numberOf(pair[1])};
|
|
442
|
+
}),
|
|
443
|
+
};
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
/** The reply of `xinfoStream`. */
|
|
447
|
+
streamInfo(): StreamInfo {
|
|
448
|
+
const items = arrayOf(this.v);
|
|
449
|
+
const out: StreamInfo = {
|
|
450
|
+
length: 0,
|
|
451
|
+
radixTreeKeys: 0,
|
|
452
|
+
radixTreeNodes: 0,
|
|
453
|
+
groups: 0,
|
|
454
|
+
lastGeneratedId: '',
|
|
455
|
+
firstEntry: null,
|
|
456
|
+
lastEntry: null,
|
|
457
|
+
};
|
|
458
|
+
for (let i = 0; i + 1 < items.length; i += 2) {
|
|
459
|
+
const v = items[i + 1];
|
|
460
|
+
switch (textOf(items[i])) {
|
|
461
|
+
case 'length':
|
|
462
|
+
out.length = numberOf(v);
|
|
463
|
+
break;
|
|
464
|
+
case 'radix-tree-keys':
|
|
465
|
+
out.radixTreeKeys = numberOf(v);
|
|
466
|
+
break;
|
|
467
|
+
case 'radix-tree-nodes':
|
|
468
|
+
out.radixTreeNodes = numberOf(v);
|
|
469
|
+
break;
|
|
470
|
+
case 'groups':
|
|
471
|
+
out.groups = numberOf(v);
|
|
472
|
+
break;
|
|
473
|
+
case 'last-generated-id':
|
|
474
|
+
out.lastGeneratedId = textOf(v);
|
|
475
|
+
break;
|
|
476
|
+
case 'first-entry':
|
|
477
|
+
out.firstEntry = v === null ? null : streamEntryOf(v);
|
|
478
|
+
break;
|
|
479
|
+
case 'last-entry':
|
|
480
|
+
out.lastEntry = v === null ? null : streamEntryOf(v);
|
|
481
|
+
break;
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
return out;
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
/** The reply of `xautoclaim`. */
|
|
488
|
+
streamAutoClaim(): StreamAutoClaim {
|
|
489
|
+
const parts = arrayOf(this.v);
|
|
490
|
+
if (parts.length < 2) throw typeErr(this.v, 'an autoclaim reply');
|
|
491
|
+
return {
|
|
492
|
+
next: textOf(parts[0]),
|
|
493
|
+
claimed: arrayOf(parts[1]).map(streamEntryOf),
|
|
494
|
+
deleted: parts.length > 2 ? arrayOf(parts[2]).map(textOf) : [],
|
|
495
|
+
};
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
/** The position of each member, a missing one as `null`, as `geoPos` replies. */
|
|
499
|
+
geoPositions(): (GeoPosition | null)[] {
|
|
500
|
+
return arrayOf(this.v).map(item =>
|
|
501
|
+
item === null ? null : geoPositionOf(item),
|
|
502
|
+
);
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
/** The members a radius search found, as `geoRadius` replies. */
|
|
506
|
+
geoRadius(): GeoRadiusResult[] {
|
|
507
|
+
return arrayOf(this.v).map(item => {
|
|
508
|
+
// A plain name without any of withDist, withHash and withCoord;
|
|
509
|
+
// otherwise the name, then what was asked for, which the types tell
|
|
510
|
+
// apart: the distance a string, the hash an integer, the position an
|
|
511
|
+
// array.
|
|
512
|
+
if (!Array.isArray(item)) return {name: textOf(item)};
|
|
513
|
+
if (item.length === 0) throw typeErr(item, 'a search result');
|
|
514
|
+
const out: GeoRadiusResult = {name: textOf(item[0])};
|
|
515
|
+
for (const part of item.slice(1)) {
|
|
516
|
+
if (typeof part === 'bigint') out.hash = part;
|
|
517
|
+
else if (Array.isArray(part)) out.coord = geoPositionOf(part);
|
|
518
|
+
else out.dist = numberOf(part);
|
|
519
|
+
}
|
|
520
|
+
return out;
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
/**
|
|
526
|
+
* A command's reply, on its way. Await it for the {@link Reply}, which
|
|
527
|
+
* rejects if the command failed; or read it as what it holds straight away:
|
|
528
|
+
*
|
|
529
|
+
* ```ts
|
|
530
|
+
* const name = await SESSIONS.string.get("name:1").text();
|
|
531
|
+
* ```
|
|
532
|
+
*
|
|
533
|
+
* The command is sent when it is called, whether or not this is awaited.
|
|
534
|
+
*/
|
|
535
|
+
export class ReplyPromise implements PromiseLike<Reply> {
|
|
536
|
+
/** @internal */
|
|
537
|
+
constructor(private readonly reply: Promise<Reply>) {}
|
|
538
|
+
|
|
539
|
+
then<T = Reply, E = never>(
|
|
540
|
+
onfulfilled?: ((value: Reply) => T | PromiseLike<T>) | null,
|
|
541
|
+
onrejected?: ((reason: unknown) => E | PromiseLike<E>) | null,
|
|
542
|
+
): Promise<T | E> {
|
|
543
|
+
return this.reply
|
|
544
|
+
.then(r => {
|
|
545
|
+
if (r.error) throw r.error;
|
|
546
|
+
return r;
|
|
547
|
+
})
|
|
548
|
+
.then(onfulfilled, onrejected);
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
catch<E = never>(
|
|
552
|
+
onrejected?: ((reason: unknown) => E | PromiseLike<E>) | null,
|
|
553
|
+
): Promise<Reply | E> {
|
|
554
|
+
return this.then(undefined, onrejected);
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
finally(onfinally?: (() => void) | null): Promise<Reply> {
|
|
558
|
+
return this.then().finally(onfinally);
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
/** See {@link Reply.value}. */
|
|
562
|
+
value(): Promise<RedisValue> {
|
|
563
|
+
return this.then(r => r.value());
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
/** See {@link Reply.text}. */
|
|
567
|
+
text(): Promise<string | null> {
|
|
568
|
+
return this.then(r => r.text());
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
/** See {@link Reply.bytes}. */
|
|
572
|
+
bytes(): Promise<Buffer | null> {
|
|
573
|
+
return this.then(r => r.bytes());
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
/** See {@link Reply.number}. */
|
|
577
|
+
number(): Promise<number | null> {
|
|
578
|
+
return this.then(r => r.number());
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
/** See {@link Reply.bigint}. */
|
|
582
|
+
bigint(): Promise<bigint | null> {
|
|
583
|
+
return this.then(r => r.bigint());
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
/** See {@link Reply.bool}. */
|
|
587
|
+
bool(): Promise<boolean | null> {
|
|
588
|
+
return this.then(r => r.bool());
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
/** See {@link Reply.json}. */
|
|
592
|
+
json<T = unknown>(): Promise<T | null> {
|
|
593
|
+
return this.then(r => r.json<T>());
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
/** See {@link Reply.replies}. */
|
|
597
|
+
replies(): Promise<Reply[]> {
|
|
598
|
+
return this.then(r => r.replies());
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
/** See {@link Reply.texts}. */
|
|
602
|
+
texts(): Promise<string[]> {
|
|
603
|
+
return this.then(r => r.texts());
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
/** See {@link Reply.optionalTexts}. */
|
|
607
|
+
optionalTexts(): Promise<(string | null)[]> {
|
|
608
|
+
return this.then(r => r.optionalTexts());
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
/** See {@link Reply.numbers}. */
|
|
612
|
+
numbers(): Promise<number[]> {
|
|
613
|
+
return this.then(r => r.numbers());
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
/** See {@link Reply.bools}. */
|
|
617
|
+
bools(): Promise<boolean[]> {
|
|
618
|
+
return this.then(r => r.bools());
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
/** See {@link Reply.textMap}. */
|
|
622
|
+
textMap(): Promise<Record<string, string>> {
|
|
623
|
+
return this.then(r => r.textMap());
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
/** See {@link Reply.scoredMembers}. */
|
|
627
|
+
scoredMembers(): Promise<ScoredMember[]> {
|
|
628
|
+
return this.then(r => r.scoredMembers());
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
/** See {@link Reply.streamEntries}. */
|
|
632
|
+
streamEntries(): Promise<StreamEntry[]> {
|
|
633
|
+
return this.then(r => r.streamEntries());
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
/** See {@link Reply.streams}. */
|
|
637
|
+
streams(): Promise<Stream[]> {
|
|
638
|
+
return this.then(r => r.streams());
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
/** See {@link Reply.streamPending}. */
|
|
642
|
+
streamPending(): Promise<StreamPending> {
|
|
643
|
+
return this.then(r => r.streamPending());
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
/** See {@link Reply.streamInfo}. */
|
|
647
|
+
streamInfo(): Promise<StreamInfo> {
|
|
648
|
+
return this.then(r => r.streamInfo());
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
/** See {@link Reply.streamAutoClaim}. */
|
|
652
|
+
streamAutoClaim(): Promise<StreamAutoClaim> {
|
|
653
|
+
return this.then(r => r.streamAutoClaim());
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
/** See {@link Reply.geoPositions}. */
|
|
657
|
+
geoPositions(): Promise<(GeoPosition | null)[]> {
|
|
658
|
+
return this.then(r => r.geoPositions());
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
/** See {@link Reply.geoRadius}. */
|
|
662
|
+
geoRadius(): Promise<GeoRadiusResult[]> {
|
|
663
|
+
return this.then(r => r.geoRadius());
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
/**
|
|
668
|
+
* The error a pipeline or a transaction fails with when the server rejected
|
|
669
|
+
* some of its commands. The others ran: Redis has no rollback.
|
|
670
|
+
*/
|
|
671
|
+
export class BatchError extends Error {
|
|
672
|
+
/** Every command's reply, in the order queued, each holding its own error. */
|
|
673
|
+
readonly replies: Reply[];
|
|
674
|
+
|
|
675
|
+
/** @internal */
|
|
676
|
+
constructor(replies: Reply[], first: Error) {
|
|
677
|
+
super(first.message);
|
|
678
|
+
this.replies = replies;
|
|
679
|
+
Object.defineProperty(this, 'name', {
|
|
680
|
+
value: 'BatchError',
|
|
681
|
+
enumerable: false,
|
|
682
|
+
configurable: true,
|
|
683
|
+
});
|
|
684
|
+
Object.setPrototypeOf(this, BatchError.prototype);
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
/** Converters for the commands whose reply has one shape. */
|
|
689
|
+
export const as = {
|
|
690
|
+
/** The reply, for the caller to read. */
|
|
691
|
+
reply: (v: Value): Reply => new Reply(v),
|
|
692
|
+
none: (v: Value): void => {
|
|
693
|
+
ok(v);
|
|
694
|
+
},
|
|
695
|
+
number: (v: Value): number => numberOf(ok(v) === null ? nilErr() : v),
|
|
696
|
+
optionalNumber: (v: Value): number | null =>
|
|
697
|
+
ok(v) === null ? null : numberOf(v),
|
|
698
|
+
bool: (v: Value): boolean => boolOf(ok(v) === null ? nilErr() : v),
|
|
699
|
+
text: (v: Value): string => textOf(ok(v) === null ? nilErr() : v),
|
|
700
|
+
bools: (v: Value): boolean[] => arrayOf(v).map(boolOf),
|
|
701
|
+
};
|
|
702
|
+
|
|
703
|
+
function nilErr(): never {
|
|
704
|
+
throw new TypeError('redis: the command replied nil');
|
|
705
|
+
}
|