Sha256: 5e813740d6f7e0d2f5f73711d8f0da8b9e1b7e7747e53e3ca104e369ba0bb052

Contents?: true

Size: 691 Bytes

Versions: 62

Compression:

Stored size: 691 Bytes

Contents

'use strict';

// Note: adler32 takes 12% for level 0 and 2% for level 6.
// It doesn't worth to make additional optimizationa as in original.
// Small size is preferable.

function adler32(adler, buf, len, pos) {
  var s1 = (adler & 0xffff) |0
    , s2 = ((adler >>> 16) & 0xffff) |0
    , n = 0;

  while (len !== 0) {
    // Set limit ~ twice less than 5552, to keep
    // s2 in 31-bits, because we force signed ints.
    // in other case %= will fail.
    n = len > 2000 ? 2000 : len;
    len -= n;

    do {
      s1 = (s1 + buf[pos++]) |0;
      s2 = (s2 + s1) |0;
    } while (--n);

    s1 %= 65521;
    s2 %= 65521;
  }

  return (s1 | (s2 << 16)) |0;
}


module.exports = adler32;

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
smock-0.1.228 node_modules/webpack/node_modules/node-libs-browser/node_modules/browserify-zlib/node_modules/pako/lib/zlib/adler32.js
smock-0.1.227 node_modules/webpack/node_modules/node-libs-browser/node_modules/browserify-zlib/node_modules/pako/lib/zlib/adler32.js
smock-0.1.226 node_modules/webpack/node_modules/node-libs-browser/node_modules/browserify-zlib/node_modules/pako/lib/zlib/adler32.js
smock-0.1.225 node_modules/webpack/node_modules/node-libs-browser/node_modules/browserify-zlib/node_modules/pako/lib/zlib/adler32.js
smock-0.1.224 node_modules/webpack/node_modules/node-libs-browser/node_modules/browserify-zlib/node_modules/pako/lib/zlib/adler32.js
smock-0.1.9 node_modules/webpack/node_modules/node-libs-browser/node_modules/browserify-zlib/node_modules/pako/lib/zlib/adler32.js
smock-0.1.223 node_modules/webpack/node_modules/node-libs-browser/node_modules/browserify-zlib/node_modules/pako/lib/zlib/adler32.js
smock-0.1.222 node_modules/webpack/node_modules/node-libs-browser/node_modules/browserify-zlib/node_modules/pako/lib/zlib/adler32.js
smock-0.1.221 node_modules/webpack/node_modules/node-libs-browser/node_modules/browserify-zlib/node_modules/pako/lib/zlib/adler32.js
smock-0.1.220 node_modules/webpack/node_modules/node-libs-browser/node_modules/browserify-zlib/node_modules/pako/lib/zlib/adler32.js
smock-0.1.219 node_modules/webpack/node_modules/node-libs-browser/node_modules/browserify-zlib/node_modules/pako/lib/zlib/adler32.js
smock-0.1.218 node_modules/webpack/node_modules/node-libs-browser/node_modules/browserify-zlib/node_modules/pako/lib/zlib/adler32.js
smock-0.1.217 node_modules/webpack/node_modules/node-libs-browser/node_modules/browserify-zlib/node_modules/pako/lib/zlib/adler32.js
smock-0.1.216 node_modules/webpack/node_modules/node-libs-browser/node_modules/browserify-zlib/node_modules/pako/lib/zlib/adler32.js
smock-0.1.215 node_modules/webpack/node_modules/node-libs-browser/node_modules/browserify-zlib/node_modules/pako/lib/zlib/adler32.js
smock-0.1.214 node_modules/webpack/node_modules/node-libs-browser/node_modules/browserify-zlib/node_modules/pako/lib/zlib/adler32.js
smock-0.1.213 node_modules/webpack/node_modules/node-libs-browser/node_modules/browserify-zlib/node_modules/pako/lib/zlib/adler32.js
smock-0.1.212 node_modules/webpack/node_modules/node-libs-browser/node_modules/browserify-zlib/node_modules/pako/lib/zlib/adler32.js
smock-0.1.211 node_modules/webpack/node_modules/node-libs-browser/node_modules/browserify-zlib/node_modules/pako/lib/zlib/adler32.js
smock-0.1.210 node_modules/webpack/node_modules/node-libs-browser/node_modules/browserify-zlib/node_modules/pako/lib/zlib/adler32.js