Sha256: e60457f1250ad8d7cd327e1e8a4f668c8379fdf17735aaa395d27e6e34193d33

Contents?: true

Size: 793 Bytes

Versions: 9

Compression:

Stored size: 793 Bytes

Contents

'use strict';

// Note: we can't get significant speed boost here.
// So write code to minimize size - no pregenerated tables
// and array tools dependencies.


// Use ordinary array, since untyped makes no boost here
function makeTable() {
  var c, table = [];

  for (var n =0; n < 256; n++) {
    c = n;
    for (var k =0; k < 8; k++) {
      c = ((c&1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));
    }
    table[n] = c;
  }

  return table;
}

// Create table on load. Just 255 signed longs. Not a problem.
var crcTable = makeTable();


function crc32(crc, buf, len, pos) {
  var t = crcTable,
      end = pos + len;

  crc = crc ^ (-1);

  for (var i = pos; i < end; i++) {
    crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xFF];
  }

  return (crc ^ (-1)); // >>> 0;
}


module.exports = crc32;

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
brwy_rails-0.0.6 test/dummy/node_modules/pako/lib/zlib/crc32.js
brwy_rails-0.0.5 test/dummy/node_modules/pako/lib/zlib/crc32.js
brwy_rails-0.0.4 test/dummy/node_modules/pako/lib/zlib/crc32.js
brwy_rails-0.0.3 test/dummy/node_modules/pako/lib/zlib/crc32.js
brwy_rails-0.0.2 test/dummy/node_modules/pako/lib/zlib/crc32.js
brwy_rails-0.0.1 test/dummy/node_modules/pako/lib/zlib/crc32.js
gulp_assets-1.0.0.pre.5 template/node_modules/node-libs-browser/node_modules/browserify-zlib/node_modules/pako/lib/zlib/crc32.js
gulp_assets-1.0.0.pre.4 template/node_modules/node-libs-browser/node_modules/browserify-zlib/node_modules/pako/lib/zlib/crc32.js
gulp_assets-1.0.0.pre.3 template/node_modules/node-libs-browser/node_modules/browserify-zlib/node_modules/pako/lib/zlib/crc32.js