bnoordhuis / node-buffertools

working with node.js buffers made easy
ISC License
205 stars 35 forks source link

v0.11 support #56

Closed mcollina closed 10 years ago

mcollina commented 10 years ago

Will this library be updated to v0.11?

bnoordhuis commented 10 years ago

Maybe. I'm not sure how many people still use buffertools; it was originally developed at a time when Buffer was still a bare-bones class but nowadays that class has grown a lot of buffertools-like functionality. Maybe it's better to get the missing pieces upstreamed (compare, search, others?)

mcollina commented 10 years ago

I agree.

It's quite used at the moment, it has ~700 downloads a day. Most of those libraries will need special attention for 0.11/0.12 in any case, but reworking a dependency it's harder.

Do you think that a JS-only implementation of this it's too slow?

bnoordhuis commented 10 years ago

It would have been at the time when the Buffer class was introduced (the V8 magic backing buffers was almost completely unoptimized back then) but the performance difference is probably within a factor of two or three now.

At any rate, making it compatible with v0.11 isn't that complicated so I did in commit 559ca71 and published it as v2.1.0. Note that it only works with node.js master though, not the last v0.11 release.

mcollina commented 10 years ago

Cool, the whole idea is to have it compatible with v0.12 when it comes out later this year.

Mithgol commented 10 years ago

@bnoordhuis

Maybe it's better to get the missing pieces upstreamed (compare, search, others?)

  • [ ] .clear — there is .fill(0) in upstream
  • [x] .compareshould be upstreamed
  • [ ] .concat — there is .concat in upstream
  • [x] .equalsshould be upstreamed
  • [x] .fillshould be upstreamed to improve the upstream's .fill in a backwards-compatible manner
  • [ ] .fromHex — there is new Buffer(…, 'hex') in upstream
  • [x] .indexOfshould be upstreamed
  • [x] .reverseshould be upstreamed
  • [ ] .toHex — there is .toString('hex') in upstream
bnoordhuis commented 10 years ago

.fill — should be upstreamed to improve the upstream's .fill in a backwards-compatible manner

Does buffertools.fill() do anything that Buffer#fill() doesn't? I was under the impression that Trevor had implemented most everything in master.

Mithgol commented 10 years ago

Does Node.js buffer accept integers, buffers, strings as its fill values?

The documentation does not (currently) say anything about the value's accepted types, though the example demonstrates a 1-character-long string (but not mentioning its implied encoding).

bnoordhuis commented 10 years ago

Does Node.js buffer accept integers, buffers, strings as its fill values?

It does though it decodes buffers and strings to UTF-8. I suppose that's one possible enhancement, specifying the encoding.

Mithgol commented 10 years ago

Also, instead of decoding buffers to UTF-8, it probably should encode strings to buffers and fill buffers with buffers. Would make more sense.