doc: document the Buffer.prototype.*Slice() methods
I maintainer di solito rispondono entro 1 giorno
@AyushCipher ci sta già lavorando.
Dal 30/11/2026.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 86/100
- Tipo di issue
- Documentazione
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- javascript, markdown
- Ambito
- documentation
Direzione di ricerca
Inizia da doc/api/buffer.md e confronta la documentazione esistente di buf.toString(). Quindi esamina addBufferPrototypeMethods() in lib/internal/buffer.js per confermare i nomi dei metodi pubblici. Documenta i sette metodi buf.<encoding>Slice(), inclusi valori predefiniti, troncamento, errori di intervallo e raccomandazione di usare generalmente toString(). Controlla la documentazione dell’API Buffer generata e verifica ogni firma documentata rispetto all’implementazione.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- JavaScript
- Stelle
- 124k
- Fork
- 38k
- Merge medio
- 4g 2h
- PR unite (30g)
- 266
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di nodejs/node
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 69/100
I maintainer di solito rispondono entro 1 giorno
-
fs: document readStream.start and readStream.endForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertadoc
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
nodejs/node#67848 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
`styleText` fast path bypasses `options` and `options.validateStream` validationForse già presa @GBra-4-669 l’ha presa 8 giorni fa. Apertautil
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
riscv64
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
nodejs/node#67655 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
meta: macos-14 used in v22.x no longer available since Nov 2, 2026Forse già presa @npm-cli-bot l’ha presa 11 giorni fa. Apertamacos v22.x
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
nodejs/node#67643 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
Issue simili
-
bug triage needed
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 2 giorni
-
[Resource]: PersephoneApertaresource-submission validation-passed
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
hesreallyhim/awesome-claude-code#3773 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 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 statusForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
OCM: shares using the `embedded` protocol are rejected with "Missing sharedSecret in protocol"Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno