New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@aurox/distributed-observables

Package Overview
Dependencies
Maintainers
3
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aurox/distributed-observables - npm Package Compare versions

Comparing version 0.0.11 to 0.1.1

2

dist/CommunicationBackbone/index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
(0, tslib_1.__exportStar)(require("./CommunicationBackbone"), exports);
tslib_1.__exportStar(require("./CommunicationBackbone"), exports);
//# sourceMappingURL=index.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
(0, tslib_1.__exportStar)(require("./CommunicationManager"), exports);
tslib_1.__exportStar(require("./CommunicationManager"), exports);
//# sourceMappingURL=index.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
(0, tslib_1.__exportStar)(require("./MemoryChannelClient"), exports);
tslib_1.__exportStar(require("./MemoryChannelClient"), exports);
//# sourceMappingURL=index.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
(0, tslib_1.__exportStar)(require("./types"), exports);
(0, tslib_1.__exportStar)(require("./helpers"), exports);
(0, tslib_1.__exportStar)(require("./utils"), exports);
(0, tslib_1.__exportStar)(require("./Observable"), exports);
(0, tslib_1.__exportStar)(require("./ObservableManager"), exports);
(0, tslib_1.__exportStar)(require("./CommunicationManager"), exports);
(0, tslib_1.__exportStar)(require("./CommunicationBackbone"), exports);
tslib_1.__exportStar(require("./types"), exports);
tslib_1.__exportStar(require("./helpers"), exports);
tslib_1.__exportStar(require("./utils"), exports);
tslib_1.__exportStar(require("./Observable"), exports);
tslib_1.__exportStar(require("./ObservableManager"), exports);
tslib_1.__exportStar(require("./CommunicationManager"), exports);
tslib_1.__exportStar(require("./CommunicationBackbone"), exports);
//# sourceMappingURL=index.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
(0, tslib_1.__exportStar)(require("./Observable"), exports);
tslib_1.__exportStar(require("./Observable"), exports);
//# sourceMappingURL=index.js.map

@@ -15,4 +15,4 @@ import { TypedEmitter } from 'tiny-typed-emitter';

export interface ObservableOptions {
persistDebounceTimeout: number;
persistRetryTimeout: number;
persistDebounceWaitMs: number;
persistRetryDelayMs: number;
displayName: string;

@@ -55,3 +55,3 @@ }

applyDelete(): void;
detach(): void;
detach(): Promise<void>;
}

@@ -7,3 +7,3 @@ "use strict";

