Skip to content

Commit

Permalink
feat[js]: javascript support compatible field
Browse files Browse the repository at this point in the history
  • Loading branch information
jaysunxiao committed Sep 27, 2023
1 parent 3dc261e commit 563d909
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 58 deletions.
57 changes: 0 additions & 57 deletions protocol/src/main/resources/javascript/buffer/ByteBuffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,18 +354,6 @@ const ByteBuffer = function() {
return value;
};

this.writeChar = function(value) {
if (value === null || value === undefined || value.length === 0) {
this.writeString(empty_str);
return;
}
this.writeString(value.charAt(0));
};

this.readChar = function() {
return this.readString();
};

this.writeString = function(value) {
if (value === null || value === undefined || value.trim().length === 0) {
this.writeInt(0);
Expand Down Expand Up @@ -583,28 +571,6 @@ const ByteBuffer = function() {
return array;
};

this.writeCharArray = function(array) {
if (array === null) {
this.writeInt(0);
} else {
this.writeInt(array.length);
array.forEach(element => {
this.writeChar(element);
});
}
};

this.readCharArray = function() {
const array = [];
const length = this.readInt();
if (length > 0) {
for (let index = 0; index < length; index++) {
array.push(this.readChar());
}
}
return array;
};

this.writePacketArray = function(array, protocolId) {
if (array === null) {
this.writeInt(0);
Expand Down Expand Up @@ -694,14 +660,6 @@ const ByteBuffer = function() {
return this.readStringArray();
};

this.writeCharList = function(list) {
this.writeCharArray(list);
};

this.readCharList = function() {
return this.readCharArray();
};

this.writePacketList = function(list, protocolId) {
this.writePacketArray(list, protocolId);
};
Expand Down Expand Up @@ -831,21 +789,6 @@ const ByteBuffer = function() {
return new Set(this.readStringArray());
};

this.writeCharSet = function(set) {
if (set === null) {
this.writeInt(0);
} else {
this.writeInt(set.size);
set.forEach(element => {
this.writeChar(element);
});
}
};

this.readCharSet = function() {
return new Set(this.readCharArray());
};

this.writePacketSet = function(set, protocolId) {
if (set === null) {
this.writeInt(0);
Expand Down
3 changes: 2 additions & 1 deletion protocol/src/main/resources/javascript/buffer/long.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* eslint-disable */
// from https://github.com/dcodeIO/long.js/blob/master/src/long.js
module.exports = Long;

/**
* wasm optimizations, to do native i64 multiplication and divide
Expand Down Expand Up @@ -1323,3 +1322,5 @@ Long.fromBytesBE = function fromBytesBE(bytes, unsigned) {
unsigned
);
};

export default Long;

0 comments on commit 563d909

Please sign in to comment.