woonplan-packages-redishelper 1.0.91 → 1.0.94

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.
@@ -10,10 +10,60 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
+ return new (P || (P = Promise))(function (resolve, reject) {
16
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
20
+ });
21
+ };
22
+ var __generator = (this && this.__generator) || function (thisArg, body) {
23
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
+ function verb(n) { return function (v) { return step([n, v]); }; }
26
+ function step(op) {
27
+ if (f) throw new TypeError("Generator is already executing.");
28
+ while (_) try {
29
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
+ if (y = 0, t) op = [op[0] & 2, t.value];
31
+ switch (op[0]) {
32
+ case 0: case 1: t = op; break;
33
+ case 4: _.label++; return { value: op[1], done: false };
34
+ case 5: _.label++; y = op[1]; op = [0]; continue;
35
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
+ default:
37
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
+ if (t[2]) _.ops.pop();
42
+ _.trys.pop(); continue;
43
+ }
44
+ op = body.call(thisArg, _);
45
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
+ }
48
+ };
13
49
  Object.defineProperty(exports, "__esModule", { value: true });
14
50
  exports.filterStream = void 0;
15
51
  var memdb_1 = require("./memdb");
16
- var getStreamInfo = function (config, streamname, count) { return (0, memdb_1.getRedisClient)(config).xinfo('stream', streamname, 'FULL', 'COUNT', count); };
52
+ var getStreamInfo = function (config, streamname, count) { return __awaiter(void 0, void 0, void 0, function () {
53
+ var _a;
54
+ return __generator(this, function (_b) {
55
+ switch (_b.label) {
56
+ case 0:
57
+ _b.trys.push([0, 2, , 3]);
58
+ return [4 /*yield*/, (0, memdb_1.getRedisClient)(config).xinfo('stream', streamname, 'FULL', 'COUNT', count)];
59
+ case 1: return [2 /*return*/, _b.sent()];
60
+ case 2:
61
+ _a = _b.sent();
62
+ return [2 /*return*/, []];
63
+ case 3: return [2 /*return*/];
64
+ }
65
+ });
66
+ }); };
17
67
  var getEntriesFromStream = function (config, streamname, count) {
18
68
  if (count === void 0) { count = 0; }
19
69
  return getStreamInfo(config, streamname, count)
package/eventsource.ts CHANGED
@@ -1,7 +1,13 @@
1
1
  import { getRedisClient } from "./memdb"
2
2
  import { RedisConfig, RedisStreamEntry, RedisMessage } from "./types"
3
3
 
4
- const getStreamInfo = ( config:RedisConfig, streamname:string, count:number ) => getRedisClient( config ).xinfo('stream', streamname,'FULL', 'COUNT', count )
4
+ const getStreamInfo = async ( config:RedisConfig, streamname:string, count:number ) => {
5
+ try{
6
+ return await getRedisClient( config ).xinfo('stream', streamname,'FULL', 'COUNT', count )
7
+ }catch{
8
+ return []
9
+ }
10
+ }
5
11
 
6
12
  const getEntriesFromStream = ( config:RedisConfig, streamname:string, count:number = 0 ) =>
7
13
  getStreamInfo( config, streamname, count )
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "woonplan-packages-redishelper",
3
- "version": "1.0.91",
3
+ "version": "1.0.94",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -13,14 +13,13 @@
13
13
  "author": "Jasper Denk",
14
14
  "license": "ISC",
15
15
  "devDependencies": {
16
- "@types/ioredis": "^4.28.4",
17
16
  "@types/node": "^16.11.13",
18
17
  "@types/uuid": "^8.3.4",
19
18
  "typescript": "^4.2.3"
20
19
  },
21
20
  "dependencies": {
22
- "@types/ioredis": "^4.28.5",
23
- "ioredis": "^4.28.2",
21
+ "@types/ioredis": "4.28.10",
22
+ "ioredis": "^5.0.4",
24
23
  "uuid": "^8.3.2"
25
24
  }
26
25
  }