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

@observertc/observer-js

Package Overview
Dependencies
Maintainers
2
Versions
96
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@observertc/observer-js - npm Package Compare versions

Comparing version 0.30.5-beta to 0.30.6-beta

lib/CallSummary.d.ts

12

lib/ObservedSfu.d.ts
/// <reference types="node" />
import { EventEmitter } from 'events';
import { Observer } from './Observer';
import { SfuSample } from '@observertc/sample-schemas-js';
export type ObservedSfuConfig<AppData extends Record<string, unknown> = Record<string, unknown>> = {

@@ -22,6 +23,17 @@ serviceId: string;

private readonly _model;
readonly observer: Observer;
readonly appData: AppData;
static create<T extends Record<string, unknown> = Record<string, unknown>>(config: ObservedSfuConfig<T>, observer: Observer): Promise<ObservedSfu<T>>;
private _updated;
private readonly _execute;
private _closed;
private constructor();
get serviceId(): string;
get sfuId(): string;
get joined(): number;
get closed(): boolean;
close(): void;
update(sample: SfuSample): Promise<void>;
private _save;
}
//# sourceMappingURL=ObservedSfu.d.ts.map

55

lib/ObservedSfu.js

@@ -38,2 +38,3 @@ "use strict";

const Models = __importStar(require("./models/Models"));
const SingleExecutor_1 = require("./common/SingleExecutor");
class ObservedSfu extends events_1.EventEmitter {

@@ -49,3 +50,3 @@ static create(config, observer) {

});
const result = new ObservedSfu(model, config.appData);
const result = new ObservedSfu(model, observer, config.appData);
const alreadyInserted = yield observer.storage.sfuStorage.insert(config.sfuId, model);

@@ -57,8 +58,58 @@ if (alreadyInserted)

}
constructor(_model, appData) {
constructor(_model, observer, appData) {
super();
this._model = _model;
this.observer = observer;
this.appData = appData;
this._updated = Date.now();
this._execute = (0, SingleExecutor_1.createSingleExecutor)();
this._closed = false;
}
get serviceId() {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
return this._model.serviceId;
}
get sfuId() {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
return this._model.sfuId;
}
get joined() {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
return Number(this._model.joined);
}
get closed() {
return this._closed;
}
close() {
if (this._closed)
return;
this._closed = true;
this.emit('close');
}
update(sample) {
return __awaiter(this, void 0, void 0, function* () {
if (this._closed)
throw new Error(`Sfu ${this.sfuId} is closed`);
if (sample.sfuId !== this.sfuId)
throw new Error(`Sfu ${this.sfuId} is not the same as sample.sfuId`);
return this._execute(() => __awaiter(this, void 0, void 0, function* () {
if (this._closed)
throw new Error(`Sfu ${this.sfuId} is closed`);
yield this._save();
this.emit('update');
}));
});
}
_save() {
return __awaiter(this, void 0, void 0, function* () {
if (this._closed)
throw new Error(`Sfu ${this.sfuId} is closed`);
return this._execute(() => __awaiter(this, void 0, void 0, function* () {
if (this._closed)
throw new Error(`Sfu ${this.sfuId} is closed`);
yield this.observer.storage.sfuStorage.set(this.sfuId, this._model);
}));
});
}
}
exports.ObservedSfu = ObservedSfu;

2

package.json
{
"name": "@observertc/observer-js",
"version": "0.30.5-beta",
"version": "0.30.6-beta",
"description": "Server Side NodeJS Library for processing ObserveRTC Samples",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

import { EventEmitter } from 'events';
import * as Models from './models/Models';
import { Observer } from './Observer';
import { createSingleExecutor } from './common/SingleExecutor';
import { SfuSample } from '@observertc/sample-schemas-js';

@@ -38,2 +40,3 @@ export type ObservedSfuConfig<AppData extends Record<string, unknown> = Record<string, unknown>> = {

model,
observer,
config.appData,

@@ -48,5 +51,10 @@ );

}
private _updated = Date.now();
private readonly _execute = createSingleExecutor();
private _closed = false;
private constructor(
private readonly _model: Models.Sfu,
public readonly observer: Observer,
public readonly appData: AppData,

@@ -56,3 +64,48 @@ ) {

}
public get serviceId() {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
return this._model.serviceId!;
}
public get sfuId() {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
return this._model.sfuId!;
}
public get joined() {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
return Number(this._model.joined!);
}
public get closed() {
return this._closed;
}
public close() {
if (this._closed) return;
this._closed = true;
this.emit('close');
}
public async update(sample: SfuSample) {
if (this._closed) throw new Error(`Sfu ${this.sfuId} is closed`);
if (sample.sfuId !== this.sfuId) throw new Error(`Sfu ${this.sfuId} is not the same as sample.sfuId`);
return this._execute(async () => {
if (this._closed) throw new Error(`Sfu ${this.sfuId} is closed`);
await this._save();
this.emit('update');
});
}
private async _save() {
if (this._closed) throw new Error(`Sfu ${this.sfuId} is closed`);
return this._execute(async () => {
if (this._closed) throw new Error(`Sfu ${this.sfuId} is closed`);
await this.observer.storage.sfuStorage.set(this.sfuId, this._model);
});
}
}

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