source: trip-planner-front/node_modules/pako/lib/zlib/crc32.js@ 6a80231

Last change on this file since 6a80231 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.7 KB
Line 
1'use strict';
2
3// Note: we can't get significant speed boost here.
4// So write code to minimize size - no pregenerated tables
5// and array tools dependencies.
6
7// (C) 1995-2013 Jean-loup Gailly and Mark Adler
8// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin
9//
10// This software is provided 'as-is', without any express or implied
11// warranty. In no event will the authors be held liable for any damages
12// arising from the use of this software.
13//
14// Permission is granted to anyone to use this software for any purpose,
15// including commercial applications, and to alter it and redistribute it
16// freely, subject to the following restrictions:
17//
18// 1. The origin of this software must not be misrepresented; you must not
19// claim that you wrote the original software. If you use this software
20// in a product, an acknowledgment in the product documentation would be
21// appreciated but is not required.
22// 2. Altered source versions must be plainly marked as such, and must not be
23// misrepresented as being the original software.
24// 3. This notice may not be removed or altered from any source distribution.
25
26// Use ordinary array, since untyped makes no boost here
27function makeTable() {
28 var c, table = [];
29
30 for (var n = 0; n < 256; n++) {
31 c = n;
32 for (var k = 0; k < 8; k++) {
33 c = ((c & 1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));
34 }
35 table[n] = c;
36 }
37
38 return table;
39}
40
41// Create table on load. Just 255 signed longs. Not a problem.
42var crcTable = makeTable();
43
44
45function crc32(crc, buf, len, pos) {
46 var t = crcTable,
47 end = pos + len;
48
49 crc ^= -1;
50
51 for (var i = pos; i < end; i++) {
52 crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xFF];
53 }
54
55 return (crc ^ (-1)); // >>> 0;
56}
57
58
59module.exports = crc32;
Note: See TracBrowser for help on using the repository browser.