woonplan-packages-redishelper 1.0.90 → 1.0.91
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/dist/eventsource.d.ts +1 -1
- package/dist/eventsource.js +6 -4
- package/eventsource.ts +4 -4
- package/package.json +1 -1
package/dist/eventsource.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { RedisConfig, RedisStreamEntry } from "./types";
|
|
2
|
-
declare const filterStream: (config: RedisConfig, streamname: string, key: string, value: string) => Promise<RedisStreamEntry[]>;
|
|
2
|
+
declare const filterStream: (config: RedisConfig, streamname: string, key: string, value: string, count?: number) => Promise<RedisStreamEntry[]>;
|
|
3
3
|
export { filterStream };
|
package/dist/eventsource.js
CHANGED
|
@@ -14,8 +14,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
14
14
|
exports.filterStream = void 0;
|
|
15
15
|
var memdb_1 = require("./memdb");
|
|
16
16
|
var getStreamInfo = function (config, streamname, count) { return (0, memdb_1.getRedisClient)(config).xinfo('stream', streamname, 'FULL', 'COUNT', count); };
|
|
17
|
-
var getEntriesFromStream = function (config, streamname) {
|
|
18
|
-
|
|
17
|
+
var getEntriesFromStream = function (config, streamname, count) {
|
|
18
|
+
if (count === void 0) { count = 0; }
|
|
19
|
+
return getStreamInfo(config, streamname, count)
|
|
19
20
|
.then(function (result) {
|
|
20
21
|
var redisStreamResult = getObjectFromStreamResult(result);
|
|
21
22
|
if (!redisStreamResult.entries)
|
|
@@ -34,8 +35,9 @@ var getObjectFromStreamResult = function (arr) { return arr.reduce(function (obj
|
|
|
34
35
|
obj[current] = arr[n + 1];
|
|
35
36
|
return obj;
|
|
36
37
|
}, {}); };
|
|
37
|
-
var filterStream = function (config, streamname, key, value) {
|
|
38
|
-
|
|
38
|
+
var filterStream = function (config, streamname, key, value, count) {
|
|
39
|
+
if (count === void 0) { count = 0; }
|
|
40
|
+
return getEntriesFromStream(config, streamname, count)
|
|
39
41
|
.then(function (entries) { return entries.filter(function (entry) {
|
|
40
42
|
return Object.keys(entry.message).indexOf(key) > -1 && entry.message[key] == value;
|
|
41
43
|
}); });
|
package/eventsource.ts
CHANGED
|
@@ -3,8 +3,8 @@ import { RedisConfig, RedisStreamEntry, RedisMessage } from "./types"
|
|
|
3
3
|
|
|
4
4
|
const getStreamInfo = ( config:RedisConfig, streamname:string, count:number ) => getRedisClient( config ).xinfo('stream', streamname,'FULL', 'COUNT', count )
|
|
5
5
|
|
|
6
|
-
const getEntriesFromStream = ( config:RedisConfig, streamname:string ) =>
|
|
7
|
-
getStreamInfo( config, streamname,
|
|
6
|
+
const getEntriesFromStream = ( config:RedisConfig, streamname:string, count:number = 0 ) =>
|
|
7
|
+
getStreamInfo( config, streamname, count )
|
|
8
8
|
.then(( result:any[] ) => {
|
|
9
9
|
const redisStreamResult = getObjectFromStreamResult( result )
|
|
10
10
|
if( !redisStreamResult.entries ) return []
|
|
@@ -24,8 +24,8 @@ const getObjectFromStreamResult = ( arr:any[] ) => arr.reduce( (obj,current,n:nu
|
|
|
24
24
|
}, {} )
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
const filterStream = ( config:RedisConfig, streamname:string, key:string, value:string ) =>
|
|
28
|
-
getEntriesFromStream( config, streamname )
|
|
27
|
+
const filterStream = ( config:RedisConfig, streamname:string, key:string, value:string, count:number = 0 ) =>
|
|
28
|
+
getEntriesFromStream( config, streamname, count )
|
|
29
29
|
.then((entries:RedisStreamEntry[]) => entries.filter( entry => {
|
|
30
30
|
return Object.keys( entry.message ).indexOf( key ) > -1 && entry.message[key] == value
|
|
31
31
|
}))
|