You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `CRC8` and `CRC16` functions take a number of options used to specify the CRC checksum to calculate.
116
+
117
+
| Parameter | Default | Description |
118
+
| :---: | :---: | :--- |
119
+
|`polynomial`| (none) | Polynomial to use (required) |
120
+
|`initial`|`0`| Initial CRC accumulator value (optional) |
121
+
|`reflectInput`|`false`| If `true`, each input byte is reflected (bits used in reverse order) before being used (optional) |
122
+
|`reflectOutput`|`false`| If `true`, each output byte is reflected before being returned. The output reflection is done over the whole CRC value (optional) |
123
+
|`xorOutput`|`0`| Value to XOR to the final CRC value (optional) |
124
+
125
+
The `polynomial`, `initial` and `xorOutput` values are 8-bit integers for CRC8 and 16-bit integers for CRC16.
126
+
127
+
The [crc example](https://github.com/Moddable-OpenSource/moddable/blob/public/examples/data/crc/main.js) demonstrates the definition of the parameters for a number of common CRC checksums:
128
+
129
+
-`CRC-8`
130
+
-`CRC-8/CDMA2000`
131
+
-`CRC-8/DARC`
132
+
-`CRC-8/DVB-S2`
133
+
-`CRC-8/EBU`
134
+
-`CRC-8/I-CODE`
135
+
-`CRC-8/ITU`
136
+
-`CRC-8/MAXIM`
137
+
-`CRC-8/ROHC`
138
+
-`CRC-8/WCDM`
139
+
-`CRC-16/CCITT-FALSE`
140
+
-`CRC-16/ARC`
141
+
-`CRC-16/ARG-CCITT`
142
+
-`CRC-16/BUYPASS`
143
+
-`CRC-16/CDMA2000`
144
+
-`CRC-16/DDS-110`
145
+
-`CRC-16/DECT-R`
146
+
-`CRC-16/DECT-X`
147
+
-`CRC-16/DNP`
148
+
-`CRC-16/EN-13757`
149
+
-`CRC-16/GENIBUS`
150
+
-`CRC-16/MAXIM`
151
+
-`CRC-16/MCRF4XX`
152
+
-`CRC-16/RIELLO`
153
+
-`CRC-16/T10-DIF`
154
+
-`CRC-16/TELEDISK`
155
+
-`CRC-16/TMS37157`
156
+
-`CRC-16/USB`
157
+
-`CRC-A`
158
+
-`CRC-16/KERMIT`
159
+
-`CRC-16/MODBUS`
160
+
-`CRC-16/X-25`
161
+
-`CRC-16/XMODE`
162
+
163
+
164
+
### `close()`
165
+
166
+
The `close` function frees resources associated with the CRC checksum calculation.
167
+
168
+
### `checksum(buffer)`
169
+
170
+
The `checksum` function applies the CRC calculation to the data provided in `buffer`. The CRC checksum is returned.
171
+
172
+
The `buffer` parameter may be a `String` or buffer.
173
+
174
+
The `checksum` function may be called multiple times. Each time it is called the CRC updated and returned. Call the `reset` function to start a new calculation.
175
+
176
+
### `reset()`
177
+
178
+
The `reset` function clears the CRC accumulator to the `initial` value.
179
+
93
180
<aid="qrcode"></a>
94
181
## class QRCode
95
182
The `QRCode` class generates QR Code data from Strings and buffers. The data may then be rendering in various ways. Extensions are provided to [Poco](https://github.com/Moddable-OpenSource/moddable/tree/public/modules/commodetto/qrcode) and [Piu](https://github.com/Moddable-OpenSource/moddable/tree/public/modules/piu/MC/qrcode) to efficiently render QR Codes. The core implementation is the QR Code Generator Library from [Project Nayuki](https://www.nayuki.io/page/qr-code-generator-library).
@@ -98,7 +185,7 @@ The `QRCode` class generates QR Code data from Strings and buffers. The data may
98
185
importqrCodefrom"qrcode";
99
186
```
100
187
101
-
Include the modules' manifest to use them in a project:
188
+
Include the module's manifest to use them in a project:
0 commit comments