woonplan-packages-redishelper 1.0.12 → 1.0.16

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.
File without changes
@@ -0,0 +1,3 @@
1
+ import { Redis } from "ioredis";
2
+ declare const listenToStream: (client: Redis, groupname: string, channelname: string, consumername: string, callback: Function) => void;
3
+ export { listenToStream };
package/dist/index.js ADDED
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.listenToStream = void 0;
4
+ var listenToStream = function (client, groupname, channelname, consumername, callback) {
5
+ client.xgroup('CREATE', channelname, groupname, '$', 'MKSTREAM').catch(function (error) {
6
+ console.log('halloo');
7
+ console.log(typeof error);
8
+ console.log(error);
9
+ });
10
+ };
11
+ exports.listenToStream = listenToStream;
12
+ var listenForMessage = function (client, groupname, channelname, consumername, lastId) {
13
+ if (lastId === void 0) { lastId = "$"; }
14
+ client.xreadgroup('GROUP', groupname, consumername, 'COUNT', 1, 'BLOCK', 0, 'STREAMS', channelname, '>')
15
+ .then(function () {
16
+ console.log(1);
17
+ })
18
+ .catch(function (error) {
19
+ console.log(error);
20
+ });
21
+ };
package/index.ts ADDED
@@ -0,0 +1,24 @@
1
+ import { Redis } from "ioredis"
2
+
3
+ const listenToStream = ( client:Redis, groupname:string, channelname:string, consumername:string, callback:Function ) => {
4
+ client.xgroup('CREATE', channelname, groupname, '$', 'MKSTREAM' ).catch(
5
+ ( error ) => {
6
+ console.log( 'halloo');
7
+ console.log( typeof error );
8
+ console.log( error );
9
+ }
10
+ )
11
+ }
12
+
13
+ const listenForMessage = ( client:Redis, groupname:string, channelname:string, consumername:string, lastId = "$" ) => {
14
+ client.xreadgroup('GROUP', groupname, consumername, 'COUNT', 1, 'BLOCK', 0, 'STREAMS', channelname, '>')
15
+ .then( () => {
16
+ console.log( 1 );
17
+ } )
18
+ .catch( ( error ) => {
19
+
20
+ console.log( error );
21
+ })
22
+ }
23
+
24
+ export { listenToStream }
package/package.json CHANGED
@@ -1,15 +1,20 @@
1
1
  {
2
2
  "name": "woonplan-packages-redishelper",
3
- "version": "1.0.12",
4
- "description": "helper function for redis",
5
- "main": "index.js",
3
+ "version": "1.0.16",
4
+ "description": "",
5
+ "main": "dist/index.js",
6
+ "types": "dist/types.d.ts",
6
7
  "scripts": {
8
+ "prepublish": "npm run build",
9
+ "build": "tsc",
7
10
  "test": "echo \"Error: no test specified\" && exit 1"
8
11
  },
9
- "repository": {
10
- "type": "git",
11
- "url": "woonplan-packages-redishelper"
12
- },
12
+ "keywords": [],
13
13
  "author": "Jasper Denk",
14
- "license": "ISC"
14
+ "license": "ISC",
15
+ "devDependencies": {
16
+ "@types/ioredis": "^4.28.4",
17
+ "@types/node": "^16.11.13",
18
+ "typescript": "^4.2.3"
19
+ }
15
20
  }
package/tsconfig.json ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es5",
4
+ "module": "commonjs",
5
+ "declaration": true,
6
+ "outDir": "./dist",
7
+ "strict": true
8
+ }
9
+ }
package/types.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ interface test{
2
+ test : boolean
3
+ }