@upstash/redis 0.1.3 → 0.1.7

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/src/client.ts CHANGED
@@ -1,17 +1,11 @@
1
1
  import fetch from 'isomorphic-unfetch';
2
2
  import {
3
3
  ClientObjectProps,
4
- EdgeCacheType,
5
4
  MethodReturn,
6
5
  Part,
7
- RequestConfig,
8
6
  ReturnType,
9
7
  Upstash,
10
- } from './type';
11
-
12
- function isObject(objectToCheck: any): boolean {
13
- return typeof objectToCheck === 'object' && objectToCheck !== null;
14
- }
8
+ } from './types';
15
9
 
16
10
  /**
17
11
  * Parse Options
@@ -19,150 +13,82 @@ function isObject(objectToCheck: any): boolean {
19
13
  function parseOptions(
20
14
  url?: string | ClientObjectProps,
21
15
  token?: string,
22
- edgeUrl?: string,
23
- readFromEdge?: boolean
16
+ requestOptions: undefined | RequestInit = {}
24
17
  ): ClientObjectProps {
25
- if (url && typeof url !== 'string') {
26
- return parseOptions(url?.url, url?.token, url?.edgeUrl, url?.readFromEdge);
18
+ if (typeof url === 'object' && url !== null) {
19
+ return parseOptions(url.url, url.token, url.requestOptions);
27
20
  }
28
21
 
29
- if (!url) {
30
- // try auto fill from env variables
22
+ // try auto fill from env variables
23
+ if (!url && typeof window === 'undefined') {
31
24
  url = process.env.UPSTASH_REDIS_REST_URL;
32
25
  token = process.env.UPSTASH_REDIS_REST_TOKEN;
33
- edgeUrl = process.env.UPSTASH_REDIS_EDGE_URL;
34
26
  }
35
27
 
36
- readFromEdge = readFromEdge ?? !!edgeUrl;
37
-
38
- return edgeUrl ? { url, token, edgeUrl, readFromEdge } : { url, token };
28
+ return { url: url as string, token, requestOptions };
39
29
  }
40
30
 
41
31
  /**
42
32
  * Fetch
43
33
  */
