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

ws

Package Overview
Dependencies
Maintainers
4
Versions
169
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ws - npm Package Compare versions

Comparing version 3.1.0 to 3.2.0

57

lib/PerMessageDeflate.js

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

const zlib = require('zlib');
const Limiter = require('async-limiter');

@@ -14,2 +15,10 @@ const bufferUtil = require('./BufferUtil');

// We limit zlib concurrency, which prevents severe memory fragmentation
// as documented in https://github.com/nodejs/node/issues/8871#issuecomment-250915913
// and https://github.com/websockets/ws/issues/1202
//
// Intentionally global; it's the global thread pool that's
// an issue.
let zlibLimiter;
/**

@@ -30,2 +39,9 @@ * Per-message Deflate implementation.

this.params = null;
if (!zlibLimiter) {
const concurrency = this._options.concurrencyLimit !== undefined
? this._options.concurrencyLimit
: 10;
zlibLimiter = new Limiter({ concurrency });
}
}

@@ -255,3 +271,3 @@

/**
* Decompress data.
* Decompress data. Concurrency limited by async-limiter.
*

@@ -264,2 +280,36 @@ * @param {Buffer} data Compressed data

decompress (data, fin, callback) {
zlibLimiter.push((done) => {
this._decompress(data, fin, (err, result) => {
done();
callback(err, result);
});
});
}
/**
* Compress data. Concurrency limited by async-limiter.
*
* @param {Buffer} data Data to compress
* @param {Boolean} fin Specifies whether or not this is the last fragment
* @param {Function} callback Callback
* @public
*/
compress (data, fin, callback) {
zlibLimiter.push((done) => {
this._compress(data, fin, (err, result) => {
done();
callback(err, result);
});
});
}
/**
* Decompress data.
*
* @param {Buffer} data Compressed data
* @param {Boolean} fin Specifies whether or not this is the last fragment
* @param {Function} callback Callback
* @private
*/
_decompress (data, fin, callback) {
const endpoint = this._isServer ? 'client' : 'server';

@@ -330,5 +380,5 @@

* @param {Function} callback Callback
* @public
* @private
*/
compress (data, fin, callback) {
_compress (data, fin, callback) {
if (!data || data.length === 0) {

@@ -349,2 +399,3 @@ process.nextTick(callback, null, EMPTY_BLOCK);

memLevel: this._options.memLevel,
level: this._options.level,
flush: zlib.Z_SYNC_FLUSH,

@@ -351,0 +402,0 @@ windowBits

9

package.json
{
"name": "ws",
"version": "3.1.0",
"version": "3.2.0",
"description": "Simple to use, blazing fast and thoroughly tested websocket client and server for Node.js",

@@ -29,2 +29,3 @@ "keywords": [

"dependencies": {
"async-limiter": "~1.0.0",
"safe-buffer": "~5.1.0",

@@ -36,3 +37,3 @@ "ultron": "~1.1.0"

"bufferutil": "~3.0.0",
"eslint": "~4.3.0",
"eslint": "~4.6.0",
"eslint-config-standard": "~10.2.0",

@@ -43,6 +44,6 @@ "eslint-plugin-import": "~2.7.0",

"eslint-plugin-standard": "~3.0.0",
"mocha": "~3.4.1",
"nyc": "~11.0.1",
"mocha": "~3.5.0",
"nyc": "~11.2.0",
"utf-8-validate": "~3.0.0"
}
}
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