MCPcopy Index your code
hub / github.com/Moddable-OpenSource/moddable / hexChecksum

Method hexChecksum

tools/mchex.js:84–96  ·  view source on GitHub ↗
(s)

Source from the content-addressed store, hash-verified

82 }
83
84 hexChecksum(s) {
85 if (s[0] != ':')
86 throw new Error("checksum for '" + s + "' failed: no initial :");
87
88 let accum = 0;
89 for (let i=0; i<(s.length-1)/2; i++) {
90 let chunk = s.slice(i*2+1, i*2+3);
91 accum += parseInt(chunk, 16);
92 }
93
94 let twoC = ((~(accum-1)) & 0xff);
95 return ("00" + twoC.toString(16)).slice(-2).toUpperCase();
96 }
97
98 generateSegment(addr) {
99 this.currentSegment = (addr & 0xffff0000);

Callers 2

generateSegmentMethod · 0.80
runMethod · 0.80

Calls 2

sliceMethod · 0.65
toStringMethod · 0.45

Tested by

no test coverage detected