@upstash/redis 0.1.22 → 0.2.0

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.
Files changed (55) hide show
  1. package/README.md +13 -53
  2. package/dist/main/client.d.ts +21 -0
  3. package/dist/main/client.js +556 -0
  4. package/dist/main/index-cjs.d.ts +1 -0
  5. package/dist/main/index-cjs.js +120 -0
  6. package/dist/main/types.d.ts +177 -0
  7. package/dist/main/{src/type.js → types.js} +0 -1
  8. package/dist/module/client.d.ts +21 -0
  9. package/dist/module/client.js +551 -0
  10. package/dist/module/index.d.ts +3 -0
  11. package/dist/module/index.js +3 -0
  12. package/dist/module/types.d.ts +177 -0
  13. package/dist/module/types.js +1 -0
  14. package/package.json +16 -25
  15. package/src/client.ts +307 -921
  16. package/src/index-cjs.ts +117 -0
  17. package/src/index.ts +4 -119
  18. package/src/types.ts +408 -0
  19. package/tsconfig.json +9 -7
  20. package/tsconfig.module.json +3 -2
  21. package/dist/main/src/client.d.ts +0 -25
  22. package/dist/main/src/client.d.ts.map +0 -1
  23. package/dist/main/src/client.js +0 -748
  24. package/dist/main/src/client.js.map +0 -1
  25. package/dist/main/src/index.d.ts +0 -73
  26. package/dist/main/src/index.d.ts.map +0 -1
  27. package/dist/main/src/index.js +0 -124
  28. package/dist/main/src/index.js.map +0 -1
  29. package/dist/main/src/type.d.ts +0 -466
  30. package/dist/main/src/type.d.ts.map +0 -1
  31. package/dist/main/src/type.js.map +0 -1
  32. package/dist/main/utils/helper.d.ts +0 -5
  33. package/dist/main/utils/helper.d.ts.map +0 -1
  34. package/dist/main/utils/helper.js +0 -20
  35. package/dist/main/utils/helper.js.map +0 -1
  36. package/dist/module/src/client.d.ts +0 -25
  37. package/dist/module/src/client.d.ts.map +0 -1
  38. package/dist/module/src/client.js +0 -743
  39. package/dist/module/src/client.js.map +0 -1
  40. package/dist/module/src/index.d.ts +0 -73
  41. package/dist/module/src/index.d.ts.map +0 -1
  42. package/dist/module/src/index.js +0 -5
  43. package/dist/module/src/index.js.map +0 -1
  44. package/dist/module/src/type.d.ts +0 -466
  45. package/dist/module/src/type.d.ts.map +0 -1
  46. package/dist/module/src/type.js +0 -2
  47. package/dist/module/src/type.js.map +0 -1
  48. package/dist/module/utils/helper.d.ts +0 -5
  49. package/dist/module/utils/helper.d.ts.map +0 -1
  50. package/dist/module/utils/helper.js +0 -13
  51. package/dist/module/utils/helper.js.map +0 -1
  52. package/dist/umd/upstash-redis.js +0 -1
  53. package/src/type.ts +0 -1194
  54. package/utils/helper.ts +0 -17
  55. package/webpack.config.js +0 -34
