Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

从试用到放弃 #4

Open
MissWho opened this issue Mar 12, 2024 · 2 comments
Open

从试用到放弃 #4

MissWho opened this issue Mar 12, 2024 · 2 comments

Comments

@MissWho
Copy link

MissWho commented Mar 12, 2024

1,readme代码跑不起来
UInt8Array实际为Uint8Array,小写i
返回的buffer实际struct.decode无法读取,需要传递buffer.buffer
`
import { qs } from "quick-struct";

const struct = qsstruct { u8 a; };

// Create a UInt8 array
const buffer = new UInt8Array([12]);

// Decode buffer
const result = struct.decode(buffer).toJson();

// Print decoded result
console.log(result.a);
`

2,十六进制FF06在i16和u16类型下输出均为1791,实际i16应为-250,无法转换为无符号i16
3,压缩过的核心代码?开源项目?基于2问题想动手修改核心代码来解决问题,结果发现build/index.js是压缩过的,算了,还是自己用DataView包装一下慢慢改吧。

@aokihu
Copy link
Owner

aokihu commented Aug 28, 2024

忘记测试有符号的数据了

github中是保存了源代码的,因为我的项目中不想把源代码集成进去,故而编译后使用

@aokihu
Copy link
Owner

aokihu commented Aug 28, 2024

1,readme代码跑不起来

UInt8Array实际为Uint8Array,小写i

返回的buffer实际struct.decode无法读取,需要传递buffer.buffer

`

import { qs } from "quick-struct";

const struct = qs`

struct {

    u8 a;

}

`;

// Create a UInt8 array

const buffer = new UInt8Array([12]);

// Decode buffer

const result = struct.decode(buffer).toJson();

// Print decoded result

console.log(result.a);

`

2,十六进制FF06在i16和u16类型下输出均为1791,实际i16应为-250,无法转换为无符号i16

3,压缩过的核心代码?开源项目?基于2问题想动手修改核心代码来解决问题,结果发现build/index.js是压缩过的,算了,还是自己用DataView包装一下慢慢改吧。

我新加了decode.test.mjs文件用来测试你说的第2个问题,但是测试结果是正确的,能再说说具体错误吗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants