@geckos.io/common
Advanced tools
Comparing version 1.4.3 to 1.5.0
@@ -11,3 +11,2 @@ import EventEmitter from 'eventemitter3'; | ||
on(eventName: EventName, cb: Function): EventEmitter<string | symbol, any>; | ||
removeListener(eventName: EventName, emitted: EventEmitter.ListenerFn, context?: undefined): void; | ||
removeAllListeners(): void; | ||
@@ -14,0 +13,0 @@ } |
@@ -21,6 +21,6 @@ "use strict"; | ||
}; | ||
Bridge.prototype.removeListener = function (eventName, emitted, context) { | ||
if (context === void 0) { context = undefined; } | ||
this.eventEmitter.removeListener(eventName, emitted, context); | ||
}; | ||
// this is never used | ||
// removeListener(eventName: EventName, emitted: EventEmitter.ListenerFn, context = undefined) { | ||
// this.eventEmitter.removeListener(eventName, emitted, context) | ||
// } | ||
Bridge.prototype.removeAllListeners = function () { | ||
@@ -27,0 +27,0 @@ this.eventEmitter.removeAllListeners(); |
@@ -11,2 +11,3 @@ declare const EVENTS: { | ||
RAW_MESSAGE: string; | ||
DROP: string; | ||
}; | ||
@@ -16,4 +17,6 @@ declare const ERRORS: { | ||
COULD_NOT_PARSE_MESSAGE: string; | ||
DROPPED_FROM_BUFFERING: string; | ||
MAX_MESSAGE_SIZE_EXCEEDED: string; | ||
}; | ||
export { EVENTS, ERRORS }; | ||
//# sourceMappingURL=constants.d.ts.map |
@@ -13,3 +13,4 @@ "use strict"; | ||
DATA_CHANNEL_IS_OPEN: 'dataChannelIsOpen', | ||
RAW_MESSAGE: 'rawMessage' | ||
RAW_MESSAGE: 'rawMessage', | ||
DROP: 'dropped' | ||
}; | ||
@@ -19,5 +20,7 @@ exports.EVENTS = EVENTS; | ||
BROWSER_NOT_SUPPORTED: 'BROWSER_NOT_SUPPORTED', | ||
COULD_NOT_PARSE_MESSAGE: 'COULD_NOT_PARSE_MESSAGE' | ||
COULD_NOT_PARSE_MESSAGE: 'COULD_NOT_PARSE_MESSAGE', | ||
DROPPED_FROM_BUFFERING: 'DROPPED_FROM_BUFFERING', | ||
MAX_MESSAGE_SIZE_EXCEEDED: 'MAX_MESSAGE_SIZE_EXCEEDED' | ||
}; | ||
exports.ERRORS = ERRORS; | ||
//# sourceMappingURL=constants.js.map |
@@ -1,3 +0,3 @@ | ||
declare const runInterval: (interval?: number, runs?: number, cb?: Function) => void; | ||
declare const runInterval: (interval: number | undefined, runs: number | undefined, cb: Function) => void; | ||
export default runInterval; | ||
//# sourceMappingURL=runInterval.d.ts.map |
@@ -6,6 +6,7 @@ "use strict"; | ||
if (runs === void 0) { runs = 1; } | ||
if (cb === void 0) { cb = function () { | ||
console.error('Please add a callback function to runInterval()'); | ||
}; } | ||
var counter = 0; | ||
if (typeof cb !== 'function') { | ||
console.error('You have to define your callback function!'); | ||
return; | ||
} | ||
var i = setInterval(function () { | ||
@@ -12,0 +13,0 @@ cb(); |
import { Data, RawMessage, EventName } from './typings'; | ||
declare const SendMessage: (dataChannel: RTCDataChannel, eventName: EventName, data?: Data | RawMessage | null) => void; | ||
declare const SendMessage: (dataChannel: RTCDataChannel, maxMessageSize: number | undefined, eventName: EventName, data?: Data | RawMessage | null) => any; | ||
export default SendMessage; | ||
//# sourceMappingURL=sendMessage.d.ts.map |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var helpers_1 = require("./helpers"); | ||
var constants_1 = require("./constants"); | ||
var SendMessage = function (dataChannel, eventName, data) { | ||
var object_sizeof_1 = __importDefault(require("object-sizeof")); | ||
var SendMessage = function (dataChannel, maxMessageSize, eventName, data) { | ||
var _a; | ||
if (data === void 0) { data = null; } | ||
var send = function (data) { | ||
if (typeof maxMessageSize === 'number' && object_sizeof_1.default(data) > maxMessageSize) | ||
throw new Error("maxMessageSize of " + maxMessageSize + " exceeded"); | ||
else | ||
dataChannel.send(data); | ||
}; | ||
if (dataChannel.readyState === 'open') { | ||
try { | ||
if (eventName === constants_1.EVENTS.RAW_MESSAGE && data !== null && helpers_1.isRawMessage(data)) { | ||
// @ts-ignore | ||
dataChannel.send(data); | ||
send(data); | ||
} | ||
else { | ||
dataChannel.send(JSON.stringify((_a = {}, _a[eventName] = data, _a))); | ||
send(JSON.stringify((_a = {}, _a[eventName] = data, _a))); | ||
} | ||
} | ||
catch (error) { | ||
console.error('Error => dataChannel.send: ', error.message); | ||
console.error('Error in sendMessage.ts: ', error.message); | ||
return error; | ||
} | ||
@@ -21,0 +31,0 @@ } |
@@ -22,2 +22,3 @@ /// <reference types="node" /> | ||
cors?: CorsOptions; | ||
autoManageBuffering?: boolean; | ||
} | ||
@@ -24,0 +25,0 @@ export interface ClientOptions { |
{ | ||
"name": "@geckos.io/common", | ||
"version": "1.4.3", | ||
"version": "1.5.0", | ||
"description": "The common module for @geckos.io/server and @geckos.io/client.", | ||
@@ -28,4 +28,8 @@ "main": "lib", | ||
"dependencies": { | ||
"eventemitter3": "^4.0.0" | ||
"eventemitter3": "^4.0.0", | ||
"object-sizeof": "^1.6.0" | ||
}, | ||
"funding": { | ||
"url": "https://github.com/sponsors/yandeu" | ||
} | ||
} |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22069
309
2
+ Addedobject-sizeof@^1.6.0
+ Addedbase64-js@1.5.1(transitive)
+ Addedbuffer@5.7.1(transitive)
+ Addedieee754@1.2.1(transitive)
+ Addedobject-sizeof@1.6.3(transitive)