Skip to content

What about SlowBuffer? #5799

Closed
Closed
@ChALkeR

Description

@ChALkeR

SlowBuffer (and its documentation) has several issues atm:

  1. The documentation states that it's a class and lists only one method of creating a SlowBuffer: new SlowBuffer(size). On the other hand, all the tests, benchmarks, and even the code samples in the documentation exclude the new keyword and just call SlowBuffer(size): link. That has to be clarified in the docs.
  2. SlowBuffer(size) is unsafe, pretty much like Buffer(size) was. It doesn't have accidential call problem, though — there is no SlowBuffer(value). But it tells users that they should zero-fill the buffer themselves, which isn't very nice (the reasons were already discussed).
  3. What is the real reason for it to be a separate class nowdays, when Buffer instances are created without the constructor functions, but using a class method?
  4. (Not SlowBuffer), btw, Buffer(something) documentation still includes the new keyword: link. It's deprecated though, and can perhaps be left like that.
  5. Buffer.from('abc') also returns a pooled buffer afaik. There is an unpooled counterpart to Buffer.allocUnsafe(size), but not to all the other Buffer creation methods. Would anyone want those?

So, perhaps we should soft-deprecate SlowBuffer altogether and provide an API as Buffer methods, that would conform with Buffer.from() and Buffer.alloc()?

I'm not yet sure how that would look like — it could be some options to the current methods, scary-looking names like Buffer.allocSlow/Buffer.allocSlowUnsafe or even something like Buffer.Slow.alloc/Buffer.Slow.allocUnsafe.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bufferIssues and PRs related to the buffer subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions