feat: refactoring project

This commit is contained in:
Carlos
2024-11-23 14:56:07 -05:00
parent f0c2a50c18
commit 1c6db5818d
2351 changed files with 39323 additions and 60326 deletions

View File

@@ -98,7 +98,7 @@ function alloc(length) {
if (result) {
bufPool[length] = undefined;
} else {
result = new Buffer(length);
result = new Uint8Array(length);
}
result.fill(0);
@@ -130,7 +130,11 @@ function resize(buffer, length) {
}
var newBuf = alloc(length);
buffer.copy(newBuf);
for (var i = 0; i <= buffer.length; i++) {
newBuf[i] = buffer[i];
}
free(buffer);
return newBuf;
}
@@ -231,6 +235,12 @@ function writeUInt64(value, buffer) {
var lowWord = value % BIT_32;
var highWord = Math.floor(value / BIT_32);
buffer.writeUInt32LE(lowWord, 0);
buffer.writeUInt32LE(highWord, 4);
buffer[0] = lowWord & 0xff;
buffer[1] = lowWord >> 8 & 0xff;
buffer[2] = lowWord >> 16 & 0xff;
buffer[3] = lowWord >> 24 & 0xff;
buffer[4] = highWord & 0xff;
buffer[5] = highWord >> 8 & 0xff;
buffer[6] = highWord >> 16 & 0xff;
buffer[7] = highWord >> 24 & 0xff;
}

View File

@@ -222,10 +222,12 @@ function decodeIntBuffer(encodedBuffer, index) {
}
function encodeInt32(num) {
var buf = bufs.alloc(4);
buf.writeInt32LE(num, 0);
var buf = new Uint8Array(4);
buf[0] = num & 0xff;
buf[1] = num >> 8 & 0xff;
buf[2] = num >> 16 & 0xff;
buf[3] = num >> 24 & 0xff;
var result = encodeIntBuffer(buf);
bufs.free(buf);
return result;
}
@@ -282,10 +284,12 @@ function decodeUIntBuffer(encodedBuffer, index) {
}
function encodeUInt32(num) {
var buf = bufs.alloc(4);
buf.writeUInt32LE(num, 0);
var buf = new Uint8Array(4);
buf[0] = num & 0xff;
buf[1] = num >> 8 & 0xff;
buf[2] = num >> 16 & 0xff;
buf[3] = num >> 24 & 0xff;
var result = encodeUIntBuffer(buf);
bufs.free(buf);
return result;
}

View File

@@ -1,6 +1,6 @@
{
"name": "@webassemblyjs/leb128",
"version": "1.11.6",
"version": "1.13.2",
"description": "LEB128 decoder and encoder",
"license": "Apache-2.0",
"main": "lib/index.js",
@@ -18,5 +18,6 @@
},
"publishConfig": {
"access": "public"
}
},
"gitHead": "897aeb784f042a46a00626f1d1cca96159aa5db3"
}