doc: document the Buffer.prototype.*Slice() methods
メンテナーはふだん 1 日以内に返信
@AyushCipher がすでに取り組んでいます。
2026年11月30日 から。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 86/100
- issue の種類
- ドキュメント
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- javascript, markdown
調査の方向性
doc/api/buffer.md から始め、既存の buf.toString() のドキュメントと比較します。次に、lib/internal/buffer.js の addBufferPrototypeMethods() を調査し、公開メソッド名を確認します。デフォルト値、切り詰め、範囲エラー、および一般には toString() を使用することが推奨される点を含め、7つの buf.<encoding>Slice() メソッドを文書化します。レンダリングされた Buffer API ドキュメントを確認し、文書化されたすべてのシグネチャを実装と照合して検証します。
索引モデルが issue の本文から書いたものです。
説明
Affected URL(s)
https://nodejs.org/api/buffer.html
Description of the problem
Buffer.prototype has seven encoding-specific methods that are public, supported in practice, and undocumented: asciiSlice(), base64Slice(), base64urlSlice(), hexSlice(), latin1Slice(), ucs2Slice() and utf8Slice(). addBufferPrototypeMethods() in lib/internal/buffer.js attaches them. They are not mentioned in doc/api/buffer.md on main, v24.x or v26.x.
They are used in the ecosystem because they decode a range without the work buf.toString(encoding, start, end) does first: clamping start/end with MathTrunc() and looking up the encoding with getEncodingOps(). Both end up in the same native functions. For short strings the difference is significant. For example, a tar header parser decodes several strings of 10 to 100 bytes per entry, and buf.utf8Slice(start, end) takes 122 ns per 20-byte string against 141 to 165 ns for buf.toString('utf8', start, end) (Node.js 24; 136 against 156 ns on 26.13.1).
#46467 raised this. Commenters favoured documenting them over leaving them public and undocumented, but it was closed as stale without a change.
I propose documenting them, for example as one section, buf.<encoding>Slice([start[, end]]), that says:
- they decode
buf[start, end)with the given encoding, likebuf.toString(encoding, start, end), without looking up the encoding; startdefaults to0andendtobuf.length, and fractional values are truncated;- unlike
toString(), indexes outside of the buffer are not clamped: they throwERR_OUT_OF_RANGE(Buffer.from('abc').utf8Slice(0, 100)), whilestart > endreturns''; toString()remains the recommended general API, and these are for when the encoding is known in advance.
I measured this behaviour on Node.js 24.22.3 and 26.13.1, and it is the same on both.
The matching *Write() methods (utf8Write(), latin1Write(), …) are attached and undocumented in the same way, and could be documented together, as was suggested in #46467.
I'm happy to send the docs PR.
- 主要言語
- JavaScript
- スター
- 124k
- フォーク
- 38k
- 平均マージ
- 4日 2時間
- マージ済み PR(30日)
- 266
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
nodejs/node のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 69/100
メンテナーはふだん 1 日以内に返信
-
fs: document readStream.start and readStream.end対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンdoc
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
nodejs/node#67848 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
`styleText` fast path bypasses `options` and `options.validateStream` validation対応中かも @GBra-4-669 が 8 日前に担当しました。 オープンutil
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
riscv64
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
nodejs/node#67655 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
meta: macos-14 used in v22.x no longer available since Nov 2, 2026対応中かも @npm-cli-bot が 11 日前に担当しました。 オープンmacos v22.x
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
nodejs/node#67643 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
似ている issue
-
bug triage needed
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 2 日以内に返信
-
resource-submission validation-passed
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
hesreallyhim/awesome-claude-code#3773 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
tabatkins/railroad-diagrams#129 ·
-
web: api() turns a null or object-valued error body into a TypeError or "[object Object]" and loses the status対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信