diff options
| author | akiyamn | 2023-09-24 23:22:21 +1000 |
|---|---|---|
| committer | akiyamn | 2023-09-24 23:22:21 +1000 |
| commit | 4e87195739f2a5d9a05451b48773c8afdc680765 (patch) | |
| tree | 9cba501844a4a11dcbdffc4050ed8189561c55ed /node_modules/rollup-plugin-node-polyfills/polyfills/zlib-lib/crc32.js | |
| download | price-tracker-worker-4e87195739f2a5d9a05451b48773c8afdc680765.tar.gz price-tracker-worker-4e87195739f2a5d9a05451b48773c8afdc680765.zip | |
Initial commit (by create-cloudflare CLI)
Diffstat (limited to 'node_modules/rollup-plugin-node-polyfills/polyfills/zlib-lib/crc32.js')
| -rw-r--r-- | node_modules/rollup-plugin-node-polyfills/polyfills/zlib-lib/crc32.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/node_modules/rollup-plugin-node-polyfills/polyfills/zlib-lib/crc32.js b/node_modules/rollup-plugin-node-polyfills/polyfills/zlib-lib/crc32.js new file mode 100644 index 0000000..6d897c1 --- /dev/null +++ b/node_modules/rollup-plugin-node-polyfills/polyfills/zlib-lib/crc32.js @@ -0,0 +1,40 @@ + +// 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 ^= -1; + + for (var i = pos; i < end; i++) { + crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xFF]; + } + + return (crc ^ (-1)); // >>> 0; +} + + +export default crc32; |