@@ -1,743 +0,0 @@
1
- import fetch from 'isomorphic-unfetch';
2
- import { isFunction, isObject, isString } from '../utils/helper';
3
- /**
4
- * Creates a Upstash Redis instance
5
- *
6
- * @constructor
7
- * @param {string} url - database rest url
8
- * @param {string} token - database rest token
9
- * @param {Object} options - database config
10
- * @param {string} [options.url] - database rest url
11
- * @param {string} [options.token] - database rest token
12
- * @param {string} [options.edgeUrl] - database rest edge url
13
- * @param {string} [options.readFromEdge] - database rest read from edge
14
- *
15
- * @example
16
- * ```js
17
- * import Upstash from '@upstash/redis'
18
- *
19
- * const redis1 = new Upstash('url', token);
20
- * const redis2 = new Upstash({ url: '', token: '', edgeUrl: '', readFromEdge: false });
21
- * ```
22
- */
23
- export default Upstash;
24
- function Upstash() {
25
- let OPTIONS;
26
- // @ts-ignore
27
- parseOptions(arguments[0], arguments[1]);
28
- /**
29
- * Parse Options
30
- */
31
- function parseOptions() {
32
- const arg0 = arguments[0];
33
- const arg1 = arguments[1];
34
- OPTIONS = { url: '', token: '', edgeUrl: '', readFromEdge: false };
35
- // Upstash({})
36
- if (isObject(arg0)) {
37
- const { url, token, edgeUrl, readFromEdge } = arg0;
38
- OPTIONS.url = url;
39
- OPTIONS.token = token;
40
- OPTIONS.edgeUrl = edgeUrl;
41
- OPTIONS.readFromEdge = readFromEdge !== null && readFromEdge !== void 0 ? readFromEdge : !!edgeUrl;
42
- }
43
- // Upstash(url, token)
44
- else if (isString(arg0) && isString(arg1)) {
45
- OPTIONS.url = arg0;
46
- OPTIONS.token = arg1;
47
- }
48
- // try auto fill from env variable
49
- else if (process) {
50
- const { UPSTASH_REDIS_REST_URL, UPSTASH_REDIS_REST_TOKEN, UPSTASH_REDIS_EDGE_URL, } = process.env;
51
- OPTIONS.url = UPSTASH_REDIS_REST_URL !== null && UPSTASH_REDIS_REST_URL !== void 0 ? UPSTASH_REDIS_REST_URL : '';
52
- OPTIONS.token = UPSTASH_REDIS_REST_TOKEN !== null && UPSTASH_REDIS_REST_TOKEN !== void 0 ? UPSTASH_REDIS_REST_TOKEN : '';
53
- OPTIONS.edgeUrl = UPSTASH_REDIS_EDGE_URL !== null && UPSTASH_REDIS_EDGE_URL !== void 0 ? UPSTASH_REDIS_EDGE_URL : '';
54
- OPTIONS.readFromEdge = !!UPSTASH_REDIS_EDGE_URL;
55
- }
56
- }
57
- /**
58
- * Fetch
59
- */
60
- function fetchData(url, options) {
61
- let cache = null;
62
- let edge = false;
63
- return new Promise((resolve) => {
64
- fetch(url, {
65
- ...options,
66
- headers: {
67
- Authorization: `Bearer ${OPTIONS.token}`,
68
- },
69
- })
70
- .then((res) => {
71
- switch (res.headers.get('x-cache')) {
72
- case 'Hit from cloudfront':
73
- edge = true;
74
- cache = 'hit';
75
- break;
76
- case 'Miss from cloudfront':
77
- edge = true;
78
- cache = 'miss';
79
- break;
80
- }
81
- return res.json().then();
82
- })
83
- .then((data) => {
84
- if (data.error)
85
- throw data.error;
86
- resolve({
87
- data: data.result,
88
- error: null,
89
- metadata: { edge, cache },
90
- });
91
- })
92
- .catch((error) => {
93
- resolve({
94
- data: null,
95
- error: typeof error === 'object' ? error.message : error,
96
- metadata: { edge, cache },
97
- });
98
- });
99
- });
100
- }
101
- /**
102
- * Request
103
- */
104
- function request(configOrCallback, callback, ...parts) {
105
- if (!OPTIONS.url) {
106
- return new Promise((resolve) => resolve({ data: null, error: 'Database url not found?' }));
107
- }
108
- if (!OPTIONS.edgeUrl && OPTIONS.readFromEdge) {
109
- return new Promise((resolve) => resolve({
110
- data: null,
111
- error: 'You need to set Edge Url to read from edge.',
112
- }));
113
- }
114
- let promise;
115
- let isRequestDefaultEdge = !!OPTIONS.edgeUrl && OPTIONS.readFromEdge;
116
- let isRequestCustomEdge = isRequestDefaultEdge;
117
- // write command?
118
- if (configOrCallback === false) {
119
- isRequestCustomEdge = false;
120
- }
121
- // get command
122
- // has config & has edgeUrl
123
- else if (isObject(configOrCallback)) {
124
- // @ts-ignore
125
- if (!OPTIONS.edgeUrl && (configOrCallback === null || configOrCallback === void 0 ? void 0 : configOrCallback.edge)) {
126
- return new Promise((resolve) => resolve({
127
- data: null,
128
- error: 'You need to set Edge Url to read from edge.',
129
- }));
130
- }
131
- if (OPTIONS.edgeUrl) {
132
- // @ts-ignore
133
- isRequestCustomEdge = configOrCallback === null || configOrCallback === void 0 ? void 0 : configOrCallback.edge;
134
- }
135
- }
136
- if (isRequestCustomEdge) {
137
- const command = encodeURI(parts.join('/'));
138
- const edgeUrlWithPath = `${OPTIONS.edgeUrl}/${command}`;
139
- promise = fetchData(edgeUrlWithPath, {
140
- method: 'GET',
141
- });
142
- }
143
- else {
144
- promise = fetchData(OPTIONS.url, {
145
- method: 'POST',
146
- body: JSON.stringify(parts),
147
- });
148
- }
149
- if (isFunction(configOrCallback)) {
150
- // @ts-ignore
151
- return promise.then(configOrCallback);
152
- }
153
- else if (isFunction(callback)) {
154
- return promise.then(callback);
155
- }
156
- return promise;
157
- }
158
- function auth() {
159
- // @ts-ignore
160
- parseOptions(arguments[0], arguments[1]);
161
- }
162
- /**
163
- * STRING
164
- */
165
- function append(key, value) {
166
- return request(false, arguments[2], 'append', key, value);
167
- }
168
- function decr(key) {
169
- return request(false, arguments[1], 'decr', key);
170
- }
171
- function decrby(key, decrement) {
172
- return request(false, arguments[2], 'decrby', key, decrement);
173
- }
174
- function get(key) {
175
- return request(arguments[1], arguments[2], 'get', key);
176
- }
177
- function getrange(key, start, end) {
178
- return request(arguments[3], arguments[4], 'getrange', key, start, end);
179
- }
180
- function getset(key, value) {
181
- return request(false, arguments[2], 'getset', key, value);
182
- }
183
- function incr(key) {
184
- return request(false, arguments[1], 'incr', key);
185
- }
186
- function incrby(key, value) {
187
- return request(false, arguments[2], 'incrby', key, value);
188
- }
189
- function incrbyfloat(key, value) {
190
- return request(false, arguments[2], 'incrbyfloat', key, value);
191
- }
192
- function mget(values) {
193
- return request(arguments[1], arguments[2], 'mget', ...values);
194
- }
195
- function mset(values) {
196
- return request(false, arguments[1], 'mset', ...values);
197
- }
198
- function msetnx(values) {
199
- return request(false, arguments[1], 'msetnx', ...values);
200
- }
201
- function psetex(key, miliseconds, value) {
202
- return request(false, arguments[3], 'psetex', key, miliseconds, value);
203
- }
204
- function set(key, value) {
205
- return request(false, arguments[2], 'set', key, value);
206
- }
207
- function setex(key, seconds, value) {
208
- return request(false, arguments[3], 'setex', key, seconds, value);
209
- }
210
- function setnx(key, value) {
211
- return request(false, arguments[2], 'setnx', key, value);
212
- }
213
- function setrange(key, offset, value) {
214
- return request(false, arguments[3], 'setrange', key, offset, value);
215
- }
216
- function strlen(key) {
217
- return request(arguments[1], arguments[2], 'strlen', key);
218
- }
219
- /**
220
- * BITMAPS
221
- */
222
- function bitcount(key, start, end) {
223
- if (start !== undefined && end !== undefined) {
224
- return request(arguments[3], arguments[4], 'bitcount', key, start, end);
225
- }
226
- return request(arguments[3], arguments[4], 'bitcount', key);
227
- }
228
- function bitop(operation, destinationKey, sourceKeys) {
229
- return request(false, arguments[3], 'bitop', operation, destinationKey, ...sourceKeys);
230
- }
231
- function bitpos(key, bit, start, end) {
232
- if (start !== undefined && end !== undefined) {
233
- return request(arguments[4], arguments[5], 'bitpos', key, bit, start, end);
234
- }
235
- else if (start !== undefined) {
236
- return request(arguments[4], arguments[5], 'bitpos', key, bit, start);
237
- }
238
- return request(arguments[4], arguments[5], 'bitpos', key, bit);
239
- }
240
- function getbit(key, offset) {
241
- return request(arguments[2], arguments[3], 'getbit', key, offset);
242
- }
243
- function setbit(key, offset, value) {
244
- return request(false, arguments[3], 'setbit', key, offset, value);
245
- }
246
- /**
247
- * CONNECTION
248
- */
249
- function echo(value) {
250
- return request(arguments[1], arguments[2], 'echo', value);
251
- }
252
- function ping(value) {
253
- if (value) {
254
- return request(arguments[1], arguments[2], 'ping', value);
255
- }
256
- return request(arguments[1], arguments[2], 'ping');
257
- }
258
- /**
259
- * HASHES
260
- */
261
- function hdel(key, fields) {
262
- return request(false, arguments[2], 'hdel', key, ...fields);
263
- }
264
- function hexists(key, field) {
265
- return request(arguments[2], arguments[3], 'hexists', key, field);
266
- }
267
- function hget(key, field) {
268
- return request(arguments[2], arguments[3], 'hget', key, field);
269
- }
270
- function hgetall(key) {
271
- return request(arguments[1], arguments[2], 'hgetall', key);
272
- }
273
- function hincrby(key, field, increment) {
274
- return request(false, arguments[3], 'hincrby', key, field, increment);
275
- }
276
- function hincrbyfloat(key, field, increment) {
277
- return request(false, arguments[3], 'hincrbyfloat', key, field, increment);
278
- }
279
- function hkeys(key) {
280
- return request(arguments[1], arguments[2], 'hkeys', key);
281
- }
282
- function hlen(key) {
283
- return request(arguments[1], arguments[2], 'hlen', key);
284
- }
285
- function hmget(key, fields) {
286
- return request(arguments[2], arguments[3], 'hmget', key, ...fields);
287
- }
288
- function hmset(key, values) {
289
- return request(false, arguments[2], 'hmset', key, ...values);
290
- }
291
- function hscan(key, cursor, options) {
292
- if ((options === null || options === void 0 ? void 0 : options.match) && (options === null || options === void 0 ? void 0 : options.count)) {
293
- return request(false, arguments[3], 'hscan', key, cursor, 'match', options.match, 'count', options.count);
294
- }
295
- else if (options === null || options === void 0 ? void 0 : options.match) {
296
- return request(false, arguments[3], 'hscan', key, cursor, 'match', options.match);
297
- }
298
- else if (options === null || options === void 0 ? void 0 : options.count) {
299
- return request(false, arguments[3], 'hscan', key, cursor, 'count', options.count);
300
- }
301
- return request(false, arguments[3], 'hscan', key, cursor);
302
- }
303
- function hset(key, values) {
304
- return request(false, arguments[2], 'hset', key, ...values);
305
- }
306
- function hsetnx(key, field, value) {
307
- return request(false, arguments[3], 'hsetnx', key, field, value);
308
- }
309
- function hvals(key) {
310
- return request(arguments[1], arguments[2], 'hvals', key);
311
- }
312
- /**
313
- * KEYS
314
- */
315
- function del(keys) {
316
- return request(false, arguments[1], 'del', ...keys);
317
- }
318
- function exists(keys) {
319
- return request(arguments[1], arguments[2], 'exists', ...keys);
320
- }
321
- function expire(key, seconds) {
322
- return request(false, arguments[2], 'expire', key, seconds);
323
- }
324
- function expireat(key, timestamp) {
325
- return request(false, arguments[2], 'expireat', key, timestamp);
326
- }
327
- function keys(pattern) {
328
- return request(arguments[1], arguments[2], 'keys', pattern);
329
- }
330
- function persist(key) {
331
- return request(false, arguments[1], 'persist', key);
332
- }
333
- function pexpire(key, miliseconds) {
334
- return request(false, arguments[2], 'pexpire', key, miliseconds);
335
- }
336
- function pexpireat(key, miliseconds) {
337
- return request(false, arguments[2], 'pexpireat', key, miliseconds);
338
- }
339
- function pttl(key) {
340
- return request(arguments[1], arguments[2], 'pttl', key);
341
- }
342
- function randomkey() {
343
- return request(false, arguments[0], 'randomkey');
344
- }
345
- function rename(key, newKey) {
346
- return request(false, arguments[2], 'rename', key, newKey);
347
- }
348
- function renamenx(key, newKey) {
349
- return request(false, arguments[2], 'renamenx', key, newKey);
350
- }
351
- function scan(cursor, opitons) {
352
- if ((opitons === null || opitons === void 0 ? void 0 : opitons.match) && (opitons === null || opitons === void 0 ? void 0 : opitons.count)) {
353
- return request(false, arguments[2], 'scan', cursor, 'match', opitons.match, 'count', opitons.count);
354
- }
355
- else if (opitons === null || opitons === void 0 ? void 0 : opitons.match) {
356
- return request(false, arguments[2], 'scan', cursor, 'match', opitons.match);
357
- }
358
- else if (opitons === null || opitons === void 0 ? void 0 : opitons.count) {
359
- return request(false, arguments[2], 'scan', cursor, 'count', opitons.count);
360
- }
361
- return request(false, arguments[2], 'scan', cursor);
362
- }
363
- function touch(keys) {
364
- return request(false, arguments[1], 'touch', ...keys);
365
- }
366
- function ttl(key) {
367
- return request(arguments[1], arguments[2], 'ttl', key);
368
- }
369
- function type(key) {
370
- return request(arguments[1], arguments[2], 'type', key);
371
- }
372
- function unlink(keys) {
373
- return request(false, arguments[1], 'unlink', ...keys);
374
- }
375
- /**
376
- * LISTS
377
- */
378
- function lindex(key, index) {
379
- return request(arguments[2], arguments[3], 'lindex', key, index);
380
- }
381
- function linsert(key, option, pivot, element) {
382
- return request(false, arguments[4], 'linsert', key, option, pivot, element);
383
- }
384
- function llen(key) {
385
- return request(arguments[1], arguments[2], 'llen', key);
386
- }
387
- function lpop(key) {
388
- return request(false, arguments[1], 'lpop', key);
389
- }
390
- function lpush(key, elements) {
391
- return request(false, arguments[2], 'lpush', key, ...elements);
392
- }
393
- function lpushx(key, elements) {
394
- return request(false, arguments[2], 'lpushx', key, ...elements);
395
- }
396
- function lrange(key, start, stop) {
397
- return request(arguments[3], arguments[4], 'lrange', key, start, stop);
398
- }
399
- function lrem(key, count, element) {
400
- return request(false, arguments[3], 'lrem', key, count, element);
401
- }
402
- function lset(key, index, element) {
403
- return request(false, arguments[3], 'lset', key, index, element);
404
- }
405
- function ltrim(key, start, stop) {
406
- return request(false, arguments[3], 'ltrim', key, start, stop);
407
- }
408
- function rpop(key) {
409
- return request(false, arguments[1], 'rpop', key);
410
- }
411
- function rpoplpush(source, destination) {
412
- return request(false, arguments[2], 'rpoplpush', source, destination);
413
- }
414
- function rpush(key, elements) {
415
- return request(false, arguments[2], 'rpush', key, ...elements);
416
- }
417
- function rpushx(key, elements) {
418
- return request(false, arguments[2], 'rpushx', key, ...elements);
419
- }
420
- /**
421
- * SERVER
422
- */
423
- function dbsize() {
424
- return request(arguments[0], arguments[1], 'dbsize');
425
- }
426
- function flushall(mode) {
427
- if (mode) {
428
- return request(false, arguments[1], 'flushall', mode);
429
- }
430
- return request(false, arguments[1], 'flushall');
431
- }
432
- function flushdb(mode) {
433
- if (mode) {
434
- return request(false, arguments[1], 'flushdb', mode);
435
- }
436
- return request(false, arguments[1], 'flushdb');
437
- }
438
- function info() {
439
- return request(arguments[0], arguments[1], 'info');
440
- }
441
- function time() {
442
- return request(false, arguments[0], 'time');
443
- }
444
- /**
445
- * SET
446
- */
447
- function sadd(key, members) {
448
- return request(false, arguments[2], 'sadd', key, ...members);
449
- }
450
- function scard(key) {
451
- return request(false, arguments[1], 'scard', key);
452
- }
453
- function sdiff(keys) {
454
- return request(arguments[1], arguments[2], 'sdiff', ...keys);
455
- }
456
- function sdiffstore(destination, keys) {
457
- return request(false, arguments[2], 'sdiffstore', destination, ...keys);
458
- }
459
- function sinter(keys) {
460
- return request(arguments[1], arguments[2], 'sinter', ...keys);
461
- }
462
- function sinterstore(destination, keys) {
463
- return request(false, arguments[2], 'sinterstore', destination, ...keys);
464
- }
465
- function sismember(key, member) {
466
- return request(arguments[2], arguments[3], 'sismember', key, member);
467
- }
468
- function smembers(key) {
469
- return request(arguments[1], arguments[2], 'smembers', key);
470
- }
471
- function smove(source, destination, member) {
472
- return request(false, arguments[3], 'smove', source, destination, member);
473
- }
474
- function spop(key, count) {
475
- if (count) {
476
- return request(false, arguments[2], 'spop', key, count);
477
- }
478
- return request(false, arguments[2], 'spop', key);
479
- }
480
- function srandmember(key, count) {
481
- if (count) {
482
- return request(arguments[2], arguments[3], 'srandmember', key, count);
483
- }
484
- return request(arguments[2], arguments[3], 'srandmember', key);
485
- }
486
- function srem(key, members) {
487
- return request(false, arguments[2], 'srem', key, ...members);
488
- }
489
- function sunion(keys) {
490
- return request(arguments[1], arguments[2], 'sunion', ...keys);
491
- }
492
- function sunionstore(destination, keys) {
493
- return request(false, arguments[2], 'sunionstore', destination, ...keys);
494
- }
495
- /**
496
- * SORTED SETS
497
- */
498
- function zadd(key, values, options) {
499
- if (options) {
500
- const allOptions = Object.entries(options)
501
- .filter((e) => ['string', 'number', 'boolean'].includes(typeof e[1]))
502
- .map((e) => e[0].toUpperCase());
503
- return request(false, arguments[3], 'zadd', key, ...allOptions, ...values);
504
- }
505
- return request(arguments[3], arguments[4], 'zadd', key, ...values);
506
- }
507
- function zcard(key) {
508
- return request(arguments[1], arguments[2], 'zcard', key);
509
- }
510
- function zcount(key, min, max) {
511
- return request(arguments[3], arguments[4], 'zcount', key, min, max);
512
- }
513
- function zincrby(key, increment, member) {
514
- return request(false, arguments[3], 'zincrby', key, increment, member);
515
- }
516
- function zinterstore(destination, keys, options) {
517
- if (options) {
518
- if (options.weights && options.aggregate) {
519
- return request(false, arguments[3], 'zinterstore', destination, keys.length, ...keys, 'weights', ...options.weights, 'aggregate', options.aggregate);
520
- }
521
- else if (options.weights) {
522
- return request(false, arguments[3], 'zinterstore', destination, keys.length, ...keys, 'weights', ...options.weights);
523
- }
524
- else if (options.aggregate) {
525
- return request(false, arguments[3], 'zinterstore', destination, keys.length, ...keys, 'aggregate', options.aggregate);
526
- }
527
- }
528
- return request(false, arguments[3], 'zinterstore', destination, keys.length, ...keys);
529
- }
530
- function zlexcount(key, min, max) {
531
- return request(arguments[3], arguments[4], 'zlexcount', key, min, max);
532
- }
533
- function zpopmax(key, count) {
534
- if (count) {
535
- return request(false, arguments[2], 'zpopmax', key, count);
536
- }
537
- return request(false, arguments[2], 'zpopmax', key);
538
- }
539
- function zpopmin(key, count) {
540
- if (count) {
541
- return request(false, arguments[2], 'zpopmin', key, count);
542
- }
543
- return request(false, arguments[2], 'zpopmin', key);
544
- }
545
- function zrange(key, min, max, options) {
546
- if (options === null || options === void 0 ? void 0 : options.withScores) {
547
- return request(arguments[4], arguments[5], 'zrange', key, min, max, 'WITHSCORES');
548
- }
549
- return request(arguments[4], arguments[5], 'zrange', key, min, max);
550
- }
551
- function zrangebylex(key, min, max, offset, count) {
552
- if (offset && count) {
553
- return request(arguments[5], arguments[6], 'zrangebylex', key, min, max, 'LIMIT', offset, count);
554
- }
555
- return request(arguments[5], arguments[6], 'zrangebylex', key, min, max);
556
- }
557
- function zrangebyscore(key, min, max, options) {
558
- if ((options === null || options === void 0 ? void 0 : options.withScores) && (options === null || options === void 0 ? void 0 : options.limit)) {
559
- return request(arguments[4], arguments[5], 'zrangebyscore', key, min, max, 'WITHSCORES', 'LIMIT', options.limit.offset, options.limit.count);
560
- }
561
- else if (options === null || options === void 0 ? void 0 : options.withScores) {
562
- return request(arguments[4], arguments[5], 'zrangebyscore', key, min, max, 'WITHSCORES');
563
- }
564
- else if (options === null || options === void 0 ? void 0 : options.limit) {
565
- return request(arguments[4], arguments[5], 'zrangebyscore', key, min, max, 'LIMIT', options.limit.offset, options.limit.count);
566
- }
567
- return request(arguments[4], arguments[5], 'zrangebyscore', key, min, max);
568
- }
569
- function zrank(key, member) {
570
- return request(arguments[2], arguments[3], 'zrank', key, member);
571
- }
572
- function zrem(key, members) {
573
- return request(false, arguments[2], 'zrem', key, ...members);
574
- }
575
- function zremrangebylex(key, min, max) {
576
- return request(false, arguments[3], 'zremrangebylex', key, min, max);
577
- }
578
- function zremrangebyrank(key, start, stop) {
579
- return request(false, arguments[3], 'zremrangebyrank', key, start, stop);
580
- }
581
- function zremrangebyscore(key, min, max) {
582
- return request(false, arguments[3], 'zremrangebyscore', key, min, max);
583
- }
584
- function zrevrange(key, start, stop, options) {
585
- if (options === null || options === void 0 ? void 0 : options.withScores) {
586
- return request(arguments[4], arguments[5], 'zrevrange', key, start, stop, 'WITHSCORES');
587
- }
588
- return request(arguments[4], arguments[5], 'zrevrange', key, start, stop);
589
- }
590
- function zrevrangebylex(key, max, min, offset, count) {
591
- if (offset && count) {
592
- return request(arguments[5], arguments[6], 'zrevrangebylex', key, max, min, 'LIMIT', offset, count);
593
- }
594
- return request(arguments[5], arguments[6], 'zrevrangebylex', key, max, min);
595
- }
596
- function zrevrangebyscore(key, min, max) {
597
- return request(arguments[3], arguments[4], 'zrevrangebyscore', key, min, max);
598
- }
599
- function zrevrank(key, member) {
600
- return request(arguments[2], arguments[3], 'zrevrank', key, member);
601
- }
602
- function zscore(key, member) {
603
- return request(arguments[2], arguments[3], 'zscore', key, member);
604
- }
605
- function zunionstore(destination, keys, options) {
606
- if (options) {
607
- if (options.weights && options.aggregate) {
608
- return request(false, arguments[3], 'zunionstore', destination, keys.length, ...keys, 'weights', ...options.weights, 'aggregate', options.aggregate);
609
- }
610
- else if (options.weights) {
611
- return request(false, arguments[3], 'zunionstore', destination, keys.length, ...keys, 'weights', ...options.weights);
612
- }
613
- else if (options.aggregate) {
614
- return request(false, arguments[3], 'zunionstore', destination, keys.length, ...keys, 'aggregate', options.aggregate);
615
- }
616
- }
617
- return request(false, arguments[3], 'zunionstore', destination, keys.length, ...keys);
618
- }
619
- return {
620
- auth,
621
- // STRING
622
- append,
623
- decr,
624
- decrby,
625
- get,
626
- getrange,
627
- getset,
628
- incr,
629
- incrby,
630
- incrbyfloat,
631
- mget,
632
- mset,
633
- msetnx,
634
- psetex,
635
- set,
636
- setex,
637
- setnx,
638
- setrange,
639
- strlen,
640
- // BITMAPS
641
- bitcount,
642
- bitop,
643
- bitpos,
644
- getbit,
645
- setbit,
646
- // CONNECTION
647
- echo,
648
- ping,
649
- // HASHES
650
- hdel,
651
- hexists,
652
- hget,
653
- hgetall,
654
- hincrby,
655
- hincrbyfloat,
656
- hkeys,
657
- hlen,
658
- hmget,
659
- hmset,
660
- hscan,
661
- hset,
662
- hsetnx,
663
- hvals,
664
- // KEYS
665
- del,
666
- exists,
667
- expire,
668
- expireat,
669
- keys,
670
- persist,
671
- pexpire,
672
- pexpireat,
673
- pttl,
674
- randomkey,
675
- rename,
676
- renamenx,
677
- scan,
678
- touch,
679
- ttl,
680
- type,
681
- unlink,
682
- // LISTS
683
- lindex,
684
- linsert,
685
- llen,
686
- lpop,
687
- lpush,
688
- lpushx,
689
- lrange,
690
- lrem,
691
- lset,
692
- ltrim,
693
- rpop,
694
- rpoplpush,
695
- rpush,
696
- rpushx,
697
- // SERVER
698
- dbsize,
699
- flushall,
700
- flushdb,
701
- info,
702
- time,
703
- // SET
704
- sadd,
705
- scard,
706
- sdiff,
707
- sdiffstore,
708
- sinter,
709
- sinterstore,
710
- sismember,
711
- smembers,
712
- smove,
713
- spop,
714
- srandmember,
715
- srem,
716
- sunion,
717
- sunionstore,
718
- // SORTED SETS
719
- zadd,
720
- zcard,
721
- zcount,
722
- zincrby,
723
- zinterstore,
724
- zlexcount,
725
- zpopmax,
726
- zpopmin,
727
- zrange,
728
- zrangebylex,
729
- zrangebyscore,
730
- zrank,
731
- zrem,
732
- zremrangebylex,
733
- zremrangebyrank,
734
- zremrangebyscore,
735
- zrevrange,
736
- zrevrangebylex,
737
- zrevrangebyscore,
738
- zrevrank,
739
- zscore,
740
- zunionstore,
741
- };
742
- }
743
- //# sourceMappingURL=client.js.map