MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / checksum

Method checksum

modules/network/ping/ping.js:110–117  ·  view source on GitHub ↗
(values)

Source from the content-addressed store, hash-verified

108 }
109
110 static checksum(values) {
111 let sum = 0;
112 for (let i=0; i<values.length; i+=2) {
113 sum += (values[i] << 8) + values[i+1];
114 }
115 sum += (sum >> 16);
116 return ~sum & 0xFFFF;
117 }
118 static validate_checksum(identifier, seqNumber, checksum) {
119 let sum = 191232; // sum of packet bytes (0x08, 0x09...0x37)
120 sum += identifier + seqNumber;

Callers 1

pingMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected