Eslintify all of libtextsecure

This commit is contained in:
Scott Nonnenberg 2018-07-21 14:51:20 -07:00
commit 0774ba2903
36 changed files with 1960 additions and 2128 deletions

View file

@ -1,3 +1,5 @@
/* global dcodeIO, window, textsecure */
function ProtoParser(arrayBuffer, protobuf) {
this.protobuf = protobuf;
this.buffer = new dcodeIO.ByteBuffer();
@ -7,23 +9,23 @@ function ProtoParser(arrayBuffer, protobuf) {
}
ProtoParser.prototype = {
constructor: ProtoParser,
next: function() {
next() {
try {
if (this.buffer.limit === this.buffer.offset) {
return undefined; // eof
}
var len = this.buffer.readVarint32();
var nextBuffer = this.buffer
const len = this.buffer.readVarint32();
const nextBuffer = this.buffer
.slice(this.buffer.offset, this.buffer.offset + len)
.toArrayBuffer();
// TODO: de-dupe ByteBuffer.js includes in libaxo/libts
// then remove this toArrayBuffer call.
var proto = this.protobuf.decode(nextBuffer);
const proto = this.protobuf.decode(nextBuffer);
this.buffer.skip(len);
if (proto.avatar) {
var attachmentLen = proto.avatar.length;
const attachmentLen = proto.avatar.length;
proto.avatar.data = this.buffer
.slice(this.buffer.offset, this.buffer.offset + attachmentLen)
.toArrayBuffer();
@ -41,14 +43,16 @@ ProtoParser.prototype = {
error && error.stack ? error.stack : error
);
}
return null;
},
};
var GroupBuffer = function(arrayBuffer) {
const GroupBuffer = function Constructor(arrayBuffer) {
ProtoParser.call(this, arrayBuffer, textsecure.protobuf.GroupDetails);
};
GroupBuffer.prototype = Object.create(ProtoParser.prototype);
GroupBuffer.prototype.constructor = GroupBuffer;
var ContactBuffer = function(arrayBuffer) {
const ContactBuffer = function Constructor(arrayBuffer) {
ProtoParser.call(this, arrayBuffer, textsecure.protobuf.ContactDetails);
};
ContactBuffer.prototype = Object.create(ProtoParser.prototype);