const tiny_typed_emitter_1 = require("tiny-typed-emitter");
const debounce_1 = (0, tslib_1.__importDefault)(require("lodash/debounce"));
const debounce_1 = tslib_1.__importDefault(require("lodash/debounce"));
class Observable extends tiny_typed_emitter_1.TypedEmitter {

@@ -82,5 +82,5 @@ constructor(adapter, topic, options) {

this._displayName = options.displayName;
this._retryTimeout = options.persistRetryTimeout;
this._retryTimeout = options.persistRetryDelayMs;
// Make sure we never wait for more than 4 times the debounce to minimize the probability of data loss
this._debouncedPersist = (0, debounce_1.default)(this.persist, options.persistDebounceTimeout, { maxWait: options.persistDebounceTimeout * 4 });
this._debouncedPersist = (0, debounce_1.default)(this.persist, options.persistDebounceWaitMs, { maxWait: options.persistDebounceWaitMs * 4 });
}

@@ -233,5 +233,5 @@ get topic() {

}
detach() {
this._debouncedPersist.flush();
async detach() {
clearTimeout(this._persistRetryTimer);
await this._debouncedPersist.flush();
this._adaptor.cleanup();

@@ -238,0 +238,0 @@ this.emit('detached');

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
(0, tslib_1.__exportStar)(require("./ObservableManager"), exports);
tslib_1.__exportStar(require("./ObservableManager"), exports);
//# sourceMappingURL=index.js.map

@@ -5,4 +5,4 @@ import { Patch } from 'immer';

export interface ObservableManagerOptions {
defaultPersistDebounceTimeout: number;
defaultPersistRetryTimeout: number;
defaultPersistDebounceWaitMs: number;
defaultPersistRetryDelayMs: number;
}

@@ -9,0 +9,0 @@ export interface ObservableManagerAdaptor {

@@ -67,4 +67,4 @@ "use strict";

observer = new Observable_1.Observable(adaptor, topic, {
persistDebounceTimeout: (_a = options === null || options === void 0 ? void 0 : options.persistDebounceTimeout) !== null && _a !== void 0 ? _a : this._options.defaultPersistDebounceTimeout,
persistRetryTimeout: (_b = options === null || options === void 0 ? void 0 : options.persistRetryTimeout) !== null && _b !== void 0 ? _b : this._options.defaultPersistRetryTimeout,
persistDebounceWaitMs: (_a = options === null || options === void 0 ? void 0 : options.persistDebounceWaitMs) !== null && _a !== void 0 ? _a : this._options.defaultPersistDebounceWaitMs,
persistRetryDelayMs: (_b = options === null || options === void 0 ? void 0 : options.persistRetryDelayMs) !== null && _b !== void 0 ? _b : this._options.defaultPersistRetryDelayMs,
displayName: (_c = options === null || options === void 0 ? void 0 : options.displayName) !== null && _c !== void 0 ? _c : topic,

@@ -71,0 +71,0 @@ });

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
(0, tslib_1.__exportStar)(require("./common"), exports);
(0, tslib_1.__exportStar)(require("./payloads"), exports);
(0, tslib_1.__exportStar)(require("./ChannelClient"), exports);
(0, tslib_1.__exportStar)(require("./CommunicationServer"), exports);
(0, tslib_1.__exportStar)(require("./CommunicationPublisher"), exports);
(0, tslib_1.__exportStar)(require("./CommunicationSubscriber"), exports);
(0, tslib_1.__exportStar)(require("./StorageAdaptor"), exports);
tslib_1.__exportStar(require("./common"), exports);
tslib_1.__exportStar(require("./payloads"), exports);
tslib_1.__exportStar(require("./ChannelClient"), exports);
tslib_1.__exportStar(require("./CommunicationServer"), exports);
tslib_1.__exportStar(require("./CommunicationPublisher"), exports);
tslib_1.__exportStar(require("./CommunicationSubscriber"), exports);
tslib_1.__exportStar(require("./StorageAdaptor"), exports);
//# sourceMappingURL=index.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
(0, tslib_1.__exportStar)(require("./patching"), exports);
tslib_1.__exportStar(require("./patching"), exports);
//# sourceMappingURL=index.js.map
{
"name": "@aurox/distributed-observables",
"version": "0.0.11",
"version": "0.1.1",
"description": "A set of isomorphic helpers to enable distributed object sharing using the observer pattern",

@@ -22,4 +22,4 @@ "main": "dist/index.js",

"dependencies": {
"@types/lodash": "^4.14.179",
"@types/node": "^17.0.8",
"@types/lodash": "^4.14.180",
"@types/node": "^17.0.23",
"@types/uuid": "^8.3.4",

@@ -34,19 +34,17 @@ "immer": "^9.0.12",

"@aurox/ws": "^0.0.2",
"@types/ioredis": "^4.28.7",
"@types/ioredis-mock": "^5.6.0",
"@types/jest": "^27.4.0",
"@typescript-eslint/eslint-plugin": "^5.9.1",
"@typescript-eslint/parser": "^5.9.1",
"eslint": "^8.6.0",
"eslint-config-prettier": "^8.3.0",
"@types/jest": "^27.4.1",
"@typescript-eslint/eslint-plugin": "^5.16.0",
"@typescript-eslint/parser": "^5.16.0",
"eslint": "^8.12.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.0.0",
"ioredis": "^4.28.3",
"ioredis-mock": "^5.9.0",
"jest": "^27.4.7",
"prettier": "^2.5.1",
"ioredis": "^5.0.1",
"ioredis-mock": "^7.2.0",
"jest": "^27.5.1",
"prettier": "^2.6.1",
"rimraf": "^3.0.2",
"ts-jest": "^27.1.3",
"ts-node": "^10.4.0",
"typescript": "^4.5.5"
"ts-jest": "^27.1.4",
"ts-node": "^10.7.0",
"typescript": "^4.6.3"
}
}
import { TypedEmitter } from 'tiny-typed-emitter';
import { v4 as uuidV4 } from 'uuid';
import Redis from 'ioredis';

@@ -9,2 +8,4 @@ import { CommunicationPublisher, CommunicationSubscriber, CommunicationSubscriberEvents } from '../types';

const Redis = require('ioredis-mock') as typeof import('ioredis').default;
describe('subscribing to backbone channel updates', () => {

@@ -91,2 +92,4 @@ const RedisPublisherClient1 = new Redis();

await new Promise(resolve => setTimeout(resolve, 500)); // sleep
backbone1.broadcastPatch({

@@ -106,25 +109,20 @@ id: { uuid: uuid1, owner: 'test-user-Id', topic: 'workspace' },

await new Promise(resolve => setTimeout(resolve, 2000)); // sleep
await new Promise(resolve => setTimeout(resolve, 500)); // sleep
try {
expect(handler1).toBeCalledTimes(1);
expect(handler2).toBeCalledTimes(1);
expect(handler1).toBeCalledTimes(1);
expect(handler2).toBeCalledTimes(1);
expect(handler1).toBeCalledWith('test-user-Id', {
id: { uuid: uuid2, owner: 'test-user-Id', topic: 'workspace' },
oldRevision: 4,
newRevision: 5,
patches: [{ value: 'test', op: 'replace', path: ['/aaa'] }],
});
expect(handler1).toBeCalledWith({
id: { uuid: uuid2, owner: 'test-user-Id', topic: 'workspace' },
oldRevision: 4,
newRevision: 5,
patches: [{ value: 'test', op: 'replace', path: ['/aaa'] }],
});
expect(handler2).toBeCalledWith('test-user-Id', {
id: { uuid: uuid1, owner: 'test-user-Id', topic: 'workspace' },
oldRevision: 4,
newRevision: 5,
patches: [{ value: 'test', op: 'replace', path: ['/aaa'] }],
});
} finally {
backbone1.destroy();
backbone2.destroy();
}
expect(handler2).toBeCalledWith({
id: { uuid: uuid1, owner: 'test-user-Id', topic: 'workspace' },
oldRevision: 4,
newRevision: 5,
patches: [{ value: 'test', op: 'replace', path: ['/aaa'] }],
});
});

@@ -135,2 +133,4 @@

await new Promise(resolve => setTimeout(resolve, 500)); // sleep
backbone1.broadcastPatch({

@@ -148,3 +148,3 @@ id: { uuid: uuid1, owner: 'test-user-Id', topic: 'workspace' },

expect(handler2).toBeCalledWith('test-user-Id', {
expect(handler2).toBeCalledWith({
id: { uuid: uuid1, owner: 'test-user-Id', topic: 'workspace' },

@@ -162,3 +162,6 @@ oldRevision: 4,

await RedisSubscriberClient2.quit();
backbone1.destroy();
backbone2.destroy();
});
});

@@ -11,3 +11,3 @@ import { enablePatches } from 'immer';

const manager = new ObservableManager({ defaultPersistDebounceTimeout: 100, defaultPersistRetryTimeout: 1000 });
const manager = new ObservableManager({ defaultPersistDebounceWaitMs: 100, defaultPersistRetryDelayMs: 1000 });

@@ -14,0 +14,0 @@ manager.connectChannelClient(channel);

@@ -21,4 +21,4 @@ import { Patch, produceWithPatches, applyPatches } from 'immer';

export interface ObservableOptions {
persistDebounceTimeout: number;
persistRetryTimeout: number;
persistDebounceWaitMs: number;
persistRetryDelayMs: number;
displayName: string;

@@ -91,6 +91,6 @@ }

this._displayName = options.displayName;
this._retryTimeout = options.persistRetryTimeout;
this._retryTimeout = options.persistRetryDelayMs;
// Make sure we never wait for more than 4 times the debounce to minimize the probability of data loss
this._debouncedPersist = debounce(this.persist, options.persistDebounceTimeout, { maxWait: options.persistDebounceTimeout * 4 });
this._debouncedPersist = debounce(this.persist, options.persistDebounceWaitMs, { maxWait: options.persistDebounceWaitMs * 4 });
}

@@ -354,6 +354,7 @@

public detach() {
this._debouncedPersist.flush();
public async detach() {
clearTimeout(this._persistRetryTimer);
await this._debouncedPersist.flush();
this._adaptor.cleanup();

@@ -360,0 +361,0 @@

@@ -8,4 +8,4 @@ import { v4 as uuidV4 } from 'uuid';

export interface ObservableManagerOptions {
defaultPersistDebounceTimeout: number;
defaultPersistRetryTimeout: number;
defaultPersistDebounceWaitMs: number;
defaultPersistRetryDelayMs: number;
}

@@ -98,4 +98,4 @@

observer = new Observable<T>(adaptor, topic, {
persistDebounceTimeout: options?.persistDebounceTimeout ?? this._options.defaultPersistDebounceTimeout,
persistRetryTimeout: options?.persistRetryTimeout ?? this._options.defaultPersistRetryTimeout,
persistDebounceWaitMs: options?.persistDebounceWaitMs ?? this._options.defaultPersistDebounceWaitMs,
persistRetryDelayMs: options?.persistRetryDelayMs ?? this._options.defaultPersistRetryDelayMs,
displayName: options?.displayName ?? topic,

@@ -102,0 +102,0 @@ });

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc