Archived
1
0
Fork 0
This repository has been archived on 2019-02-05. You can view files and clone it, but cannot push or open issues or pull requests.
Pong/node_modules/crc/lib/crc1.js
2017-01-20 23:42:49 +01:00

21 lines
448 B
JavaScript

// Generated by CoffeeScript 1.7.1
var Buffer, create;
Buffer = require('buffer').Buffer;
create = require('./create');
module.exports = create('crc1', function(buf, previous) {
var accum, byte, crc, _i, _len;
if (!Buffer.isBuffer(buf)) {
buf = Buffer(buf);
}
crc = ~~previous;
accum = 0;
for (_i = 0, _len = buf.length; _i < _len; _i++) {
byte = buf[_i];
accum += byte;
}
crc += accum % 256;
return crc % 256;
});