MCPcopy Create free account
hub / github.com/TruthHun/BookStack / adler32

Function adler32

static/word2md/mammoth.browser.js:18120–18142  ·  view source on GitHub ↗
(adler, buf, len, pos)

Source from the content-addressed store, hash-verified

18118// Small size is preferable.
18119
18120function adler32(adler, buf, len, pos) {
18121 var s1 = (adler & 0xffff) |0,
18122 s2 = ((adler >>> 16) & 0xffff) |0,
18123 n = 0;
18124
18125 while (len !== 0) {
18126 // Set limit ~ twice less than 5552, to keep
18127 // s2 in 31-bits, because we force signed ints.
18128 // in other case %= will fail.
18129 n = len > 2000 ? 2000 : len;
18130 len -= n;
18131
18132 do {
18133 s1 = (s1 + buf[pos++]) |0;
18134 s2 = (s2 + s1) |0;
18135 } while (--n);
18136
18137 s1 %= 65521;
18138 s2 %= 65521;
18139 }
18140
18141 return (s1 | (s2 << 16)) |0;
18142}
18143
18144
18145module.exports = adler32;

Callers 4

read_bufFunction · 0.70
deflateSetDictionaryFunction · 0.70
inflateFunction · 0.70
inflateSetDictionaryFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected