Socket
Socket
Sign inDemoInstall

ncom

Package Overview
Dependencies
1
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.10.1 to 0.11.0

.npmignore

31

index.js

@@ -15,8 +15,11 @@ var net = require('net');

var dataBuffer = '';
var dataInboundBuffer = '';
var dataOutboundBuffer = '';
var endSymbol = '\u0017';
var endSymbolRegex = new RegExp(endSymbol, 'g');
var flushOutTimeout = null;
self.id = id;
self.connected = false;
self.batchDuration = 5; // 5 milliseconds

@@ -37,6 +40,6 @@ if (options instanceof net.Socket) {

self.socket.on('data', function (data) {
dataBuffer += data.toString();
var messages = dataBuffer.split(endSymbol);
dataInboundBuffer += data.toString();
var messages = dataInboundBuffer.split(endSymbol);
var num = messages.length - 1;
dataBuffer = messages[num];
dataInboundBuffer = messages[num];

@@ -76,5 +79,14 @@ for (var i=0; i<num; i++) {

self.write = function (data, filters) {
self._flushOutboundBuffer = function () {
self.socket.write(dataOutboundBuffer);
dataOutboundBuffer = '';
flushOutTimeout = null;
};
self.write = function (data, writeOptions) {
var str, formatError;
writeOptions = writeOptions || {};
var filters = writeOptions.filters;
try {

@@ -93,3 +105,10 @@ str = formatter.encode(data).replace(endSymbolRegex, '');

}
self.socket.write(str + endSymbol);
if (writeOptions.batch) {
dataOutboundBuffer += str + endSymbol;
if (!flushOutTimeout) {
flushOutTimeout = setTimeout(self._flushOutboundBuffer, self.batchDuration);
}
} else {
self.socket.write(str + endSymbol);
}
}

@@ -96,0 +115,0 @@ };

2

package.json
{
"name": "ncom",
"description": "A TCP socket pair for easily transmitting full messages without worrying about packet size limits.",
"version": "0.10.1",
"version": "0.11.0",
"author": {

@@ -6,0 +6,0 @@ "name": "JF Gros-Dubois",

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc