Sha256: 8d05d6f1a34e64d5f77309d83e6e24382f0df8b265abbe949298b35643253a18

Contents?: true

Size: 1.39 KB

Versions: 194

Compression:

Stored size: 1.39 KB

Contents

/*!
 * ws: a node.js websocket client
 * Copyright(c) 2011 Einar Otto Stangvik <einaros@gmail.com>
 * MIT Licensed
 */

module.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);
      offset += buf.length;
    }
  },
  mask: function(source, mask, output, offset, length) {
    var maskNum = mask.readUInt32LE(0, true);
    var i = 0;
    for (; i < length - 3; i += 4) {
      var num = maskNum ^ source.readUInt32LE(i, true);
      if (num < 0) num = 4294967296 + num;
      output.writeUInt32LE(num, offset + i, true);
    }
    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];
      case 0:;
    }
  },
  unmask: function(data, mask) {
    var maskNum = mask.readUInt32LE(0, true);
    var length = data.length;
    var i = 0;
    for (; i < length - 3; i += 4) {
      var num = maskNum ^ data.readUInt32LE(i, true);
      if (num < 0) num = 4294967296 + num;
      data.writeUInt32LE(num, i, true);
    }
    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];
      case 0:;
    }
  }
}

Version data entries

194 entries across 106 versions & 5 rubygems

Version Path
blackboard-3.1.9 lib/site_template/node_modules/ws/lib/BufferUtil.fallback.js
flok-0.0.105 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/ws/lib/BufferUtil.fallback.js
flok-0.0.105 spec/iface/driver/assets/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/BufferUtil.fallback.js
flok-0.0.103 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/ws/lib/BufferUtil.fallback.js
flok-0.0.103 spec/iface/driver/assets/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/BufferUtil.fallback.js
hooch-0.4.2 jasmine/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/node_modules/ws/lib/BufferUtil.fallback.js
hooch-0.4.1 jasmine/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/node_modules/ws/lib/BufferUtil.fallback.js
hooch-0.4.0 jasmine/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/node_modules/ws/lib/BufferUtil.fallback.js
flok-0.0.102 spec/iface/driver/assets/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/BufferUtil.fallback.js
flok-0.0.102 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/ws/lib/BufferUtil.fallback.js
gulp_assets-1.0.0.pre.5 template/node_modules/webpack-dev-server/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/ws/lib/BufferUtil.fallback.js
gulp_assets-1.0.0.pre.5 template/node_modules/webpack-dev-server/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/BufferUtil.fallback.js
gulp_assets-1.0.0.pre.4 template/node_modules/webpack-dev-server/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/ws/lib/BufferUtil.fallback.js
gulp_assets-1.0.0.pre.4 template/node_modules/webpack-dev-server/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/BufferUtil.fallback.js
gulp_assets-1.0.0.pre.3 template/node_modules/webpack-dev-server/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/ws/lib/BufferUtil.fallback.js
gulp_assets-1.0.0.pre.3 template/node_modules/webpack-dev-server/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/BufferUtil.fallback.js
flok-0.0.101 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/ws/lib/BufferUtil.fallback.js
flok-0.0.101 spec/iface/driver/assets/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/BufferUtil.fallback.js
hooch-0.3.0 jasmine/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/node_modules/ws/lib/BufferUtil.fallback.js
flok-0.0.100 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/ws/lib/BufferUtil.fallback.js