Closed
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 thenew
keyword 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 thenew
keyword: 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 otherBuffer
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
.