Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

binary-socket

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

binary-socket - npm Package Compare versions

Comparing version 0.5.1 to 0.5.2

1

dist/stream.js

@@ -111,3 +111,2 @@ 'use strict';

}
console.log(cmd, data, _id);
var message = msgpack.encode([cmd, data, _id]).slice();

@@ -114,0 +113,0 @@ return this._socket.send(message) !== false;

2

package.json
{
"name": "binary-socket",
"version": "0.5.1",
"version": "0.5.2",
"description": "Simple Binary Sockets to use, builded on thoroughly tested modules, standards and it's easy to integrate.",

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

@@ -1,67 +0,8 @@

import {MASTER_KEY, EVENTS} from '../lib/constants';
import ProcessCustodian from '../lib/ProcessCustodian';
import {mockCollection} from './mock';
import {mock, useFakeTimers} from 'sinon';
import {expect} from 'chai';
import {asset} from 'chai';
const {describe, it} = global;
const tickTimeInSeconds = 10;
const clock = useFakeTimers();
const porocessCustodian = new ProcessCustodian({
rawCollection: mockCollection(),
tickTimeInSeconds,
marginTimeForRenew: 2
});
describe('lagging', () => {
it('should be instance of ProcessCustodian', () => {
expect(porocessCustodian).to.be.instanceof(ProcessCustodian);
expect(porocessCustodian.getEventLoopLag).to.be.function;
expect(porocessCustodian.isOverloaded).to.be.function;
expect(porocessCustodian.onceIAmNewMaster).to.be.function;
expect(porocessCustodian.onceIAmSlave).to.be.function;
expect(porocessCustodian.onceTick).to.be.function;
expect(porocessCustodian.onceStop).to.be.function;
expect(porocessCustodian.onIAmNewMaster).to.be.function;
expect(porocessCustodian.onIAmSlave).to.be.function;
expect(porocessCustodian.onTick).to.be.function;
describe('test 1', () => {
it('test test', () => {
assert.isOk('everything', 'everything is ok');
});
it('should return no lag ', () => {
const noLag = porocessCustodian.getEventLoopLag();
expect(noLag).be.equal(0);
});
it('should once called on tick should', () => {
const exp = mock({once(){}}).expects('once');
expect(porocessCustodian.onceTick(() => {
exp.once();
console.log('Once called onceTick', exp);
})).to.be.an('undefined');
clock.tick(90);
clock.tick(510);
exp.verify();
clock.tick(780);
});
it('should return a lag value after a little load', function() {
const ts = Date.now();
console.log('Start heavy work');
clock.tick(200001);
heavyWork(200);
clock.tick(200001);
heavyWork(200);
clock.tick(200001);
console.log('Stop heavy work');
const lag = porocessCustodian.getEventLoopLag();
expect(lag).be.above(1);
});
});
function heavyWork(duration) {
let a = 1;
for (let i = 0; i < 1e7; i++) {
a = a + 1;
}
porocessCustodian.onTick(()=> console.log('time'));
for (let i = 0; i < 1e7; i++) {
a = a + 1;
}
console.log('a', a);
}

@@ -66,3 +66,2 @@ import {Stream} from 'stream';

}
console.log(cmd, data, _id);
const message = msgpack.encode([cmd, data, _id]).slice();

@@ -69,0 +68,0 @@ return this._socket.send(message) !== false;

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