Sha256: 4526f9671f42817dda763cdbbdffe46f5c15f107d163712df83c46343d4a09a0

Contents?: true

Size: 725 Bytes

Versions: 180

Compression:

Stored size: 725 Bytes

Contents

/**
 * An abstraction for slicing an arraybuffer even when
 * ArrayBuffer.prototype.slice is not supported
 *
 * @api public
 */

module.exports = function(arraybuffer, start, end) {
  var bytes = arraybuffer.byteLength;
  start = start || 0;
  end = end || bytes;

  if (arraybuffer.slice) { return arraybuffer.slice(start, end); }

  if (start < 0) { start += bytes; }
  if (end < 0) { end += bytes; }
  if (end > bytes) { end = bytes; }

  if (start >= bytes || start >= end || bytes === 0) {
    return new ArrayBuffer(0);
  }

  var abv = new Uint8Array(arraybuffer);
  var result = new Uint8Array(end - start);
  for (var i = start, ii = 0; i < end; i++, ii++) {
    result[ii] = abv[i];
  }
  return result.buffer;
};

Version data entries

180 entries across 92 versions & 4 rubygems

Version Path
ilog-0.4.1 node_modules/arraybuffer.slice/index.js
ilog-0.4.0 node_modules/arraybuffer.slice/index.js
ilog-0.3.3 node_modules/arraybuffer.slice/index.js
blackboard-3.1.9 lib/site_template/node_modules/arraybuffer.slice/index.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/engine.io-parser/node_modules/arraybuffer.slice/index.js
flok-0.0.105 spec/iface/driver/assets/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/arraybuffer.slice/index.js
flok-0.0.103 spec/iface/driver/assets/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/arraybuffer.slice/index.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/engine.io-parser/node_modules/arraybuffer.slice/index.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/engine.io-parser/node_modules/arraybuffer.slice/index.js
flok-0.0.102 spec/iface/driver/assets/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/arraybuffer.slice/index.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/engine.io-parser/node_modules/arraybuffer.slice/index.js
gulp_assets-1.0.0.pre.5 template/node_modules/webpack-dev-server/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/arraybuffer.slice/index.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/engine.io-parser/node_modules/arraybuffer.slice/index.js
gulp_assets-1.0.0.pre.4 template/node_modules/webpack-dev-server/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/arraybuffer.slice/index.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/engine.io-parser/node_modules/arraybuffer.slice/index.js
gulp_assets-1.0.0.pre.3 template/node_modules/webpack-dev-server/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/arraybuffer.slice/index.js
flok-0.0.101 spec/iface/driver/assets/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/arraybuffer.slice/index.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/engine.io-parser/node_modules/arraybuffer.slice/index.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/engine.io-parser/node_modules/arraybuffer.slice/index.js
flok-0.0.100 spec/iface/driver/assets/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/arraybuffer.slice/index.js