44
34
  async function fetchData(
45
- url: string,
46
35
  options: ClientObjectProps,
47
- init: RequestInit
36
+ ...parts: Part[]
48
37
  ): Promise<ReturnType> {
38
+ if (!options.url) {
39
+ throw 'Database url not found?';
40
+ }
41
+
49
42
  try {
50
- const res = await fetch(url, {
51
- ...init,
43
+ const res = await fetch(options.url!, {
44
+ method: 'POST',
45
+ body: JSON.stringify(parts),
52
46
  headers: {
53
47
  Authorization: `Bearer ${options.token}`,
54
- ...init.headers,
48
+ ...options.requestOptions?.headers,
55
49
  },
50
+ ...options.requestOptions,
56
51
  });
57
52
 
58
53
  const data = await res.json();
59
54
 
60
- if (res.ok) {
61
- let edge = false;
62
- let cache: EdgeCacheType = null;
63
-
64
- switch (res.headers.get('x-cache')) {
65
- case 'Hit from cloudfront':
66
- edge = true;
67
- cache = 'hit';
68
- break;
69
- case 'Miss from cloudfront':
70
- edge = true;
71
- cache = 'miss';
72
- break;
73
- }
74
-
75
- return {
76
- data: data.result,
77
- error: null,
78
- metadata: { edge, cache },
79
- };
80
- } else {
81
- if (data.error) throw data;
82
- throw new Error(
83
- `Upstash failed with (${res.status}): ${JSON.stringify(data, null, 2)}`
84
- );
55
+ if (!res.ok) {
56
+ if (data.error) throw data.error;
57
+ throw `Upstash failed with (${res.status}): ${JSON.stringify(
58
+ data,
59
+ null,
60
+ 2
61
+ )}`;
85
62
  }
63
+
64
+ return {
65
+ data: data.result,
66
+ error: null,
67
+ };
86
68
  } catch (err) {
87
69
  return {
88
70
  data: null,
89
- error: typeof err.data === 'object' ? err.data.message : err,
90
- metadata: { edge: false, cache: null },
71
+ // @ts-ignore
72
+ error: err,
91
73
  };
92
74
  }
93
75
  }
94
76
 
95
- /**
96
- * Request
97
- */
98
- function request(
99
- options: ClientObjectProps,
100
- config: RequestConfig,
101
- ...parts: Part[]
102
- ): MethodReturn {
103
- if (!options.url) {
104
- throw new Error('Database url not found?');
105
- }
106
-
107
- if (!options.edgeUrl) {
108
- if (options.readFromEdge || config?.edge) {
109
- throw new Error('You need to set Edge Url to read from edge.');
110
- }
111
- }
112
-
113
- let fromEdge = !!options.edgeUrl && options.readFromEdge !== false;
114
-
115
- if (config === undefined) {
116
- fromEdge = false;
117
- } else if (options.edgeUrl) {
118
- fromEdge = config?.edge ?? true;
119
- }
120
-
121
- if (fromEdge) {
122
- const command = encodeURI(parts.join('/'));
123
- const edgeUrlWithPath = `${options.edgeUrl!}/${command}`;
124
- return fetchData(edgeUrlWithPath, options, { method: 'GET' });
125
- } else {
126
- return fetchData(options.url!, options, {
127
- method: 'POST',
128
- body: JSON.stringify(parts),
129
- });
130
- }
131
- }
132
-
133
- function hasConfig(options: ClientObjectProps, command: string, a: any) {
134
- let lastArg;
135
- let args = [...a];
136
-
137
- if (a.length > 0) {
138
- lastArg = args.pop();
139
- }
140
-
141
- if (isObject(lastArg)) {
142
- return request(options, lastArg, command, ...args);
143
- } else {
144
- return request(options, {}, command, ...a);
145
- }
146
- }
147
-
148
77
  /**
149
78
  * Creates a Upstash Redis instance
150
79
  *
151
80
  * @constructor
152
- * @param {string} url - database rest url
153
- * @param {string} token - database rest token
154
- * @param {Object} options - database config
155
- * @param {string} [options.url] - database rest url
156
- * @param {string} [options.token] - database rest token
157
- * @param {string} [options.edgeUrl] - database rest edge url
158
- * @param {string} [options.readFromEdge] - database rest read from edge
81
+ * @param {Object} options
82
+ * @param {string} [options.url]
83
+ * @param {string} [options.token]
84
+ * @param {Object} [options.requestOptions]
159
85
  *
160
86
  * @example
161
87
  * ```js
162
88
  * import upstash from '@upstash/redis'
163
89
  *
164
90
  * const redis1 = upstash('url', token);
165
- * const redis2 = upstash({ url: '', token: '', edgeUrl: '', readFromEdge: false });
91
+ * const redis2 = upstash({ url: '', token: '', requestOptions: {} });
166
92
  * ```
167
93
  */
168
94
 
@@ -181,7 +107,6 @@ function upstash(url?: string | ClientObjectProps, token?: string): Upstash {
181
107
  {
182
108
  url: undefined,
183
109
  token: undefined,
184
- edgeUrl: undefined,
185
110
  },
186
111
  parseOptions(arguments[0], arguments[1])
187
112
  );
@@ -192,58 +117,58 @@ function upstash(url?: string | ClientObjectProps, token?: string): Upstash {
192
117
  */
193
118
 
194
119
  function append() {
195
- return request(options, undefined, 'append', ...arguments);
120
+ return fetchData(options, 'append', ...arguments);
196
121
  }
197
122
  function decr() {
198
- return request(options, undefined, 'decr', ...arguments);
123
+ return fetchData(options, 'decr', ...arguments);
199
124
  }
200
125
  function decrby() {
201
- return request(options, undefined, 'decrby', ...arguments);
126
+ return fetchData(options, 'decrby', ...arguments);
202
127
  }
203
128
  function get() {
204
- return hasConfig(options, 'get', arguments);
129
+ return fetchData(options, 'get', ...arguments);
205
130
  }
206
131
  function getrange() {
207
- return hasConfig(options, 'getrange', arguments);
132
+ return fetchData(options, 'getrange', ...arguments);
208
133
  }
209
134
  function getset() {
210
- return request(options, undefined, 'getset', ...arguments);
135
+ return fetchData(options, 'getset', ...arguments);
211
136
  }
212
137
  function incr() {
213
- return request(options, undefined, 'incr', ...arguments);
138
+ return fetchData(options, 'incr', ...arguments);
214
139
  }
215
140
  function incrby() {
216
- return request(options, undefined, 'incrby', ...arguments);
141
+ return fetchData(options, 'incrby', ...arguments);
217
142
  }
218
143
  function incrbyfloat() {
219
- return request(options, undefined, 'incrbyfloat', ...arguments);
144
+ return fetchData(options, 'incrbyfloat', ...arguments);
220
145
  }
221
146
  function mget() {
222
- return hasConfig(options, 'mget', arguments);
147
+ return fetchData(options, 'mget', ...arguments);
223
148
  }
224
149
  function mset() {
225
- return request(options, undefined, 'mset', ...arguments);
150
+ return fetchData(options, 'mset', ...arguments);
226
151
  }
227
152
  function msetnx() {
228
- return request(options, undefined, 'msetnx', ...arguments);
153
+ return fetchData(options, 'msetnx', ...arguments);
229
154
  }
230
155
  function psetex() {
231
- return request(options, undefined, 'psetex', ...arguments);
156
+ return fetchData(options, 'psetex', ...arguments);
232
157
  }
233
158
  function set() {
234
- return request(options, undefined, 'set', ...arguments);
159
+ return fetchData(options, 'set', ...arguments);
235
160
  }
236
161
  function setex() {
237
- return request(options, undefined, 'setex', ...arguments);
162
+ return fetchData(options, 'setex', ...arguments);
238
163
  }
239
164
  function setnx() {
240
- return request(options, undefined, 'setnx', ...arguments);
165
+ return fetchData(options, 'setnx', ...arguments);
241
166
  }
242
167
  function setrange() {
243
- return request(options, undefined, 'setrange', ...arguments);
168
+ return fetchData(options, 'setrange', ...arguments);
244
169
  }
245
170
  function strlen() {
246
- return hasConfig(options, 'strlen', arguments);
171
+ return fetchData(options, 'strlen', ...arguments);
247
172
  }
248
173
 
249
174
  /**
@@ -251,19 +176,19 @@ function upstash(url?: string | ClientObjectProps, token?: string): Upstash {
251
176
  */
252
177
 
253
178
  function bitcount() {
254
- return hasConfig(options, 'bitcount', arguments);
179
+ return fetchData(options, 'bitcount', ...arguments);
255
180
  }
256
181
  function bitop() {
257
- return request(options, undefined, 'bitop', ...arguments);
182
+ return fetchData(options, 'bitop', ...arguments);
258
183
  }
259
184
  function bitpos() {
260
- return hasConfig(options, 'bitpos', arguments);
185
+ return fetchData(options, 'bitpos', ...arguments);
261
186
  }
262
187
  function getbit() {
263
- return hasConfig(options, 'getbit', arguments);
188
+ return fetchData(options, 'getbit', ...arguments);
264
189
  }
265
190
  function setbit() {
266
- return request(options, undefined, 'setbit', ...arguments);
191
+ return fetchData(options, 'setbit', ...arguments);
267
192
  }
268
193
 
269
194
  /**
@@ -271,10 +196,10 @@ function upstash(url?: string | ClientObjectProps, token?: string): Upstash {
271
196
  */
272
197
 
273
198
  function echo() {
274
- return hasConfig(options, 'echo', arguments);
199
+ return fetchData(options, 'echo', ...arguments);
275
200
  }
276
201
  function ping() {
277
- return hasConfig(options, 'ping', arguments);
202
+ return fetchData(options, 'ping', ...arguments);
278
203
  }
279
204
 
280
205
  /**
@@ -282,46 +207,46 @@ function upstash(url?: string | ClientObjectProps, token?: string): Upstash {
282
207
  */
283
208
 
284
209
  function hdel(): MethodReturn {
285
- return request(options, undefined, 'hdel', ...arguments);
210
+ return fetchData(options, 'hdel', ...arguments);
286
211
  }
287
212
  function hexists(): MethodReturn {
288
- return hasConfig(options, 'hexists', arguments);
213
+ return fetchData(options, 'hexists', ...arguments);
289
214
  }
290
215
  function hget(): MethodReturn {
291
- return hasConfig(options, 'hget', arguments);
216
+ return fetchData(options, 'hget', ...arguments);
292
217
  }
293
218
  function hgetall(): MethodReturn {
294
- return hasConfig(options, 'hgetall', arguments);
219
+ return fetchData(options, 'hgetall', ...arguments);
295
220
  }
296
221
  function hincrby(): MethodReturn {
297
- return request(options, undefined, 'hincrby', ...arguments);
222
+ return fetchData(options, 'hincrby', ...arguments);
298
223
  }
299
224
  function hincrbyfloat(): MethodReturn {
300
- return request(options, undefined, 'hincrbyfloat', ...arguments);
225
+ return fetchData(options, 'hincrbyfloat', ...arguments);
301
226
  }
302
227
  function hkeys(): MethodReturn {
303
- return hasConfig(options, 'hkeys', arguments);
228
+ return fetchData(options, 'hkeys', ...arguments);
304
229
  }
305
230
  function hlen(): MethodReturn {
306
- return hasConfig(options, 'hlen', arguments);
231
+ return fetchData(options, 'hlen', ...arguments);
307
232
  }
308
233
  function hmget(): MethodReturn {
309
- return hasConfig(options, 'hmget', arguments);
234
+ return fetchData(options, 'hmget', ...arguments);
310
235
  }
311
236
  function hmset(): MethodReturn {
312
- return request(options, undefined, 'hmset', ...arguments);
237
+ return fetchData(options, 'hmset', ...arguments);
313
238
  }
314
239
  function hscan(): MethodReturn {
315
- return request(options, undefined, 'hscan', ...arguments);
240
+ return fetchData(options, 'hscan', ...arguments);
316
241
  }
317
242
  function hset(): MethodReturn {
318
- return request(options, undefined, 'hset', ...arguments);
243
+ return fetchData(options, 'hset', ...arguments);
319
244
  }
320
245
  function hsetnx(): MethodReturn {
321
- return request(options, undefined, 'hsetnx', ...arguments);
246
+ return fetchData(options, 'hsetnx', ...arguments);
322
247
  }
323
248
  function hvals(): MethodReturn {
324
- return hasConfig(options, 'hvals', arguments);
249
+ return fetchData(options, 'hvals', ...arguments);
325
250
  }
326
251
 
327
252
  /**
@@ -329,55 +254,55 @@ function upstash(url?: string | ClientObjectProps, token?: string): Upstash {
329
254
  */
330
255
 
331
256
  function del(): MethodReturn {
332
- return request(options, undefined, 'del', ...arguments);
257
+ return fetchData(options, 'del', ...arguments);
333
258
  }
334
259
  function exists(): MethodReturn {
335
- return hasConfig(options, 'exists', arguments);
260
+ return fetchData(options, 'exists', ...arguments);
336
261
  }
337
262
  function expire(): MethodReturn {
338
- return request(options, undefined, 'expire', ...arguments);
263
+ return fetchData(options, 'expire', ...arguments);
339
264
  }
340
265
  function expireat(): MethodReturn {
341
- return request(options, undefined, 'expireat', ...arguments);
266
+ return fetchData(options, 'expireat', ...arguments);
342
267
  }
343
268
  function keys(): MethodReturn {
344
- return hasConfig(options, 'keys', arguments);
269
+ return fetchData(options, 'keys', ...arguments);
345
270
  }
346
271
  function persist(): MethodReturn {
347
- return request(options, undefined, 'persist', ...arguments);
272
+ return fetchData(options, 'persist', ...arguments);
348
273
  }
349
274
  function pexpire(): MethodReturn {
350
- return request(options, undefined, 'pexpire', ...arguments);
275
+ return fetchData(options, 'pexpire', ...arguments);
351
276
  }
352
277
  function pexpireat(): MethodReturn {
353
- return request(options, undefined, 'pexpireat', ...arguments);
278
+ return fetchData(options, 'pexpireat', ...arguments);
354
279
  }
355
280
  function pttl(): MethodReturn {
356
- return hasConfig(options, 'pttl', arguments);
281
+ return fetchData(options, 'pttl', ...arguments);
357
282
  }
358
283
  function randomkey(): MethodReturn {
359
- return request(options, undefined, 'randomkey', ...arguments);
284
+ return fetchData(options, 'randomkey', ...arguments);
360
285
  }
361
286
  function rename(): MethodReturn {
362
- return request(options, undefined, 'rename', ...arguments);
287
+ return fetchData(options, 'rename', ...arguments);
363
288
  }
364
289
  function renamenx(): MethodReturn {
365
- return request(options, undefined, 'renamenx', ...arguments);
290
+ return fetchData(options, 'renamenx', ...arguments);
366
291
  }
367
292
  function scan(): MethodReturn {
368
- return request(options, undefined, 'scan', ...arguments);
293
+ return fetchData(options, 'scan', ...arguments);
369
294
  }
370
295
  function touch(): MethodReturn {
371
- return request(options, undefined, 'touch', ...arguments);
296
+ return fetchData(options, 'touch', ...arguments);
372
297
  }
373
298
  function ttl(): MethodReturn {
374
- return hasConfig(options, 'ttl', arguments);
299
+ return fetchData(options, 'ttl', ...arguments);
375
300
  }
376
301
  function type(): MethodReturn {
377
- return hasConfig(options, 'type', arguments);
302
+ return fetchData(options, 'type', ...arguments);
378
303
  }
379
304
  function unlink(): MethodReturn {
380
- return request(options, undefined, 'unlink', ...arguments);
305
+ return fetchData(options, 'unlink', ...arguments);
381
306
  }
382
307
 
383
308
  /**
@@ -385,46 +310,46 @@ function upstash(url?: string | ClientObjectProps, token?: string): Upstash {
385
310
  */
386
311
 
387
312
  function lindex(): MethodReturn {
388
- return hasConfig(options, 'lindex', arguments);
313
+ return fetchData(options, 'lindex', ...arguments);
389
314
  }
390
315
  function linsert(): MethodReturn {
391
- return request(options, undefined, 'linsert', ...arguments);
316
+ return fetchData(options, 'linsert', ...arguments);
392
317
  }
393
318
  function llen(): MethodReturn {
394
- return hasConfig(options, 'llen', arguments);
319
+ return fetchData(options, 'llen', ...arguments);
395
320
  }
396
321
  function lpop(): MethodReturn {
397
- return request(options, undefined, 'lpop', ...arguments);
322
+ return fetchData(options, 'lpop', ...arguments);
398
323
  }
399
324
  function lpush(): MethodReturn {
400
- return request(options, undefined, 'lpush', ...arguments);
325
+ return fetchData(options, 'lpush', ...arguments);
401
326
  }
402
327
  function lpushx(): MethodReturn {
403
- return request(options, undefined, 'lpushx', ...arguments);
328
+ return fetchData(options, 'lpushx', ...arguments);
404
329
  }
405
330
  function lrange(): MethodReturn {
406
- return hasConfig(options, 'lrange', arguments);
331
+ return fetchData(options, 'lrange', ...arguments);
407
332
  }
408
333
  function lrem(): MethodReturn {
409
- return request(options, undefined, 'lrem', ...arguments);
334
+ return fetchData(options, 'lrem', ...arguments);
410
335
  }
411
336
  function lset(): MethodReturn {
412
- return request(options, undefined, 'lset', ...arguments);
337
+ return fetchData(options, 'lset', ...arguments);
413
338
  }
414
339
  function ltrim(): MethodReturn {
415
- return request(options, undefined, 'ltrim', ...arguments);
340
+ return fetchData(options, 'ltrim', ...arguments);
416
341
  }
417
342
  function rpop(): MethodReturn {
418
- return request(options, undefined, 'rpop', ...arguments);
343
+ return fetchData(options, 'rpop', ...arguments);
419
344
  }
420
345
  function rpoplpush(): MethodReturn {
421
- return request(options, undefined, 'rpoplpush', ...arguments);
346
+ return fetchData(options, 'rpoplpush', ...arguments);
422
347
  }
423
348
  function rpush(): MethodReturn {
424
- return request(options, undefined, 'rpush', ...arguments);
349
+ return fetchData(options, 'rpush', ...arguments);
425
350
  }
426
351
  function rpushx(): MethodReturn {
427
- return request(options, undefined, 'rpushx', ...arguments);
352
+ return fetchData(options, 'rpushx', ...arguments);
428
353
  }
429
354
 
430
355
  /**
@@ -432,19 +357,19 @@ function upstash(url?: string | ClientObjectProps, token?: string): Upstash {
432
357
  */
433
358
 
434
359
  function dbsize(): MethodReturn {
435
- return hasConfig(options, 'dbsize', arguments);
360
+ return fetchData(options, 'dbsize', ...arguments);
436
361
  }
437
362
  function flushall(): MethodReturn {
438
- return request(options, undefined, 'flushall', ...arguments);
363
+ return fetchData(options, 'flushall', ...arguments);
439
364
  }
440
365
  function flushdb(): MethodReturn {
441
- return request(options, undefined, 'flushdb', ...arguments);
366
+ return fetchData(options, 'flushdb', ...arguments);
442
367
  }
443
368
  function info(): MethodReturn {
444
- return hasConfig(options, 'info', arguments);
369
+ return fetchData(options, 'info', ...arguments);
445
370
  }
446
371
  function time(): MethodReturn {
447
- return request(options, undefined, 'time', ...arguments);
372
+ return fetchData(options, 'time', ...arguments);
448
373
  }
449
374
 
450
375
  /**
@@ -452,46 +377,46 @@ function upstash(url?: string | ClientObjectProps, token?: string): Upstash {
452
377
  */
453
378
 
454
379
  function sadd(): MethodReturn {
455
- return request(options, undefined, 'sadd', ...arguments);
380
+ return fetchData(options, 'sadd', ...arguments);
456
381
  }
457
382
  function scard(): MethodReturn {
458
- return request(options, undefined, 'scard', ...arguments);
383
+ return fetchData(options, 'scard', ...arguments);
459
384
  }
460
385
  function sdiff(): MethodReturn {
461
- return hasConfig(options, 'sdiff', arguments);
386
+ return fetchData(options, 'sdiff', ...arguments);
462
387
  }
463
388
  function sdiffstore(): MethodReturn {
464
- return request(options, undefined, 'sdiffstore', ...arguments);
389
+ return fetchData(options, 'sdiffstore', ...arguments);
465
390
  }
466
391
  function sinter(): MethodReturn {
467
- return hasConfig(options, 'sinter', arguments);
392
+ return fetchData(options, 'sinter', ...arguments);
468
393
  }
469
394
  function sinterstore(): MethodReturn {
470
- return request(options, undefined, 'sinterstore', ...arguments);
395
+ return fetchData(options, 'sinterstore', ...arguments);
471
396
  }
472
397
  function sismember(): MethodReturn {
473
- return hasConfig(options, 'sismember', arguments);
398
+ return fetchData(options, 'sismember', ...arguments);
474
399
  }
475
400
  function smembers(): MethodReturn {
476
- return hasConfig(options, 'smembers', arguments);
401
+ return fetchData(options, 'smembers', ...arguments);
477
402
  }
478
403
  function smove(): MethodReturn {
479
- return request(options, undefined, 'smove', ...arguments);
404
+ return fetchData(options, 'smove', ...arguments);
480
405
  }
481
406
  function spop(): MethodReturn {
482
- return request(options, undefined, 'spop', ...arguments);
407
+ return fetchData(options, 'spop', ...arguments);
483
408
  }
484
409
  function srandmember(): MethodReturn {
485
- return hasConfig(options, 'srandmember', arguments);
410
+ return fetchData(options, 'srandmember', ...arguments);
486
411
  }
487
412
  function srem(): MethodReturn {
488
- return request(options, undefined, 'srem', ...arguments);
413
+ return fetchData(options, 'srem', ...arguments);
489
414
  }
490
415
  function sunion(): MethodReturn {
491
- return hasConfig(options, 'sunion', arguments);
416
+ return fetchData(options, 'sunion', ...arguments);
492
417
  }
493
418
  function sunionstore(): MethodReturn {
494
- return request(options, undefined, 'sunionstore', ...arguments);
419
+ return fetchData(options, 'sunionstore', ...arguments);
495
420
  }
496
421
 
497
422
  /**
@@ -499,70 +424,70 @@ function upstash(url?: string | ClientObjectProps, token?: string): Upstash {
499
424
  */
500
425
 
501
426
  function zadd(): MethodReturn {
502
- return request(options, undefined, 'zadd', ...arguments);
427
+ return fetchData(options, 'zadd', ...arguments);
503
428
  }
504
429
  function zcard(): MethodReturn {
505
- return hasConfig(options, 'zcard', arguments);
430
+ return fetchData(options, 'zcard', ...arguments);
506
431
  }
507
432
  function zcount(): MethodReturn {
508
- return hasConfig(options, 'zcount', arguments);
433
+ return fetchData(options, 'zcount', ...arguments);
509
434
  }
510
435
  function zincrby(): MethodReturn {
511
- return request(options, undefined, 'zincrby', ...arguments);
436
+ return fetchData(options, 'zincrby', ...arguments);
512
437
  }
513
438
  function zinterstore(): MethodReturn {
514
- return request(options, undefined, 'zinterstore', ...arguments);
439
+ return fetchData(options, 'zinterstore', ...arguments);
515
440
  }
516
441
  function zlexcount(): MethodReturn {
517
- return hasConfig(options, 'zlexcount', arguments);
442
+ return fetchData(options, 'zlexcount', ...arguments);
518
443
  }
519
444
  function zpopmax(): MethodReturn {
520
- return request(options, undefined, 'zpopmax', ...arguments);
445
+ return fetchData(options, 'zpopmax', ...arguments);
521
446
  }
522
447
  function zpopmin(): MethodReturn {
523
- return request(options, undefined, 'zpopmin', ...arguments);
448
+ return fetchData(options, 'zpopmin', ...arguments);
524
449
  }
525
450
  function zrange(): MethodReturn {
526
- return hasConfig(options, 'zrange', arguments);
451
+ return fetchData(options, 'zrange', ...arguments);
527
452
  }
528
453
  function zrangebylex(): MethodReturn {
529
- return hasConfig(options, 'zrangebylex', arguments);
454
+ return fetchData(options, 'zrangebylex', ...arguments);
530
455
  }
531
456
  function zrangebyscore(): MethodReturn {
532
- return hasConfig(options, 'zrangebyscore', arguments);
457
+ return fetchData(options, 'zrangebyscore', ...arguments);
533
458
  }
534
459
  function zrank(): MethodReturn {
535
- return hasConfig(options, 'zrank', arguments);
460
+ return fetchData(options, 'zrank', ...arguments);
536
461
  }
537
462
  function zrem(): MethodReturn {
538
- return request(options, undefined, 'zrem', ...arguments);
463
+ return fetchData(options, 'zrem', ...arguments);
539
464
  }
540
465
  function zremrangebylex(): MethodReturn {
541
- return request(options, undefined, 'zremrangebylex', ...arguments);
466
+ return fetchData(options, 'zremrangebylex', ...arguments);
542
467
  }
543
468
  function zremrangebyrank(): MethodReturn {
544
- return request(options, undefined, 'zremrangebyrank', ...arguments);
469
+ return fetchData(options, 'zremrangebyrank', ...arguments);
545
470
  }
546
471
  function zremrangebyscore(): MethodReturn {
547
- return request(options, undefined, 'zremrangebyscore', ...arguments);
472
+ return fetchData(options, 'zremrangebyscore', ...arguments);
548
473
  }
549
474
  function zrevrange(): MethodReturn {
550
- return hasConfig(options, 'zrevrange', arguments);
475
+ return fetchData(options, 'zrevrange', ...arguments);
551
476
  }
552
477
  function zrevrangebylex(): MethodReturn {
553
- return hasConfig(options, 'zrevrangebylex', arguments);
478
+ return fetchData(options, 'zrevrangebylex', ...arguments);
554
479
  }
555
480
  function zrevrangebyscore(): MethodReturn {
556
- return hasConfig(options, 'zrevrangebyscore', arguments);
481
+ return fetchData(options, 'zrevrangebyscore', ...arguments);
557
482
  }
558
483
  function zrevrank(): MethodReturn {
559
- return hasConfig(options, 'zrevrank', arguments);
484
+ return fetchData(options, 'zrevrank', ...arguments);
560
485
  }
561
486
  function zscore(): MethodReturn {
562
- return hasConfig(options, 'zscore', arguments);
487
+ return fetchData(options, 'zscore', ...arguments);
563
488
  }
564
489
  function zunionstore(): MethodReturn {
565
- return request(options, undefined, 'zunionstore', ...arguments);
490
+ return fetchData(options, 'zunionstore', ...arguments);
566
491
  }
567
492
 
568
493
  return {