@ohos-ports/crc 0.0.0-stage → 4.3.2-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (163) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +122 -2
  3. package/calculators/crc1.d.ts +3 -0
  4. package/calculators/crc16.d.ts +3 -0
  5. package/calculators/crc16ccitt.d.ts +3 -0
  6. package/calculators/crc16kermit.d.ts +3 -0
  7. package/calculators/crc16modbus.d.ts +3 -0
  8. package/calculators/crc16xmodem.d.ts +3 -0
  9. package/calculators/crc24.d.ts +3 -0
  10. package/calculators/crc32.d.ts +3 -0
  11. package/calculators/crc32mpeg.d.ts +3 -0
  12. package/calculators/crc32mpeg2.d.ts +3 -0
  13. package/calculators/crc5.d.ts +3 -0
  14. package/calculators/crc8.d.ts +3 -0
  15. package/calculators/crc81wire.d.ts +3 -0
  16. package/calculators/crc8dvbs2.d.ts +3 -0
  17. package/calculators/crcjam.d.ts +3 -0
  18. package/cjs/calculators/crc1.js +12 -0
  19. package/cjs/calculators/crc16.js +38 -0
  20. package/cjs/calculators/crc16ccitt.js +38 -0
  21. package/cjs/calculators/crc16kermit.js +38 -0
  22. package/cjs/calculators/crc16modbus.js +38 -0
  23. package/cjs/calculators/crc16xmodem.js +18 -0
  24. package/cjs/calculators/crc24.js +45 -0
  25. package/cjs/calculators/crc32.js +49 -0
  26. package/cjs/calculators/crc32mpeg2.js +48 -0
  27. package/cjs/calculators/crc5.js +37 -0
  28. package/cjs/calculators/crc8.js +32 -0
  29. package/cjs/calculators/crc81wire.js +32 -0
  30. package/cjs/calculators/crc8dvbs2.js +32 -0
  31. package/cjs/calculators/crcjam.js +48 -0
  32. package/cjs/crc1.js +8 -0
  33. package/cjs/crc16.js +8 -0
  34. package/cjs/crc16ccitt.js +8 -0
  35. package/cjs/crc16kermit.js +8 -0
  36. package/cjs/crc16modbus.js +8 -0
  37. package/cjs/crc16xmodem.js +8 -0
  38. package/cjs/crc24.js +8 -0
  39. package/cjs/crc32.js +8 -0
  40. package/cjs/crc32mpeg2.js +8 -0
  41. package/cjs/crc5.js +8 -0
  42. package/cjs/crc8.js +8 -0
  43. package/cjs/crc81wire.js +8 -0
  44. package/cjs/crc8dvbs2.js +8 -0
  45. package/cjs/crcjam.js +8 -0
  46. package/cjs/create_buffer.js +7 -0
  47. package/cjs/define_crc.js +14 -0
  48. package/cjs/index.js +47 -0
  49. package/cjs/package.json +3 -0
  50. package/cjs/types.js +2 -0
  51. package/cjs-default-unwrap/calculators/crc1.js +3 -0
  52. package/cjs-default-unwrap/calculators/crc16.js +3 -0
  53. package/cjs-default-unwrap/calculators/crc16ccitt.js +3 -0
  54. package/cjs-default-unwrap/calculators/crc16kermit.js +3 -0
  55. package/cjs-default-unwrap/calculators/crc16modbus.js +3 -0
  56. package/cjs-default-unwrap/calculators/crc16xmodem.js +3 -0
  57. package/cjs-default-unwrap/calculators/crc24.js +3 -0
  58. package/cjs-default-unwrap/calculators/crc32.js +3 -0
  59. package/cjs-default-unwrap/calculators/crc32mpeg2.js +3 -0
  60. package/cjs-default-unwrap/calculators/crc8.js +3 -0
  61. package/cjs-default-unwrap/calculators/crc81wire.js +3 -0
  62. package/cjs-default-unwrap/calculators/crc8dvbs2.js +3 -0
  63. package/cjs-default-unwrap/calculators/crcjam.js +3 -0
  64. package/cjs-default-unwrap/crc1.js +3 -0
  65. package/cjs-default-unwrap/crc16.js +3 -0
  66. package/cjs-default-unwrap/crc16ccitt.js +3 -0
  67. package/cjs-default-unwrap/crc16kermit.js +3 -0
  68. package/cjs-default-unwrap/crc16modbus.js +3 -0
  69. package/cjs-default-unwrap/crc16xmodem.js +3 -0
  70. package/cjs-default-unwrap/crc24.js +3 -0
  71. package/cjs-default-unwrap/crc32.js +3 -0
  72. package/cjs-default-unwrap/crc32mpeg2.js +3 -0
  73. package/cjs-default-unwrap/crc8.js +3 -0
  74. package/cjs-default-unwrap/crc81wire.js +3 -0
  75. package/cjs-default-unwrap/crc8dvbs2.js +3 -0
  76. package/cjs-default-unwrap/crcjam.js +3 -0
  77. package/cjs-default-unwrap/index.js +17 -0
  78. package/cjs-default-unwrap/package.json +3 -0
  79. package/crc1.d.ts +2 -0
  80. package/crc16.d.ts +2 -0
  81. package/crc16ccitt.d.ts +2 -0
  82. package/crc16kermit.d.ts +2 -0
  83. package/crc16modbus.d.ts +2 -0
  84. package/crc16xmodem.d.ts +2 -0
  85. package/crc24.d.ts +2 -0
  86. package/crc32.d.ts +2 -0
  87. package/crc32mpeg.d.ts +2 -0
  88. package/crc32mpeg2.d.ts +2 -0
  89. package/crc5.d.ts +2 -0
  90. package/crc8.d.ts +2 -0
  91. package/crc81wire.d.ts +2 -0
  92. package/crc8dvbs2.d.ts +2 -0
  93. package/crcjam.d.ts +2 -0
  94. package/create_buffer.d.ts +5 -0
  95. package/define_crc.d.ts +2 -0
  96. package/index.d.ts +42 -0
  97. package/mjs/calculators/crc1.d.ts +3 -0
  98. package/mjs/calculators/crc1.js +10 -0
  99. package/mjs/calculators/crc16.d.ts +3 -0
  100. package/mjs/calculators/crc16.js +36 -0
  101. package/mjs/calculators/crc16ccitt.d.ts +3 -0
  102. package/mjs/calculators/crc16ccitt.js +36 -0
  103. package/mjs/calculators/crc16kermit.d.ts +3 -0
  104. package/mjs/calculators/crc16kermit.js +36 -0
  105. package/mjs/calculators/crc16modbus.d.ts +3 -0
  106. package/mjs/calculators/crc16modbus.js +36 -0
  107. package/mjs/calculators/crc16xmodem.d.ts +3 -0
  108. package/mjs/calculators/crc16xmodem.js +16 -0
  109. package/mjs/calculators/crc24.d.ts +3 -0
  110. package/mjs/calculators/crc24.js +43 -0
  111. package/mjs/calculators/crc32.d.ts +3 -0
  112. package/mjs/calculators/crc32.js +47 -0
  113. package/mjs/calculators/crc32mpeg2.d.ts +3 -0
  114. package/mjs/calculators/crc32mpeg2.js +46 -0
  115. package/mjs/calculators/crc5.d.ts +3 -0
  116. package/mjs/calculators/crc5.js +35 -0
  117. package/mjs/calculators/crc8.d.ts +3 -0
  118. package/mjs/calculators/crc8.js +30 -0
  119. package/mjs/calculators/crc81wire.d.ts +3 -0
  120. package/mjs/calculators/crc81wire.js +30 -0
  121. package/mjs/calculators/crc8dvbs2.d.ts +3 -0
  122. package/mjs/calculators/crc8dvbs2.js +30 -0
  123. package/mjs/calculators/crcjam.d.ts +3 -0
  124. package/mjs/calculators/crcjam.js +46 -0
  125. package/mjs/crc1.d.ts +2 -0
  126. package/mjs/crc1.js +3 -0
  127. package/mjs/crc16.d.ts +2 -0
  128. package/mjs/crc16.js +3 -0
  129. package/mjs/crc16ccitt.d.ts +2 -0
  130. package/mjs/crc16ccitt.js +3 -0
  131. package/mjs/crc16kermit.d.ts +2 -0
  132. package/mjs/crc16kermit.js +3 -0
  133. package/mjs/crc16modbus.d.ts +2 -0
  134. package/mjs/crc16modbus.js +3 -0
  135. package/mjs/crc16xmodem.d.ts +2 -0
  136. package/mjs/crc16xmodem.js +3 -0
  137. package/mjs/crc24.d.ts +2 -0
  138. package/mjs/crc24.js +3 -0
  139. package/mjs/crc32.d.ts +2 -0
  140. package/mjs/crc32.js +3 -0
  141. package/mjs/crc32mpeg2.d.ts +2 -0
  142. package/mjs/crc32mpeg2.js +3 -0
  143. package/mjs/crc5.d.ts +2 -0
  144. package/mjs/crc5.js +3 -0
  145. package/mjs/crc8.d.ts +2 -0
  146. package/mjs/crc8.js +3 -0
  147. package/mjs/crc81wire.d.ts +2 -0
  148. package/mjs/crc81wire.js +3 -0
  149. package/mjs/crc8dvbs2.d.ts +2 -0
  150. package/mjs/crc8dvbs2.js +3 -0
  151. package/mjs/crcjam.d.ts +2 -0
  152. package/mjs/crcjam.js +3 -0
  153. package/mjs/create_buffer.d.ts +5 -0
  154. package/mjs/create_buffer.js +5 -0
  155. package/mjs/define_crc.d.ts +2 -0
  156. package/mjs/define_crc.js +8 -0
  157. package/mjs/index.d.ts +42 -0
  158. package/mjs/index.js +41 -0
  159. package/mjs/package.json +3 -0
  160. package/mjs/types.d.ts +11 -0
  161. package/mjs/types.js +1 -0
  162. package/package.json +191 -4
  163. package/types.d.ts +11 -0
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright 2014 Alex Gorbatchev
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,123 @@
1
- # Temporary Holding Version
1
+ # crc
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Functions for calculating Cyclic Redundancy Checks (CRC) values for the Node.js and front-end.
4
+
5
+ ## Features
6
+
7
+ - Written in TypeScript and provides typings out of the box.
8
+ - Supports ESM and CommonJS.
9
+ - Pure JavaScript implementation, no native dependencies.
10
+ - Full test suite using `pycrc` as a refenrence.
11
+ - Supports for the following CRC algorithms:
12
+ - CRC1 (`crc1`)
13
+ - CRC8 (`crc8`)
14
+ - CRC8 1-Wire (`crc81wire`)
15
+ - CRC8 DVB-S2 (`crc8dvbs2`)
16
+ - CRC16 (`crc16`)
17
+ - CRC16 CCITT (`crc16ccitt`)
18
+ - CRC16 Modbus (`crc16modbus`)
19
+ - CRC16 Kermit (`crc16kermit`)
20
+ - CRC16 XModem (`crc16xmodem`)
21
+ - CRC24 (`crc24`)
22
+ - CRC32 (`crc32`)
23
+ - CRC32 MPEG-2 (`crc32mpeg`)
24
+ - CRCJAM (`crcjam`)
25
+
26
+ ## Installation
27
+
28
+ ```
29
+ npm install crc
30
+ ```
31
+
32
+ ## Usage
33
+
34
+ Using specific CRC is the recommended way to reduce bundle size:
35
+
36
+ ```js
37
+ import crc32 from 'crc/crc32';
38
+ crc32('hello').toString(16);
39
+ // "3610a686"
40
+ ```
41
+
42
+ Alternatively you can use main default export:
43
+
44
+ ```js
45
+ import crc from 'crc';
46
+ crc.crc32('hello').toString(16);
47
+ // "3610a686"
48
+ ```
49
+
50
+ If you really wish to minimize bundle size, you can import CRC calculators directly and pass an instance of `Int8Array`:
51
+
52
+ ```js
53
+ import crc32 from 'crc/calculators/crc32';
54
+ const helloWorld = new Int8Array([104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100]);
55
+ crc32(helloWorld).toString(16);
56
+ // "3610a686"
57
+ ```
58
+
59
+ CommonJS is supported as well without the need to unwrap `.default`:
60
+
61
+ ```js
62
+ const crc32 = require('crc/crc32');
63
+ crc32('hello').toString(16);
64
+ // "3610a686"
65
+ ```
66
+
67
+ Calculate a CRC32 of a file:
68
+
69
+ ```js
70
+ crc32(fs.readFileSync('README.md', 'utf-8')).toString(16);
71
+ // "127ad531"
72
+ ```
73
+
74
+ Or using a `Buffer`:
75
+
76
+ ```js
77
+ crc32(fs.readFileSync('README.md', 'utf-8')).toString(16);
78
+ // "127ad531"
79
+ ```
80
+
81
+ Incrementally calculate a CRC:
82
+
83
+ ```js
84
+ let value = crc32('one');
85
+ value = crc32('two', value);
86
+ value = crc32('three', value);
87
+ value.toString(16);
88
+ // "9e1c092"
89
+ ```
90
+
91
+ ## Tests
92
+
93
+ ```
94
+ npm test
95
+ ```
96
+
97
+ ## Thanks!
98
+
99
+ [pycrc](http://www.tty1.net/pycrc/) library is which the source of all of the CRC tables.
100
+
101
+ # License
102
+
103
+ The MIT License (MIT)
104
+
105
+ Copyright (c) 2014 Alex Gorbatchev
106
+
107
+ Permission is hereby granted, free of charge, to any person obtaining a copy
108
+ of this software and associated documentation files (the "Software"), to deal
109
+ in the Software without restriction, including without limitation the rights
110
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
111
+ copies of the Software, and to permit persons to whom the Software is
112
+ furnished to do so, subject to the following conditions:
113
+
114
+ The above copyright notice and this permission notice shall be included in
115
+ all copies or substantial portions of the Software.
116
+
117
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
118
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
119
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
120
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
121
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
122
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
123
+ THE SOFTWARE.
@@ -0,0 +1,3 @@
1
+ import { CRCCalculator } from '../types.js';
2
+ declare const crc1: CRCCalculator<Uint8Array>;
3
+ export default crc1;
@@ -0,0 +1,3 @@
1
+ import { CRCCalculator } from '../types.js';
2
+ declare const crc16: CRCCalculator<Uint8Array>;
3
+ export default crc16;
@@ -0,0 +1,3 @@
1
+ import { CRCCalculator } from '../types.js';
2
+ declare const crc16ccitt: CRCCalculator<Uint8Array>;
3
+ export default crc16ccitt;
@@ -0,0 +1,3 @@
1
+ import { CRCCalculator } from '../types.js';
2
+ declare const crc16kermit: CRCCalculator<Uint8Array>;
3
+ export default crc16kermit;
@@ -0,0 +1,3 @@
1
+ import { CRCCalculator } from '../types.js';
2
+ declare const crc16modbus: CRCCalculator<Uint8Array>;
3
+ export default crc16modbus;
@@ -0,0 +1,3 @@
1
+ import { CRCCalculator } from '../types.js';
2
+ declare const crc16xmodem: CRCCalculator<Uint8Array>;
3
+ export default crc16xmodem;
@@ -0,0 +1,3 @@
1
+ import { CRCCalculator } from '../types.js';
2
+ declare const crc24: CRCCalculator<Uint8Array>;
3
+ export default crc24;
@@ -0,0 +1,3 @@
1
+ import { CRCCalculator } from '../types.js';
2
+ declare const crc32: CRCCalculator<Uint8Array>;
3
+ export default crc32;
@@ -0,0 +1,3 @@
1
+ import { CRCCalculator } from '../types.js';
2
+ declare const crc32mpeg: CRCCalculator<Uint8Array>;
3
+ export default crc32mpeg;
@@ -0,0 +1,3 @@
1
+ import { CRCCalculator } from '../types.js';
2
+ declare const crc32mpeg2: CRCCalculator<Uint8Array>;
3
+ export default crc32mpeg2;
@@ -0,0 +1,3 @@
1
+ import { CRCCalculator } from '../types.js';
2
+ declare const crc5: CRCCalculator<Uint8Array>;
3
+ export default crc5;
@@ -0,0 +1,3 @@
1
+ import { CRCCalculator } from '../types.js';
2
+ declare const crc8: CRCCalculator<Uint8Array>;
3
+ export default crc8;
@@ -0,0 +1,3 @@
1
+ import { CRCCalculator } from '../types.js';
2
+ declare const crc81wire: CRCCalculator<Uint8Array>;
3
+ export default crc81wire;
@@ -0,0 +1,3 @@
1
+ import { CRCCalculator } from '../types.js';
2
+ declare const crc8dvbs2: CRCCalculator<Uint8Array>;
3
+ export default crc8dvbs2;
@@ -0,0 +1,3 @@
1
+ import { CRCCalculator } from '../types.js';
2
+ declare const crcjam: CRCCalculator<Uint8Array>;
3
+ export default crcjam;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const crc1 = (current, previous = 0) => {
4
+ let crc = ~~previous;
5
+ let accum = 0;
6
+ for (let index = 0; index < current.length; index++) {
7
+ accum += current[index];
8
+ }
9
+ crc += accum % 256;
10
+ return crc % 256;
11
+ };
12
+ exports.default = crc1;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ // Generated by `./pycrc.py --algorithm=table-driven --model=crc-16 --generate=c`
4
+ let TABLE = [
5
+ 0x0000, 0xc0c1, 0xc181, 0x0140, 0xc301, 0x03c0, 0x0280, 0xc241, 0xc601, 0x06c0, 0x0780, 0xc741,
6
+ 0x0500, 0xc5c1, 0xc481, 0x0440, 0xcc01, 0x0cc0, 0x0d80, 0xcd41, 0x0f00, 0xcfc1, 0xce81, 0x0e40,
7
+ 0x0a00, 0xcac1, 0xcb81, 0x0b40, 0xc901, 0x09c0, 0x0880, 0xc841, 0xd801, 0x18c0, 0x1980, 0xd941,
8
+ 0x1b00, 0xdbc1, 0xda81, 0x1a40, 0x1e00, 0xdec1, 0xdf81, 0x1f40, 0xdd01, 0x1dc0, 0x1c80, 0xdc41,
9
+ 0x1400, 0xd4c1, 0xd581, 0x1540, 0xd701, 0x17c0, 0x1680, 0xd641, 0xd201, 0x12c0, 0x1380, 0xd341,
10
+ 0x1100, 0xd1c1, 0xd081, 0x1040, 0xf001, 0x30c0, 0x3180, 0xf141, 0x3300, 0xf3c1, 0xf281, 0x3240,
11
+ 0x3600, 0xf6c1, 0xf781, 0x3740, 0xf501, 0x35c0, 0x3480, 0xf441, 0x3c00, 0xfcc1, 0xfd81, 0x3d40,
12
+ 0xff01, 0x3fc0, 0x3e80, 0xfe41, 0xfa01, 0x3ac0, 0x3b80, 0xfb41, 0x3900, 0xf9c1, 0xf881, 0x3840,
13
+ 0x2800, 0xe8c1, 0xe981, 0x2940, 0xeb01, 0x2bc0, 0x2a80, 0xea41, 0xee01, 0x2ec0, 0x2f80, 0xef41,
14
+ 0x2d00, 0xedc1, 0xec81, 0x2c40, 0xe401, 0x24c0, 0x2580, 0xe541, 0x2700, 0xe7c1, 0xe681, 0x2640,
15
+ 0x2200, 0xe2c1, 0xe381, 0x2340, 0xe101, 0x21c0, 0x2080, 0xe041, 0xa001, 0x60c0, 0x6180, 0xa141,
16
+ 0x6300, 0xa3c1, 0xa281, 0x6240, 0x6600, 0xa6c1, 0xa781, 0x6740, 0xa501, 0x65c0, 0x6480, 0xa441,
17
+ 0x6c00, 0xacc1, 0xad81, 0x6d40, 0xaf01, 0x6fc0, 0x6e80, 0xae41, 0xaa01, 0x6ac0, 0x6b80, 0xab41,
18
+ 0x6900, 0xa9c1, 0xa881, 0x6840, 0x7800, 0xb8c1, 0xb981, 0x7940, 0xbb01, 0x7bc0, 0x7a80, 0xba41,
19
+ 0xbe01, 0x7ec0, 0x7f80, 0xbf41, 0x7d00, 0xbdc1, 0xbc81, 0x7c40, 0xb401, 0x74c0, 0x7580, 0xb541,
20
+ 0x7700, 0xb7c1, 0xb681, 0x7640, 0x7200, 0xb2c1, 0xb381, 0x7340, 0xb101, 0x71c0, 0x7080, 0xb041,
21
+ 0x5000, 0x90c1, 0x9181, 0x5140, 0x9301, 0x53c0, 0x5280, 0x9241, 0x9601, 0x56c0, 0x5780, 0x9741,
22
+ 0x5500, 0x95c1, 0x9481, 0x5440, 0x9c01, 0x5cc0, 0x5d80, 0x9d41, 0x5f00, 0x9fc1, 0x9e81, 0x5e40,
23
+ 0x5a00, 0x9ac1, 0x9b81, 0x5b40, 0x9901, 0x59c0, 0x5880, 0x9841, 0x8801, 0x48c0, 0x4980, 0x8941,
24
+ 0x4b00, 0x8bc1, 0x8a81, 0x4a40, 0x4e00, 0x8ec1, 0x8f81, 0x4f40, 0x8d01, 0x4dc0, 0x4c80, 0x8c41,
25
+ 0x4400, 0x84c1, 0x8581, 0x4540, 0x8701, 0x47c0, 0x4680, 0x8641, 0x8201, 0x42c0, 0x4380, 0x8341,
26
+ 0x4100, 0x81c1, 0x8081, 0x4040,
27
+ ];
28
+ if (typeof Int32Array !== 'undefined') {
29
+ TABLE = new Int32Array(TABLE);
30
+ }
31
+ const crc16 = (current, previous = 0) => {
32
+ let crc = ~~previous;
33
+ for (let index = 0; index < current.length; index++) {
34
+ crc = (TABLE[(crc ^ current[index]) & 0xff] ^ (crc >> 8)) & 0xffff;
35
+ }
36
+ return crc;
37
+ };
38
+ exports.default = crc16;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ // Generated by `./pycrc.py --algorithm=table-driven --model=ccitt --generate=c`
4
+ let TABLE = [
5
+ 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7, 0x8108, 0x9129, 0xa14a, 0xb16b,
6
+ 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef, 0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6,
7
+ 0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de, 0x2462, 0x3443, 0x0420, 0x1401,
8
+ 0x64e6, 0x74c7, 0x44a4, 0x5485, 0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d,
9
+ 0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4, 0xb75b, 0xa77a, 0x9719, 0x8738,
10
+ 0xf7df, 0xe7fe, 0xd79d, 0xc7bc, 0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823,
11
+ 0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b, 0x5af5, 0x4ad4, 0x7ab7, 0x6a96,
12
+ 0x1a71, 0x0a50, 0x3a33, 0x2a12, 0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a,
13
+ 0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41, 0xedae, 0xfd8f, 0xcdec, 0xddcd,
14
+ 0xad2a, 0xbd0b, 0x8d68, 0x9d49, 0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70,
15
+ 0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78, 0x9188, 0x81a9, 0xb1ca, 0xa1eb,
16
+ 0xd10c, 0xc12d, 0xf14e, 0xe16f, 0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067,
17
+ 0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e, 0x02b1, 0x1290, 0x22f3, 0x32d2,
18
+ 0x4235, 0x5214, 0x6277, 0x7256, 0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d,
19
+ 0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, 0xa7db, 0xb7fa, 0x8799, 0x97b8,
20
+ 0xe75f, 0xf77e, 0xc71d, 0xd73c, 0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634,
21
+ 0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab, 0x5844, 0x4865, 0x7806, 0x6827,
22
+ 0x18c0, 0x08e1, 0x3882, 0x28a3, 0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a,
23
+ 0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92, 0xfd2e, 0xed0f, 0xdd6c, 0xcd4d,
24
+ 0xbdaa, 0xad8b, 0x9de8, 0x8dc9, 0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1,
25
+ 0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8, 0x6e17, 0x7e36, 0x4e55, 0x5e74,
26
+ 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0,
27
+ ];
28
+ if (typeof Int32Array !== 'undefined') {
29
+ TABLE = new Int32Array(TABLE);
30
+ }
31
+ const crc16ccitt = (current, previous) => {
32
+ let crc = typeof previous !== 'undefined' ? ~~previous : 0xffff;
33
+ for (let index = 0; index < current.length; index++) {
34
+ crc = (TABLE[((crc >> 8) ^ current[index]) & 0xff] ^ (crc << 8)) & 0xffff;
35
+ }
36
+ return crc;
37
+ };
38
+ exports.default = crc16ccitt;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ // Generated by `./pycrc.py --algorithm=table-driven --model=kermit --generate=c`
4
+ let TABLE = [
5
+ 0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf, 0x8c48, 0x9dc1, 0xaf5a, 0xbed3,
6
+ 0xca6c, 0xdbe5, 0xe97e, 0xf8f7, 0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e,
7
+ 0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876, 0x2102, 0x308b, 0x0210, 0x1399,
8
+ 0x6726, 0x76af, 0x4434, 0x55bd, 0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5,
9
+ 0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c, 0xbdcb, 0xac42, 0x9ed9, 0x8f50,
10
+ 0xfbef, 0xea66, 0xd8fd, 0xc974, 0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb,
11
+ 0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3, 0x5285, 0x430c, 0x7197, 0x601e,
12
+ 0x14a1, 0x0528, 0x37b3, 0x263a, 0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72,
13
+ 0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9, 0xef4e, 0xfec7, 0xcc5c, 0xddd5,
14
+ 0xa96a, 0xb8e3, 0x8a78, 0x9bf1, 0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738,
15
+ 0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70, 0x8408, 0x9581, 0xa71a, 0xb693,
16
+ 0xc22c, 0xd3a5, 0xe13e, 0xf0b7, 0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff,
17
+ 0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036, 0x18c1, 0x0948, 0x3bd3, 0x2a5a,
18
+ 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e, 0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5,
19
+ 0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd, 0xb58b, 0xa402, 0x9699, 0x8710,
20
+ 0xf3af, 0xe226, 0xd0bd, 0xc134, 0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c,
21
+ 0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3, 0x4a44, 0x5bcd, 0x6956, 0x78df,
22
+ 0x0c60, 0x1de9, 0x2f72, 0x3efb, 0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232,
23
+ 0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a, 0xe70e, 0xf687, 0xc41c, 0xd595,
24
+ 0xa12a, 0xb0a3, 0x8238, 0x93b1, 0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9,
25
+ 0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330, 0x7bc7, 0x6a4e, 0x58d5, 0x495c,
26
+ 0x3de3, 0x2c6a, 0x1ef1, 0x0f78,
27
+ ];
28
+ if (typeof Int32Array !== 'undefined') {
29
+ TABLE = new Int32Array(TABLE);
30
+ }
31
+ const crc16kermit = (current, previous) => {
32
+ let crc = typeof previous !== 'undefined' ? ~~previous : 0x0000;
33
+ for (let index = 0; index < current.length; index++) {
34
+ crc = (TABLE[(crc ^ current[index]) & 0xff] ^ (crc >> 8)) & 0xffff;
35
+ }
36
+ return crc;
37
+ };
38
+ exports.default = crc16kermit;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ // Generated by `./pycrc.py --algorithm=table-driven --model=crc-16-modbus --generate=c`
4
+ let TABLE = [
5
+ 0x0000, 0xc0c1, 0xc181, 0x0140, 0xc301, 0x03c0, 0x0280, 0xc241, 0xc601, 0x06c0, 0x0780, 0xc741,
6
+ 0x0500, 0xc5c1, 0xc481, 0x0440, 0xcc01, 0x0cc0, 0x0d80, 0xcd41, 0x0f00, 0xcfc1, 0xce81, 0x0e40,
7
+ 0x0a00, 0xcac1, 0xcb81, 0x0b40, 0xc901, 0x09c0, 0x0880, 0xc841, 0xd801, 0x18c0, 0x1980, 0xd941,
8
+ 0x1b00, 0xdbc1, 0xda81, 0x1a40, 0x1e00, 0xdec1, 0xdf81, 0x1f40, 0xdd01, 0x1dc0, 0x1c80, 0xdc41,
9
+ 0x1400, 0xd4c1, 0xd581, 0x1540, 0xd701, 0x17c0, 0x1680, 0xd641, 0xd201, 0x12c0, 0x1380, 0xd341,
10
+ 0x1100, 0xd1c1, 0xd081, 0x1040, 0xf001, 0x30c0, 0x3180, 0xf141, 0x3300, 0xf3c1, 0xf281, 0x3240,
11
+ 0x3600, 0xf6c1, 0xf781, 0x3740, 0xf501, 0x35c0, 0x3480, 0xf441, 0x3c00, 0xfcc1, 0xfd81, 0x3d40,
12
+ 0xff01, 0x3fc0, 0x3e80, 0xfe41, 0xfa01, 0x3ac0, 0x3b80, 0xfb41, 0x3900, 0xf9c1, 0xf881, 0x3840,
13
+ 0x2800, 0xe8c1, 0xe981, 0x2940, 0xeb01, 0x2bc0, 0x2a80, 0xea41, 0xee01, 0x2ec0, 0x2f80, 0xef41,
14
+ 0x2d00, 0xedc1, 0xec81, 0x2c40, 0xe401, 0x24c0, 0x2580, 0xe541, 0x2700, 0xe7c1, 0xe681, 0x2640,
15
+ 0x2200, 0xe2c1, 0xe381, 0x2340, 0xe101, 0x21c0, 0x2080, 0xe041, 0xa001, 0x60c0, 0x6180, 0xa141,
16
+ 0x6300, 0xa3c1, 0xa281, 0x6240, 0x6600, 0xa6c1, 0xa781, 0x6740, 0xa501, 0x65c0, 0x6480, 0xa441,
17
+ 0x6c00, 0xacc1, 0xad81, 0x6d40, 0xaf01, 0x6fc0, 0x6e80, 0xae41, 0xaa01, 0x6ac0, 0x6b80, 0xab41,
18
+ 0x6900, 0xa9c1, 0xa881, 0x6840, 0x7800, 0xb8c1, 0xb981, 0x7940, 0xbb01, 0x7bc0, 0x7a80, 0xba41,
19
+ 0xbe01, 0x7ec0, 0x7f80, 0xbf41, 0x7d00, 0xbdc1, 0xbc81, 0x7c40, 0xb401, 0x74c0, 0x7580, 0xb541,
20
+ 0x7700, 0xb7c1, 0xb681, 0x7640, 0x7200, 0xb2c1, 0xb381, 0x7340, 0xb101, 0x71c0, 0x7080, 0xb041,
21
+ 0x5000, 0x90c1, 0x9181, 0x5140, 0x9301, 0x53c0, 0x5280, 0x9241, 0x9601, 0x56c0, 0x5780, 0x9741,
22
+ 0x5500, 0x95c1, 0x9481, 0x5440, 0x9c01, 0x5cc0, 0x5d80, 0x9d41, 0x5f00, 0x9fc1, 0x9e81, 0x5e40,
23
+ 0x5a00, 0x9ac1, 0x9b81, 0x5b40, 0x9901, 0x59c0, 0x5880, 0x9841, 0x8801, 0x48c0, 0x4980, 0x8941,
24
+ 0x4b00, 0x8bc1, 0x8a81, 0x4a40, 0x4e00, 0x8ec1, 0x8f81, 0x4f40, 0x8d01, 0x4dc0, 0x4c80, 0x8c41,
25
+ 0x4400, 0x84c1, 0x8581, 0x4540, 0x8701, 0x47c0, 0x4680, 0x8641, 0x8201, 0x42c0, 0x4380, 0x8341,
26
+ 0x4100, 0x81c1, 0x8081, 0x4040,
27
+ ];
28
+ if (typeof Int32Array !== 'undefined') {
29
+ TABLE = new Int32Array(TABLE);
30
+ }
31
+ const crc16modbus = (current, previous) => {
32
+ let crc = typeof previous !== 'undefined' ? ~~previous : 0xffff;
33
+ for (let index = 0; index < current.length; index++) {
34
+ crc = (TABLE[(crc ^ current[index]) & 0xff] ^ (crc >> 8)) & 0xffff;
35
+ }
36
+ return crc;
37
+ };
38
+ exports.default = crc16modbus;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const crc16xmodem = (current, previous) => {
4
+ let crc = typeof previous !== 'undefined' ? ~~previous : 0x0;
5
+ for (let index = 0; index < current.length; index++) {
6
+ let code = (crc >>> 8) & 0xff;
7
+ code ^= current[index] & 0xff;
8
+ code ^= code >>> 4;
9
+ crc = (crc << 8) & 0xffff;
10
+ crc ^= code;
11
+ code = (code << 5) & 0xffff;
12
+ crc ^= code;
13
+ code = (code << 7) & 0xffff;
14
+ crc ^= code;
15
+ }
16
+ return crc;
17
+ };
18
+ exports.default = crc16xmodem;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ // Generated by `./pycrc.py --algorithm=table-drive --model=crc-24 --generate=c`
4
+ let TABLE = [
5
+ 0x000000, 0x864cfb, 0x8ad50d, 0x0c99f6, 0x93e6e1, 0x15aa1a, 0x1933ec, 0x9f7f17, 0xa18139,
6
+ 0x27cdc2, 0x2b5434, 0xad18cf, 0x3267d8, 0xb42b23, 0xb8b2d5, 0x3efe2e, 0xc54e89, 0x430272,
7
+ 0x4f9b84, 0xc9d77f, 0x56a868, 0xd0e493, 0xdc7d65, 0x5a319e, 0x64cfb0, 0xe2834b, 0xee1abd,
8
+ 0x685646, 0xf72951, 0x7165aa, 0x7dfc5c, 0xfbb0a7, 0x0cd1e9, 0x8a9d12, 0x8604e4, 0x00481f,
9
+ 0x9f3708, 0x197bf3, 0x15e205, 0x93aefe, 0xad50d0, 0x2b1c2b, 0x2785dd, 0xa1c926, 0x3eb631,
10
+ 0xb8faca, 0xb4633c, 0x322fc7, 0xc99f60, 0x4fd39b, 0x434a6d, 0xc50696, 0x5a7981, 0xdc357a,
11
+ 0xd0ac8c, 0x56e077, 0x681e59, 0xee52a2, 0xe2cb54, 0x6487af, 0xfbf8b8, 0x7db443, 0x712db5,
12
+ 0xf7614e, 0x19a3d2, 0x9fef29, 0x9376df, 0x153a24, 0x8a4533, 0x0c09c8, 0x00903e, 0x86dcc5,
13
+ 0xb822eb, 0x3e6e10, 0x32f7e6, 0xb4bb1d, 0x2bc40a, 0xad88f1, 0xa11107, 0x275dfc, 0xdced5b,
14
+ 0x5aa1a0, 0x563856, 0xd074ad, 0x4f0bba, 0xc94741, 0xc5deb7, 0x43924c, 0x7d6c62, 0xfb2099,
15
+ 0xf7b96f, 0x71f594, 0xee8a83, 0x68c678, 0x645f8e, 0xe21375, 0x15723b, 0x933ec0, 0x9fa736,
16
+ 0x19ebcd, 0x8694da, 0x00d821, 0x0c41d7, 0x8a0d2c, 0xb4f302, 0x32bff9, 0x3e260f, 0xb86af4,
17
+ 0x2715e3, 0xa15918, 0xadc0ee, 0x2b8c15, 0xd03cb2, 0x567049, 0x5ae9bf, 0xdca544, 0x43da53,
18
+ 0xc596a8, 0xc90f5e, 0x4f43a5, 0x71bd8b, 0xf7f170, 0xfb6886, 0x7d247d, 0xe25b6a, 0x641791,
19
+ 0x688e67, 0xeec29c, 0x3347a4, 0xb50b5f, 0xb992a9, 0x3fde52, 0xa0a145, 0x26edbe, 0x2a7448,
20
+ 0xac38b3, 0x92c69d, 0x148a66, 0x181390, 0x9e5f6b, 0x01207c, 0x876c87, 0x8bf571, 0x0db98a,
21
+ 0xf6092d, 0x7045d6, 0x7cdc20, 0xfa90db, 0x65efcc, 0xe3a337, 0xef3ac1, 0x69763a, 0x578814,
22
+ 0xd1c4ef, 0xdd5d19, 0x5b11e2, 0xc46ef5, 0x42220e, 0x4ebbf8, 0xc8f703, 0x3f964d, 0xb9dab6,
23
+ 0xb54340, 0x330fbb, 0xac70ac, 0x2a3c57, 0x26a5a1, 0xa0e95a, 0x9e1774, 0x185b8f, 0x14c279,
24
+ 0x928e82, 0x0df195, 0x8bbd6e, 0x872498, 0x016863, 0xfad8c4, 0x7c943f, 0x700dc9, 0xf64132,
25
+ 0x693e25, 0xef72de, 0xe3eb28, 0x65a7d3, 0x5b59fd, 0xdd1506, 0xd18cf0, 0x57c00b, 0xc8bf1c,
26
+ 0x4ef3e7, 0x426a11, 0xc426ea, 0x2ae476, 0xaca88d, 0xa0317b, 0x267d80, 0xb90297, 0x3f4e6c,
27
+ 0x33d79a, 0xb59b61, 0x8b654f, 0x0d29b4, 0x01b042, 0x87fcb9, 0x1883ae, 0x9ecf55, 0x9256a3,
28
+ 0x141a58, 0xefaaff, 0x69e604, 0x657ff2, 0xe33309, 0x7c4c1e, 0xfa00e5, 0xf69913, 0x70d5e8,
29
+ 0x4e2bc6, 0xc8673d, 0xc4fecb, 0x42b230, 0xddcd27, 0x5b81dc, 0x57182a, 0xd154d1, 0x26359f,
30
+ 0xa07964, 0xace092, 0x2aac69, 0xb5d37e, 0x339f85, 0x3f0673, 0xb94a88, 0x87b4a6, 0x01f85d,
31
+ 0x0d61ab, 0x8b2d50, 0x145247, 0x921ebc, 0x9e874a, 0x18cbb1, 0xe37b16, 0x6537ed, 0x69ae1b,
32
+ 0xefe2e0, 0x709df7, 0xf6d10c, 0xfa48fa, 0x7c0401, 0x42fa2f, 0xc4b6d4, 0xc82f22, 0x4e63d9,
33
+ 0xd11cce, 0x575035, 0x5bc9c3, 0xdd8538,
34
+ ];
35
+ if (typeof Int32Array !== 'undefined') {
36
+ TABLE = new Int32Array(TABLE);
37
+ }
38
+ const crc24 = (current, previous) => {
39
+ let crc = typeof previous !== 'undefined' ? ~~previous : 0xb704ce;
40
+ for (let index = 0; index < current.length; index++) {
41
+ crc = (TABLE[((crc >> 16) ^ current[index]) & 0xff] ^ (crc << 8)) & 0xffffff;
42
+ }
43
+ return crc;
44
+ };
45
+ exports.default = crc24;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ // Generated by `./pycrc.py --algorithm=table-driven --model=crc-32 --generate=c`
4
+ let TABLE = [
5
+ 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
6
+ 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,
7
+ 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
8
+ 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5,
9
+ 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
10
+ 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
11
+ 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f,
12
+ 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d,
13
+ 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
14
+ 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
15
+ 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457,
16
+ 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
17
+ 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb,
18
+ 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9,
19
+ 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
20
+ 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad,
21
+ 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683,
22
+ 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
23
+ 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7,
24
+ 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
25
+ 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
26
+ 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79,
27
+ 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f,
28
+ 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
29
+ 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
30
+ 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21,
31
+ 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
32
+ 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45,
33
+ 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db,
34
+ 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
35
+ 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf,
36
+ 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d,
37
+ ];
38
+ if (typeof Int32Array !== 'undefined') {
39
+ TABLE = new Int32Array(TABLE);
40
+ }
41
+ const crc32 = (current, previous) => {
42
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
43
+ let crc = previous === 0 ? 0 : ~~previous ^ -1;
44
+ for (let index = 0; index < current.length; index++) {
45
+ crc = TABLE[(crc ^ current[index]) & 0xff] ^ (crc >>> 8);
46
+ }
47
+ return crc ^ -1;
48
+ };
49
+ exports.default = crc32;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ // Generated by `./pycrc.py --algorithm=table-driven --model=crc-32-mpeg --generate=c`
4
+ let TABLE = [
5
+ 0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b, 0x1a864db2, 0x1e475005,
6
+ 0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61, 0x350c9b64, 0x31cd86d3, 0x3c8ea00a, 0x384fbdbd,
7
+ 0x4c11db70, 0x48d0c6c7, 0x4593e01e, 0x4152fda9, 0x5f15adac, 0x5bd4b01b, 0x569796c2, 0x52568b75,
8
+ 0x6a1936c8, 0x6ed82b7f, 0x639b0da6, 0x675a1011, 0x791d4014, 0x7ddc5da3, 0x709f7b7a, 0x745e66cd,
9
+ 0x9823b6e0, 0x9ce2ab57, 0x91a18d8e, 0x95609039, 0x8b27c03c, 0x8fe6dd8b, 0x82a5fb52, 0x8664e6e5,
10
+ 0xbe2b5b58, 0xbaea46ef, 0xb7a96036, 0xb3687d81, 0xad2f2d84, 0xa9ee3033, 0xa4ad16ea, 0xa06c0b5d,
11
+ 0xd4326d90, 0xd0f37027, 0xddb056fe, 0xd9714b49, 0xc7361b4c, 0xc3f706fb, 0xceb42022, 0xca753d95,
12
+ 0xf23a8028, 0xf6fb9d9f, 0xfbb8bb46, 0xff79a6f1, 0xe13ef6f4, 0xe5ffeb43, 0xe8bccd9a, 0xec7dd02d,
13
+ 0x34867077, 0x30476dc0, 0x3d044b19, 0x39c556ae, 0x278206ab, 0x23431b1c, 0x2e003dc5, 0x2ac12072,
14
+ 0x128e9dcf, 0x164f8078, 0x1b0ca6a1, 0x1fcdbb16, 0x018aeb13, 0x054bf6a4, 0x0808d07d, 0x0cc9cdca,
15
+ 0x7897ab07, 0x7c56b6b0, 0x71159069, 0x75d48dde, 0x6b93dddb, 0x6f52c06c, 0x6211e6b5, 0x66d0fb02,
16
+ 0x5e9f46bf, 0x5a5e5b08, 0x571d7dd1, 0x53dc6066, 0x4d9b3063, 0x495a2dd4, 0x44190b0d, 0x40d816ba,
17
+ 0xaca5c697, 0xa864db20, 0xa527fdf9, 0xa1e6e04e, 0xbfa1b04b, 0xbb60adfc, 0xb6238b25, 0xb2e29692,
18
+ 0x8aad2b2f, 0x8e6c3698, 0x832f1041, 0x87ee0df6, 0x99a95df3, 0x9d684044, 0x902b669d, 0x94ea7b2a,
19
+ 0xe0b41de7, 0xe4750050, 0xe9362689, 0xedf73b3e, 0xf3b06b3b, 0xf771768c, 0xfa325055, 0xfef34de2,
20
+ 0xc6bcf05f, 0xc27dede8, 0xcf3ecb31, 0xcbffd686, 0xd5b88683, 0xd1799b34, 0xdc3abded, 0xd8fba05a,
21
+ 0x690ce0ee, 0x6dcdfd59, 0x608edb80, 0x644fc637, 0x7a089632, 0x7ec98b85, 0x738aad5c, 0x774bb0eb,
22
+ 0x4f040d56, 0x4bc510e1, 0x46863638, 0x42472b8f, 0x5c007b8a, 0x58c1663d, 0x558240e4, 0x51435d53,
23
+ 0x251d3b9e, 0x21dc2629, 0x2c9f00f0, 0x285e1d47, 0x36194d42, 0x32d850f5, 0x3f9b762c, 0x3b5a6b9b,
24
+ 0x0315d626, 0x07d4cb91, 0x0a97ed48, 0x0e56f0ff, 0x1011a0fa, 0x14d0bd4d, 0x19939b94, 0x1d528623,
25
+ 0xf12f560e, 0xf5ee4bb9, 0xf8ad6d60, 0xfc6c70d7, 0xe22b20d2, 0xe6ea3d65, 0xeba91bbc, 0xef68060b,
26
+ 0xd727bbb6, 0xd3e6a601, 0xdea580d8, 0xda649d6f, 0xc423cd6a, 0xc0e2d0dd, 0xcda1f604, 0xc960ebb3,
27
+ 0xbd3e8d7e, 0xb9ff90c9, 0xb4bcb610, 0xb07daba7, 0xae3afba2, 0xaafbe615, 0xa7b8c0cc, 0xa379dd7b,
28
+ 0x9b3660c6, 0x9ff77d71, 0x92b45ba8, 0x9675461f, 0x8832161a, 0x8cf30bad, 0x81b02d74, 0x857130c3,
29
+ 0x5d8a9099, 0x594b8d2e, 0x5408abf7, 0x50c9b640, 0x4e8ee645, 0x4a4ffbf2, 0x470cdd2b, 0x43cdc09c,
30
+ 0x7b827d21, 0x7f436096, 0x7200464f, 0x76c15bf8, 0x68860bfd, 0x6c47164a, 0x61043093, 0x65c52d24,
31
+ 0x119b4be9, 0x155a565e, 0x18197087, 0x1cd86d30, 0x029f3d35, 0x065e2082, 0x0b1d065b, 0x0fdc1bec,
32
+ 0x3793a651, 0x3352bbe6, 0x3e119d3f, 0x3ad08088, 0x2497d08d, 0x2056cd3a, 0x2d15ebe3, 0x29d4f654,
33
+ 0xc5a92679, 0xc1683bce, 0xcc2b1d17, 0xc8ea00a0, 0xd6ad50a5, 0xd26c4d12, 0xdf2f6bcb, 0xdbee767c,
34
+ 0xe3a1cbc1, 0xe760d676, 0xea23f0af, 0xeee2ed18, 0xf0a5bd1d, 0xf464a0aa, 0xf9278673, 0xfde69bc4,
35
+ 0x89b8fd09, 0x8d79e0be, 0x803ac667, 0x84fbdbd0, 0x9abc8bd5, 0x9e7d9662, 0x933eb0bb, 0x97ffad0c,
36
+ 0xafb010b1, 0xab710d06, 0xa6322bdf, 0xa2f33668, 0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4,
37
+ ];
38
+ if (typeof Int32Array !== 'undefined') {
39
+ TABLE = new Int32Array(TABLE);
40
+ }
41
+ const crc32mpeg2 = (current, previous) => {
42
+ let crc = typeof previous !== 'undefined' ? ~~previous : 0xffffffff;
43
+ for (let index = 0; index < current.length; index++) {
44
+ crc = TABLE[((crc >> 24) ^ current[index]) & 0xff] ^ (crc << 8);
45
+ }
46
+ return crc;
47
+ };
48
+ exports.default = crc32mpeg2;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ // Generated by `./pycrc.py --algorithm=table-driven --model=crc-5 --generate=c`
4
+ let TABLE = [
5
+ 0x00, 0x70, 0xe0, 0x90, 0x88, 0xf8, 0x68, 0x18, 0x58, 0x28, 0xb8, 0xc8, 0xd0, 0xa0, 0x30, 0x40,
6
+ 0xb0, 0xc0, 0x50, 0x20, 0x38, 0x48, 0xd8, 0xa8, 0xe8, 0x98, 0x08, 0x78, 0x60, 0x10, 0x80, 0xf0,
7
+ 0x28, 0x58, 0xc8, 0xb8, 0xa0, 0xd0, 0x40, 0x30, 0x70, 0x00, 0x90, 0xe0, 0xf8, 0x88, 0x18, 0x68,
8
+ 0x98, 0xe8, 0x78, 0x08, 0x10, 0x60, 0xf0, 0x80, 0xc0, 0xb0, 0x20, 0x50, 0x48, 0x38, 0xa8, 0xd8,
9
+ 0x50, 0x20, 0xb0, 0xc0, 0xd8, 0xa8, 0x38, 0x48, 0x08, 0x78, 0xe8, 0x98, 0x80, 0xf0, 0x60, 0x10,
10
+ 0xe0, 0x90, 0x00, 0x70, 0x68, 0x18, 0x88, 0xf8, 0xb8, 0xc8, 0x58, 0x28, 0x30, 0x40, 0xd0, 0xa0,
11
+ 0x78, 0x08, 0x98, 0xe8, 0xf0, 0x80, 0x10, 0x60, 0x20, 0x50, 0xc0, 0xb0, 0xa8, 0xd8, 0x48, 0x38,
12
+ 0xc8, 0xb8, 0x28, 0x58, 0x40, 0x30, 0xa0, 0xd0, 0x90, 0xe0, 0x70, 0x00, 0x18, 0x68, 0xf8, 0x88,
13
+ 0xa0, 0xd0, 0x40, 0x30, 0x28, 0x58, 0xc8, 0xb8, 0xf8, 0x88, 0x18, 0x68, 0x70, 0x00, 0x90, 0xe0,
14
+ 0x10, 0x60, 0xf0, 0x80, 0x98, 0xe8, 0x78, 0x08, 0x48, 0x38, 0xa8, 0xd8, 0xc0, 0xb0, 0x20, 0x50,
15
+ 0x88, 0xf8, 0x68, 0x18, 0x00, 0x70, 0xe0, 0x90, 0xd0, 0xa0, 0x30, 0x40, 0x58, 0x28, 0xb8, 0xc8,
16
+ 0x38, 0x48, 0xd8, 0xa8, 0xb0, 0xc0, 0x50, 0x20, 0x60, 0x10, 0x80, 0xf0, 0xe8, 0x98, 0x08, 0x78,
17
+ 0xf0, 0x80, 0x10, 0x60, 0x78, 0x08, 0x98, 0xe8, 0xa8, 0xd8, 0x48, 0x38, 0x20, 0x50, 0xc0, 0xb0,
18
+ 0x40, 0x30, 0xa0, 0xd0, 0xc8, 0xb8, 0x28, 0x58, 0x18, 0x68, 0xf8, 0x88, 0x90, 0xe0, 0x70, 0x00,
19
+ 0xd8, 0xa8, 0x38, 0x48, 0x50, 0x20, 0xb0, 0xc0, 0x80, 0xf0, 0x60, 0x10, 0x08, 0x78, 0xe8, 0x98,
20
+ 0x68, 0x18, 0x88, 0xf8, 0xe0, 0x90, 0x00, 0x70, 0x30, 0x40, 0xd0, 0xa0, 0xb8, 0xc8, 0x58, 0x28,
21
+ ];
22
+ if (typeof Uint8Array !== 'undefined') {
23
+ TABLE = new Uint8Array(TABLE);
24
+ }
25
+ // https://github.com/postmodern/digest-crc/blob/main/lib/digest/crc5.rb
26
+ const XOR_MASK = 0x1f;
27
+ const CRC_MASK = 0x1f << 3;
28
+ const crc5 = (current, previous = 0x1f) => {
29
+ let crc = previous;
30
+ for (let index = 0; index < current.length; index++) {
31
+ const byte = current[index];
32
+ crc = (TABLE[((crc >> 3) ^ byte) & 0xff] ^ (crc >> 8)) & CRC_MASK;
33
+ }
34
+ return (crc & CRC_MASK) ^ XOR_MASK;
35
+ return (crc ^ XOR_MASK) & CRC_MASK;
36
+ };
37
+ exports.default = crc5;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ // Generated by `./pycrc.py --algorithm=table-driven --model=crc-8 --generate=c`
4
+ let TABLE = [
5
+ 0x00, 0x07, 0x0e, 0x09, 0x1c, 0x1b, 0x12, 0x15, 0x38, 0x3f, 0x36, 0x31, 0x24, 0x23, 0x2a, 0x2d,
6
+ 0x70, 0x77, 0x7e, 0x79, 0x6c, 0x6b, 0x62, 0x65, 0x48, 0x4f, 0x46, 0x41, 0x54, 0x53, 0x5a, 0x5d,
7
+ 0xe0, 0xe7, 0xee, 0xe9, 0xfc, 0xfb, 0xf2, 0xf5, 0xd8, 0xdf, 0xd6, 0xd1, 0xc4, 0xc3, 0xca, 0xcd,
8
+ 0x90, 0x97, 0x9e, 0x99, 0x8c, 0x8b, 0x82, 0x85, 0xa8, 0xaf, 0xa6, 0xa1, 0xb4, 0xb3, 0xba, 0xbd,
9
+ 0xc7, 0xc0, 0xc9, 0xce, 0xdb, 0xdc, 0xd5, 0xd2, 0xff, 0xf8, 0xf1, 0xf6, 0xe3, 0xe4, 0xed, 0xea,
10
+ 0xb7, 0xb0, 0xb9, 0xbe, 0xab, 0xac, 0xa5, 0xa2, 0x8f, 0x88, 0x81, 0x86, 0x93, 0x94, 0x9d, 0x9a,
11
+ 0x27, 0x20, 0x29, 0x2e, 0x3b, 0x3c, 0x35, 0x32, 0x1f, 0x18, 0x11, 0x16, 0x03, 0x04, 0x0d, 0x0a,
12
+ 0x57, 0x50, 0x59, 0x5e, 0x4b, 0x4c, 0x45, 0x42, 0x6f, 0x68, 0x61, 0x66, 0x73, 0x74, 0x7d, 0x7a,
13
+ 0x89, 0x8e, 0x87, 0x80, 0x95, 0x92, 0x9b, 0x9c, 0xb1, 0xb6, 0xbf, 0xb8, 0xad, 0xaa, 0xa3, 0xa4,
14
+ 0xf9, 0xfe, 0xf7, 0xf0, 0xe5, 0xe2, 0xeb, 0xec, 0xc1, 0xc6, 0xcf, 0xc8, 0xdd, 0xda, 0xd3, 0xd4,
15
+ 0x69, 0x6e, 0x67, 0x60, 0x75, 0x72, 0x7b, 0x7c, 0x51, 0x56, 0x5f, 0x58, 0x4d, 0x4a, 0x43, 0x44,
16
+ 0x19, 0x1e, 0x17, 0x10, 0x05, 0x02, 0x0b, 0x0c, 0x21, 0x26, 0x2f, 0x28, 0x3d, 0x3a, 0x33, 0x34,
17
+ 0x4e, 0x49, 0x40, 0x47, 0x52, 0x55, 0x5c, 0x5b, 0x76, 0x71, 0x78, 0x7f, 0x6a, 0x6d, 0x64, 0x63,
18
+ 0x3e, 0x39, 0x30, 0x37, 0x22, 0x25, 0x2c, 0x2b, 0x06, 0x01, 0x08, 0x0f, 0x1a, 0x1d, 0x14, 0x13,
19
+ 0xae, 0xa9, 0xa0, 0xa7, 0xb2, 0xb5, 0xbc, 0xbb, 0x96, 0x91, 0x98, 0x9f, 0x8a, 0x8d, 0x84, 0x83,
20
+ 0xde, 0xd9, 0xd0, 0xd7, 0xc2, 0xc5, 0xcc, 0xcb, 0xe6, 0xe1, 0xe8, 0xef, 0xfa, 0xfd, 0xf4, 0xf3,
21
+ ];
22
+ if (typeof Int32Array !== 'undefined') {
23
+ TABLE = new Int32Array(TABLE);
24
+ }
25
+ const crc8 = (current, previous = 0) => {
26
+ let crc = ~~previous;
27
+ for (let index = 0; index < current.length; index++) {
28
+ crc = TABLE[(crc ^ current[index]) & 0xff] & 0xff;
29
+ }
30
+ return crc;
31
+ };
32
+ exports.default = crc8;