Node: Buffer.write inconsistent

Created on 14 Mar 2020  路  3Comments  路  Source: nodejs/node

Version: v13.11.0
Platform: Windows 10
Subsystem: Buffer

Buffer.write is inconsistent with the other Buffer write methods because it doesn't return the offset only the bytes written.

buffer

Most helpful comment

Indeed, the return value looks inconsistent with other write* methods. Most likely that's because write was added in v0.1.90, while other methods are much newer. Unfortunately, changing this logic will break backwards compatibility, so I'm not sure if it should be fixed.

All 3 comments

Indeed, the return value looks inconsistent with other write* methods. Most likely that's because write was added in v0.1.90, while other methods are much newer. Unfortunately, changing this logic will break backwards compatibility, so I'm not sure if it should be fixed.

Maybe a deprecation cycle will help here?

@rexagod Realistically, we can鈥檛 just deprecate this method altogether, and there鈥檚 no good way to specifically attach a deprecation warning to the return value, and even if we did, there would be no good transition path to the consistent variant for users, and even if there was, moving existing npm ecosystem usage would take years, with a lot of annoyance for end users.

@puzpuzpuz is right here, this is a bit unfortunate but there鈥檚 nothing we can do about it at this point. I鈥檒l close this.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

danialkhansari picture danialkhansari  路  3Comments

Icemic picture Icemic  路  3Comments

danielstaleiny picture danielstaleiny  路  3Comments

filipesilvaa picture filipesilvaa  路  3Comments

mcollina picture mcollina  路  3Comments