Skip to content

feat(javascript): align buffer read/write API with Java naming#3346

Merged
chaokunyang merged 2 commits intoapache:mainfrom
miantalha45:feat/js-buffer-read-write-api
Feb 18, 2026
Merged

feat(javascript): align buffer read/write API with Java naming#3346
chaokunyang merged 2 commits intoapache:mainfrom
miantalha45:feat/js-buffer-read-write-api

Conversation

@miantalha45
Copy link
Contributor

@miantalha45 miantalha45 commented Feb 17, 2026

Summary

Aligns the JavaScript buffer API with Java and other xlang implementations by using explicit read* / write* method names only. No compatibility aliases; one-shot breaking change.

Changes

  • BinaryWriter (lib/writer/index.ts): Removed short-name aliases (int8, uint8, int16, etc.). Public write API is now only the existing write* methods (e.g. writeInt8, writeUint8, writeInt32, writeFloat64, writeGetCursor, etc.).
  • BinaryReader (lib/reader/index.ts): Removed short-name aliases. Public read API is now only the existing read* methods (e.g. readInt8, readUint8, readInt32, readGetCursor, readSetCursor, readSkip, etc.).
  • Codegen (lib/gen/builder.ts): BinaryWriterBuilder now emits write* calls (e.g. bw.writeInt8(...)); BinaryReaderBuilder now emits read* calls (e.g. br.readInt8(), br.readGetCursor()).
  • Tests (test/io.test.ts): Updated dynamic writer calls from writer['uint${x}'] / writer['int${x}'] to writer['writeUint${x}'] / writer['writeInt${x}'].

Requirements met

  • Writer methods use write* prefix (e.g. writeInt8, writeUint32).
  • Reader methods use read* prefix (e.g. readInt8, readUint32).
  • One-shot breaking rename; no old names, aliases, or deprecation shims.
  • All internal call sites, codegen, and tests updated.
  • Runtime behavior and performance unchanged.

Testing

  • cd javascript && node ./node_modules/.bin/jest --ci — all 18 suites pass (112 tests, 1 skipped).

Fixes #3345

return `${this.holder}.readSetCursor(${v})`;
}

varInt32() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also rename such methods?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have done this.

Copy link
Collaborator

@chaokunyang chaokunyang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@chaokunyang chaokunyang merged commit 184253c into apache:main Feb 18, 2026
57 checks passed
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

Successfully merging this pull request may close these issues.

[JavaScript] Align Buffer read/write API with java

2 participants