anza-xyz / anza-xyz/kit

toArrayBuffer: Negative-offset semantics are confusing/probably wrong

未關閉 適合新手
#1,960 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
TypeScript
星號
695
分支
210
平均合併
21 小時 33 分鐘
30 天內合併 PR
90

描述

Issue flagged by Trevor here: https://github.com/anza-xyz/kit/pull/1957#pullrequestreview-4982438072

> Negative-offset semantics are murky in the slow path. buffer.slice(bytesOffset, bytesOffset + bytesLength) with a negative bytesOffset produces an end index that crosses zero (e.g. slice(-1, 0) → empty buffer), so most negative offset/length combinations return empty buffers rather than tail slices. The existing it.each tests only assert not.toBe(buffer), so they don't catch this.

It seems like this is probably not behaving as we'd expect. Should probably try to make this behave exactly the same as native `slice` in this case.

貢獻指南

開啟貢獻指南

研究方向

Start at the toArrayBuffer implementation and its existing it.each tests, then compare the slow path's negative-offset behavior with native slice. Extend the tests to cover negative offset and length combinations, and consider the issue done when the helper returns the same results as native slice without weakening the existing buffer-identity assertions.

由索引模型根據 Issue 內容生成。

評估

技術堆疊
typescript
領域
blockchain
Issue 類型
缺陷
難度
2/5
預估耗時
1-3 小時
活躍度
活躍
描述清晰度
基本清楚
新手友好度
72/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。