bufferutil
Advanced tools
Comparing version 1.2.1 to 1.3.0
@@ -1,3 +0,1 @@ | ||
'use strict'; | ||
/*! | ||
@@ -9,7 +7,9 @@ * bufferutil: WebSocket buffer utils | ||
module.exports.BufferUtil = { | ||
merge: function(mergedBuffer, buffers) { | ||
for (var i = 0, offset = 0, l = buffers.length; i < l; ++i) { | ||
'use strict'; | ||
exports.BufferUtil = { | ||
merge: function (mergedBuffer, buffers) { | ||
var offset = 0; | ||
for (var i = 0, l = buffers.length; i < l; ++i) { | ||
var buf = buffers[i]; | ||
buf.copy(mergedBuffer, offset); | ||
@@ -19,41 +19,14 @@ offset += buf.length; | ||
}, | ||
mask: function(source, mask, output, offset, length) { | ||
var maskNum = mask.readUInt32LE(0, true) | ||
, i = 0 | ||
, num; | ||
for (; i < length - 3; i += 4) { | ||
num = maskNum ^ source.readUInt32LE(i, true); | ||
if (num < 0) num = 4294967296 + num; | ||
output.writeUInt32LE(num, offset + i, true); | ||
mask: function (source, mask, output, offset, length) { | ||
for (var i = 0; i < length; i++) { | ||
output[offset + i] = source[i] ^ mask[i & 3]; | ||
} | ||
switch (length % 4) { | ||
case 3: output[offset + i + 2] = source[i + 2] ^ mask[2]; | ||
case 2: output[offset + i + 1] = source[i + 1] ^ mask[1]; | ||
case 1: output[offset + i] = source[i] ^ mask[0]; | ||
} | ||
}, | ||
unmask: function(data, mask) { | ||
var maskNum = mask.readUInt32LE(0, true) | ||
, length = data.length | ||
, i = 0 | ||
, num; | ||
for (; i < length - 3; i += 4) { | ||
num = maskNum ^ data.readUInt32LE(i, true); | ||
if (num < 0) num = 4294967296 + num; | ||
data.writeUInt32LE(num, i, true); | ||
unmask: function (data, mask) { | ||
// required until https://github.com/nodejs/node/issues/9006 is resolved | ||
var length = data.length; | ||
for (var i = 0; i < length; i++) { | ||
data[i] ^= mask[i & 3]; | ||
} | ||
switch (length % 4) { | ||
case 3: data[i + 2] = data[i + 2] ^ mask[2]; | ||
case 2: data[i + 1] = data[i + 1] ^ mask[1]; | ||
case 1: data[i] = data[i] ^ mask[0]; | ||
} | ||
} | ||
}; |
{ | ||
"name": "bufferutil", | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"description": "WebSocket buffer utils", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Only testing builds, test have to be extraced from `ws`\" && exit 0" | ||
"test": "echo \"Only testing builds, tests have to be extraced from ws\"" | ||
}, | ||
@@ -23,5 +23,5 @@ "repository": { | ||
"dependencies": { | ||
"bindings": "1.2.x", | ||
"nan": "^2.0.5" | ||
"bindings": "~1.2.1", | ||
"nan": "~2.4.0" | ||
} | ||
} |
# bufferutil | ||
[![Build Status](https://travis-ci.org/websockets/bufferutil.svg?branch=master)](https://travis-ci.org/websockets/bufferutil) | ||
[![Version npm](https://img.shields.io/npm/v/bufferutil.svg)](https://www.npmjs.com/package/bufferutil) | ||
[![Linux/macOS Build](https://travis-ci.org/websockets/bufferutil.svg?branch=master)](https://travis-ci.org/websockets/bufferutil) | ||
[![Windows Build](https://ci.appveyor.com/api/projects/status/github/websockets/bufferutil?branch=master&svg=true)](https://ci.appveyor.com/project/lpinca/bufferutil) | ||
@@ -13,3 +15,3 @@ Buffer utils is one of the modules that makes `ws` fast. It's optimized for | ||
repository. See `fallback.js` for the suggest fallback implementation if | ||
installation fails. | ||
installation fails. | ||
@@ -63,2 +65,2 @@ ## Installation | ||
MIT | ||
[MIT](LICENSE) |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
9049
65
7
34
2
+ Addednan@2.4.0(transitive)
- Removednan@2.22.0(transitive)
Updatedbindings@~1.2.1
Updatednan@~2.4.0