@only-chat/in-memory-queue 0.2.0-beta.10

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/README.md ADDED
@@ -0,0 +1,2 @@
1
+ # only-chat
2
+ This is an in-memory queue implementation for only-chat.
@@ -0,0 +1,2 @@
1
+ import type { MessageQueue } from '@only-chat/types/queue.js';
2
+ export declare function initialize(): Promise<MessageQueue>;
package/dist/index.js ADDED
@@ -0,0 +1,24 @@
1
+ const acceptTypes = ['connected', 'disconnected', 'joined', 'left', 'closed', 'deleted', 'updated', 'message-updated', 'message-deleted', 'text', 'file'];
2
+ export async function initialize() {
3
+ const subscribers = [];
4
+ return {
5
+ async publish(msg) {
6
+ if (!acceptTypes.includes(msg.type)) {
7
+ return false;
8
+ }
9
+ subscribers.forEach(s => s(msg));
10
+ return true;
11
+ },
12
+ async subscribe(callback) {
13
+ return !!subscribers.push(callback);
14
+ },
15
+ async unsubscribe(callback) {
16
+ const index = subscribers.lastIndexOf(callback);
17
+ if (index < 0) {
18
+ return false;
19
+ }
20
+ return !!subscribers.splice(index, 1);
21
+ },
22
+ };
23
+ }
24
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,GAAkB,CAAC,WAAW,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAEzK,MAAM,CAAC,KAAK,UAAU,UAAU;IAC5B,MAAM,WAAW,GAAwC,EAAE,CAAC;IAE5D,OAAO;QACH,KAAK,CAAC,OAAO,CAAC,GAAG;YACb,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;gBAClC,OAAO,KAAK,CAAC;YACjB,CAAC;YAED,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YACjC,OAAO,IAAI,CAAC;QAChB,CAAC;QAED,KAAK,CAAC,SAAS,CAAC,QAAQ;YACpB,OAAO,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACxC,CAAC;QAED,KAAK,CAAC,WAAW,CAAC,QAAQ;YACtB,MAAM,KAAK,GAAG,WAAW,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;YAChD,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;gBACZ,OAAO,KAAK,CAAC;YACjB,CAAC;YAED,OAAO,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAC1C,CAAC;KACJ,CAAC;AACN,CAAC"}
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@only-chat/in-memory-queue",
3
+ "version": "0.2.0-beta.10",
4
+ "description": "In memory queue for only-chat",
5
+ "homepage": "https://github.com/only-chat/node-backend/packages/queues/memory",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "type": "module",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/only-chat/node-backend.git",
12
+ "directory": "packages/queues/memory"
13
+ },
14
+ "scripts": {
15
+ "build": "tsc"
16
+ },
17
+ "author": "only-chat",
18
+ "license": "MIT",
19
+ "devDependencies": {
20
+ "@only-chat/types": "0.2.0-beta.10",
21
+ "typescript": "^5.4.5"
22
+ },
23
+ "files": [
24
+ "dist/"
25
+ ],
26
+ "keywords": [
27
+ "node",
28
+ "only-chat",
29
+ "queues"
30
+ ]
31
+ }