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 the new keyword and just call SlowBuffer(size): link. That has to be clarified in the docs.
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).
- 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 the new 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 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.
SlowBuffer (and its documentation) has several issues atm:
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).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
Buffermethods, that would conform withBuffer.from()andBuffer.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.allocSlowUnsafeor even something likeBuffer.Slow.alloc/Buffer.Slow.allocUnsafe.