-
-
Notifications
You must be signed in to change notification settings - Fork 35.2k
What about SlowBuffer? #5799
Copy link
Copy link
Closed
Labels
bufferIssues and PRs related to the buffer subsystem.Issues and PRs related to the buffer subsystem.
Description
SlowBuffer (and its documentation) has several issues atm:
- 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 thenewkeyword and just callSlowBuffer(size): link. That has to be clarified in the docs. SlowBuffer(size)is unsafe, pretty much likeBuffer(size)was. It doesn't have accidential call problem, though — there is noSlowBuffer(value). But it tells users that they should zero-fill the buffer themselves, which isn't very nice (the reasons were already discussed).- 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?
- (Not
SlowBuffer), btw,Buffer(something)documentation still includes thenewkeyword: link. It's deprecated though, and can perhaps be left like that. Buffer.from('abc')also returns a pooled buffer afaik. There is an unpooled counterpart toBuffer.allocUnsafe(size), but not to all the otherBuffercreation 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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bufferIssues and PRs related to the buffer subsystem.Issues and PRs related to the buffer subsystem.