From 563d9099a1eb3a7211ffb032e7554c44818228fd Mon Sep 17 00:00:00 2001 From: sun Date: Wed, 27 Sep 2023 17:50:41 +0800 Subject: [PATCH] feat[js]: javascript support compatible field --- .../resources/javascript/buffer/ByteBuffer.js | 57 ------------------- .../main/resources/javascript/buffer/long.js | 3 +- 2 files changed, 2 insertions(+), 58 deletions(-) diff --git a/protocol/src/main/resources/javascript/buffer/ByteBuffer.js b/protocol/src/main/resources/javascript/buffer/ByteBuffer.js index e0202e95a..970a836ed 100644 --- a/protocol/src/main/resources/javascript/buffer/ByteBuffer.js +++ b/protocol/src/main/resources/javascript/buffer/ByteBuffer.js @@ -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); @@ -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); @@ -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); }; @@ -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); diff --git a/protocol/src/main/resources/javascript/buffer/long.js b/protocol/src/main/resources/javascript/buffer/long.js index 31a8e6d7d..37026933b 100644 --- a/protocol/src/main/resources/javascript/buffer/long.js +++ b/protocol/src/main/resources/javascript/buffer/long.js @@ -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 @@ -1323,3 +1322,5 @@ Long.fromBytesBE = function fromBytesBE(bytes, unsigned) { unsigned ); }; + +export default Long; \ No newline at end of file