Derived from pycrc16 library implementation (Link)
For using in Node.js and Browser No dependency needed Tested and worked in Node 12, Chrome 83 (Not tested in JS import yet).
Step 1: Load script via Require / Browser script tag
// For node.js
const crc16xmodem = require('crc16-xmodem');
<!-- For browser -->
<script src="[path-to-file]/bundle.js"></script>
<script>
// Should return type object if working
console.log(typeof crc16xmodem);
</script>
Step 2: Methods
// Calculate checksum with 4 digit hex output
const originalStr = '00020101021129370016A000000677010111011300660000000005802TH53037646304';
console.log(crc16xmodem.calculateChecksum(originalStr));
// Result: 8956
// Validate from last 4 digit hex checksum
const fullStr = '00020101021129370016A000000677010111011300660000000005802TH530376463048956';
console.log(crc16xmodem.validateChecksum(fullStr));
// Result: true
// or just crc16 input string with custom initial value like 0
crc16xmodem.crc16(str, initialValue);